com.dbarnes.sgme
Class Map

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

public class Map
extends java.lang.Object

Represents a map in a project. A map contains a two-dimensional array of tile IDs, as well as a list of MapWidget objects. Maps also can have a background color, which is defined by a single RGB value.


Field Summary
static int MAX_HEIGHT
           
static int MAX_WIDTH
           
 
Constructor Summary
Map()
          Creates a new Map object.
 
Method Summary
 MapWidget addMapWidget(int x, int y, Widget widget)
          Adds a MapWidget at the specified coordinates.
 void deleteColumn(int deleteAtX)
          Deletes a column of tiles at the specified column index, and shifts all columns to the right of that index to the left by one column.
 boolean deleteMapWidget(MapWidget mapWidget)
          Removes the specified MapWidget object from the map.
 void deleteMapWidgets(int x, int y)
          Removes all MapWidgets for the specified coordinates.
 void deleteMapWidgets(Widget widget)
          Removes all MapWidgets for the specified Widget.
 void deleteRow(int deleteAtY)
          Deletes a row of tiles at the specified row index, and shifts all rows below that index up by one row.
 int getBackgroundColor()
           
 int getHeight()
          Returns the height of the map.
 int getId()
          Returns the identifier for this Map.
 int getMapWidgetCount()
          Returns the number of map widgets.
 java.util.Iterator<MapWidget> getMapWidgets()
          Returns an iterator containing all the MapWidget objects for this Map.
 java.util.Iterator<MapWidget> getMapWidgets(int x, int y)
          Returns an Iterator containing the MapWidget objects at the specified coordinates.
 java.util.Iterator<MapWidget> getMapWidgets(Widget widget)
          Returns an Iterator containing the MapWidget objects for the specified Widget.
 Tile getTile(int x, int y)
          Returns the Tile object at the specified x and y coordinates.
 int getWidth()
          Returns the width of the map.
 void insertColumn(int insertAtX)
          Inserts a column of blank tiles at the specified column index.
 void insertRow(int insertAtY)
          Inserts a row of blank tiles at the specified row index.
 void setBackgroundColor(int backgroundColor)
           
 void setHeight(int height)
          Sets the height of the map.
 void setId(int id)
          Sets the identifier for this Map.
 void setTile(int x, int y, Tile tile)
          Sets the Tile object at the specified x and y coordinates.
 void setWidth(int width)
          Sets the width of the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_WIDTH

public static final int MAX_WIDTH
See Also:
Constant Field Values

MAX_HEIGHT

public static final int MAX_HEIGHT
See Also:
Constant Field Values
Constructor Detail

Map

public Map()
Creates a new Map object.

Method Detail

insertColumn

public void insertColumn(int insertAtX)
Inserts a column of blank tiles at the specified column index. This operation will not change the size of the map; the data in the right-most column in the map will be lost.


deleteColumn

public void deleteColumn(int deleteAtX)
Deletes a column of tiles at the specified column index, and shifts all columns to the right of that index to the left by one column. The right-most column will be blank after this operation.


insertRow

public void insertRow(int insertAtY)
Inserts a row of blank tiles at the specified row index. This operation will not change the size of the map; the data in the bottom-most row in the map will be lost.


deleteRow

public void deleteRow(int deleteAtY)
Deletes a row of tiles at the specified row index, and shifts all rows below that index up by one row. The bottom-most row will be blank after this operation.


getTile

public Tile getTile(int x,
                    int y)
Returns the Tile object at the specified x and y coordinates. If no Tile object has been assigned at those coordinates, returns null.


setTile

public void setTile(int x,
                    int y,
                    Tile tile)
Sets the Tile object at the specified x and y coordinates.


getWidth

public int getWidth()
Returns the width of the map.


setWidth

public void setWidth(int width)
Sets the width of the map. Internal storage is adjusted automatically. If the size is decreased, any data outside of the new map boundaries will be lost.


getHeight

public int getHeight()
Returns the height of the map.


setHeight

public void setHeight(int height)
Sets the height of the map. Internal storage is adjusted automatically. If the size is decreased, any data outside of the new map boundaries will be lost.


getId

public int getId()
Returns the identifier for this Map.


setId

public void setId(int id)
Sets the identifier for this Map.


getMapWidgets

public java.util.Iterator<MapWidget> getMapWidgets()
Returns an iterator containing all the MapWidget objects for this Map.

Returns:
Iterator containing MapWidget objects.

getMapWidgetCount

public int getMapWidgetCount()
Returns the number of map widgets.

Returns:
The number of MapWidget objects for this map.

getMapWidgets

public java.util.Iterator<MapWidget> getMapWidgets(int x,
                                                   int y)
Returns an Iterator containing the MapWidget objects at the specified coordinates.

Parameters:
x - the x coordinate of the MapWidget objects to return.
y - the y coordinate of the MapWidget objects to return.
Returns:
Iterator containing MapWidget objects.

getMapWidgets

public java.util.Iterator<MapWidget> getMapWidgets(Widget widget)
Returns an Iterator containing the MapWidget objects for the specified Widget.

Parameters:
widget - the widget of the MapWidget objects to return.
Returns:
Iterator containing MapWidget objects.

addMapWidget

public MapWidget addMapWidget(int x,
                              int y,
                              Widget widget)
Adds a MapWidget at the specified coordinates.

Returns:
the new MapWidget object.

deleteMapWidget

public boolean deleteMapWidget(MapWidget mapWidget)
Removes the specified MapWidget object from the map.

Parameters:
mapWidget - the MapWidget object to remove.
Returns:
true if map contained the specified MapWidget; false otherwise.

deleteMapWidgets

public void deleteMapWidgets(Widget widget)
Removes all MapWidgets for the specified Widget.

Parameters:
widget - the Widget of the MapWidget objects to remove.

deleteMapWidgets

public void deleteMapWidgets(int x,
                             int y)
Removes all MapWidgets for the specified coordinates.

Parameters:
x - the x coordinate of the MapWidget objects to remove.
y - the y coordinate of the MapWidget objects to remove.

getBackgroundColor

public int getBackgroundColor()

setBackgroundColor

public void setBackgroundColor(int backgroundColor)


Copyright 2006-2009 Don Barnes. All Rights Reserved.