com.dbarnes.sgme
Class Project

java.lang.Object
  extended by com.dbarnes.sgme.Project

public class Project
extends java.lang.Object

Represents a single project.


Field Summary
static java.lang.String PROJECT_FILE_EXTENSION
           
 
Constructor Summary
Project()
          Creates and initializes this Project object.
 
Method Summary
 void addMap(Map map)
          Adds the specified map to the project.
 void addTile(Tile tile)
          Adds the specified tile to the project.
 void addTileImage(TileImage tileImage)
          Adds the specified tile image to the project.
 java.util.Collection<TileImage> addTileImageFile(TileImageFile tileImageFile)
          Adds the specified tile image file to the project, and creates and adds to the project the corresponding tile images.
 void addWidget(Widget widget)
          Adds the specified widget to the project.
 void clearAttributes()
          Clears the list of custom attributes.
 void clearTiles()
          Clears the list of tiles.
 java.util.Collection<Tile> createDefaultTiles(java.util.Collection<TileImage> tileImages)
          Given the specified collection of TileImage objects, creates a set of default Tile objects.
 java.lang.String getAttribute(java.lang.String key)
          Returns a custom attribute.
 java.util.Iterator<java.lang.String> getAttributeNames()
          Returns an iterator containing the names of all the custom attributes.
 java.io.File getFile()
          Returns a File object representing the main project file.
 int getLastMapId()
          Returns the highest numbered identifier for a Map object in this project.
 int getLastTileId()
          Returns the highest numbered identifier for a Tile object in this project.
protected  int getLastTileImageId()
          Returns the highest numbered identifier for a TileImage object in this project.
 int getLastWidgetId()
          Returns the highest numbered identifier for a Widget object in this project.
 java.util.Iterator<Map> getMaps()
          Returns an Iterator containing all the Map objects in this project.
 java.lang.String getRelativePath(java.io.File file)
          Attempts to resolve the path to the specified file, relative to the main project file.
 Tile getTileById(int id)
          Returns the Tile object with the specified identifier, or null if no such Tile object exists.
 int getTileCount()
          Returns a count of all the Tile objects in this project.
 int getTileHeight()
          Returns the tile height for this project.
 TileImage getTileImageById(int id)
          Returns the TileImage object with the specified identifier, or null if no such TileImage object exists.
 java.util.Iterator<TileImageFile> getTileImageFiles()
          Returns a Collection containing all the TileImageFile objects in this project.
 java.util.Iterator<TileImage> getTileImages()
          Returns a Collection containing all the TileImage objects in this project.
 java.util.Iterator<Tile> getTiles()
          Returns an Iterator containing all the Tile objects in this project.
 int getTileWidth()
          Returns the tile width for this project.
 Widget getWidgetById(int id)
          Returns the Widget object with the specified identifier, or null if no such Widget object exists.
 int getWidgetCount()
          Returns a count of all the Widget objects in this project.
 java.util.Iterator<Widget> getWidgets()
          Returns an Iterator containing all the Widget objects in this project.
 boolean isNeedsSave()
          Returns whether a save of the project is needed.
 void load()
          Loads this project from a project file.
 void removeMap(Map map)
          Removes the specified map from the project.
 void removeWidget(int id)
          Removes the specified widget from the project, and removes any associated MapWidget objects from all maps in the project.
 void save()
          Saves this project as a project file.
 void setAttribute(java.lang.String key, java.lang.String value)
          Sets a custom attribute.
 void setFile(java.io.File file)
          Sets the File object representing the main project file.
 void setNeedsSave(boolean needsSave)
          Sets whether a save of the project is needed.
 void setTileHeight(int tileHeight)
          Sets the tile height for this project.
 void setTileWidth(int tileWidth)
          Sets the tile width for this project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROJECT_FILE_EXTENSION

public static final java.lang.String PROJECT_FILE_EXTENSION
See Also:
Constant Field Values
Constructor Detail

Project

public Project()
Creates and initializes this Project object.

Method Detail

addTileImageFile

public java.util.Collection<TileImage> addTileImageFile(TileImageFile tileImageFile)
Adds the specified tile image file to the project, and creates and adds to the project the corresponding tile images.

Parameters:
tileImageFile - Tile image file to add to this project
Returns:
Collection of derived tile images that were added to the project.

addTileImage

public void addTileImage(TileImage tileImage)
Adds the specified tile image to the project.

Parameters:
tileImage - Tile image to add to this project

createDefaultTiles

public java.util.Collection<Tile> createDefaultTiles(java.util.Collection<TileImage> tileImages)
Given the specified collection of TileImage objects, creates a set of default Tile objects.

Parameters:
tileImages - Collection of TileImage objects.

addTile

public void addTile(Tile tile)
Adds the specified tile to the project.

Parameters:
tile - Tile to add to this project

addWidget

public void addWidget(Widget widget)
Adds the specified widget to the project.

Parameters:
widget - Widget to add to this project

addMap

public void addMap(Map map)
Adds the specified map to the project.

Parameters:
map - Map to add to this project

removeWidget

public void removeWidget(int id)
Removes the specified widget from the project, and removes any associated MapWidget objects from all maps in the project.

Parameters:
id - ID of the widget to remove from this project

removeMap

public void removeMap(Map map)
Removes the specified map from the project.


save

public void save()
          throws java.io.IOException
Saves this project as a project file. The file property must be set before calling this method.

Throws:
java.io.IOException

load

public void load()
          throws java.lang.InterruptedException
Loads this project from a project file. The file property must be set before calling this method.

Throws:
java.lang.InterruptedException

getLastTileImageId

protected int getLastTileImageId()
Returns the highest numbered identifier for a TileImage object in this project.


getLastTileId

public int getLastTileId()
Returns the highest numbered identifier for a Tile object in this project.


getLastMapId

public int getLastMapId()
Returns the highest numbered identifier for a Map object in this project.


getLastWidgetId

public int getLastWidgetId()
Returns the highest numbered identifier for a Widget object in this project.


getTileWidth

public int getTileWidth()
Returns the tile width for this project.


setTileWidth

public void setTileWidth(int tileWidth)
Sets the tile width for this project.


getTileHeight

public int getTileHeight()
Returns the tile height for this project.


setTileHeight

public void setTileHeight(int tileHeight)
Sets the tile height for this project.


getTileImages

public java.util.Iterator<TileImage> getTileImages()
Returns a Collection containing all the TileImage objects in this project.


getTileImageById

public TileImage getTileImageById(int id)
Returns the TileImage object with the specified identifier, or null if no such TileImage object exists.


getTileImageFiles

public java.util.Iterator<TileImageFile> getTileImageFiles()
Returns a Collection containing all the TileImageFile objects in this project.


getTiles

public java.util.Iterator<Tile> getTiles()
Returns an Iterator containing all the Tile objects in this project.


getTileCount

public int getTileCount()
Returns a count of all the Tile objects in this project.


getTileById

public Tile getTileById(int id)
Returns the Tile object with the specified identifier, or null if no such Tile object exists.


getWidgetById

public Widget getWidgetById(int id)
Returns the Widget object with the specified identifier, or null if no such Widget object exists.


isNeedsSave

public boolean isNeedsSave()
Returns whether a save of the project is needed.


setNeedsSave

public void setNeedsSave(boolean needsSave)
Sets whether a save of the project is needed.


getFile

public java.io.File getFile()
Returns a File object representing the main project file.


setFile

public void setFile(java.io.File file)
Sets the File object representing the main project file.


getMaps

public java.util.Iterator<Map> getMaps()
Returns an Iterator containing all the Map objects in this project.


getWidgets

public java.util.Iterator<Widget> getWidgets()
Returns an Iterator containing all the Widget objects in this project.


getWidgetCount

public int getWidgetCount()
Returns a count of all the Widget objects in this project.


getRelativePath

public java.lang.String getRelativePath(java.io.File file)
Attempts to resolve the path to the specified file, relative to the main project file. If the specified File object already represents a relative path, that path is returned. Otherwise, if the specified file is below or at the same directory as the main project file, the relative path to the file is returned. Otherwise, the absolute path to the specified file is returned.


clearTiles

public void clearTiles()
Clears the list of tiles.


clearAttributes

public void clearAttributes()
Clears the list of custom attributes.


setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
Sets a custom attribute.


getAttribute

public java.lang.String getAttribute(java.lang.String key)
Returns a custom attribute.


getAttributeNames

public java.util.Iterator<java.lang.String> getAttributeNames()
Returns an iterator containing the names of all the custom attributes.



Copyright 2006-2009 Don Barnes. All Rights Reserved.