|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdd.sim.SimObject
dd.sim.MapCell
A single geographic location in a map. The simulation map is broken down into multiple hexagonal areas called cells. A MapCell has a location within a map and stores attributes related to its location. Attributes may be location specific or may be organized into layers.
Because of the tight connection between Maps and MapCells, a MapCell must have an associated map in order to work properly.
Field Summary |
Fields inherited from class dd.sim.SimObject |
attributes |
Constructor Summary | |
MapCell(Map map,
int row,
int column)
Create a new map cell at the current location. |
Method Summary | |
void |
addLayer(Layer layer)
Add a layer to the current cell. |
java.util.List |
attributesInRange(Layer layer,
float minValue,
float maxValue)
Finds all attributes on a layer between a minimum and maximum value. |
double |
cDistanceTo(MapCell anotherCell)
Computes the cellwise distance between this and another cell. |
java.util.Collection |
cellsWithin(int distance)
Returns all cells within a specified distance from this one. |
double |
eDistanceTo(MapCell anotherCell)
Computes the Euclidean distance between this and another cell. |
float |
getAttribute(java.lang.String attributeName,
Layer layer)
Queries this cell for an attribute associated with a specified layer. |
float |
getAttribute(java.lang.String attributeName,
Layer layer,
float defaultValue)
Queries this cell for an attribute associated with a specified layer. |
int |
getColumn()
Get the cell's column in Map coordinates. |
java.util.Map |
getLayerAttributes(Layer layer)
Returns all of the attributes that are associated with a layer. |
java.util.Collection |
getLayers()
Returns all the layers associated with this cell. |
Map |
getMap()
Returns the map associated with this cell. |
java.lang.String |
getName()
Get the cell's name: its Map coordinates as a string of the form "<row, col>". |
java.util.Collection |
getNeighbors()
Returns all of the cells directly adjacent to this cell. |
java.lang.Object |
getObjectAttribute(java.lang.String attributeName,
Layer layer)
Queries this cell for an attribute associated with a specified layer. |
int |
getRow()
Get the cell's row in Map coordinates. |
double |
getX()
Get the cell's geographic X coordinate. |
double |
getY()
Get the cell's geographic Y coordinate. |
boolean |
hasAttribute(java.lang.String attributeName,
Layer layer)
Queries whether a cell has an attribute on this layer. |
boolean |
isSet(java.lang.String attributeName,
Layer layer)
Indicates whether this cell has an attribute set (with non-zero value) with the specified name on the specified layer. |
MapCell |
north()
Returns the cell north of this cell. |
MapCell |
northEast()
Returns the cell northeast of this cell. |
MapCell |
northWest()
Returns the cell northwest of this cell. |
java.lang.String |
printName()
|
void |
setAttribute(java.lang.String attributeName,
Layer layer,
float value)
Sets the attribute associated with a specified layer. |
void |
setAttribute(java.lang.String attributeName,
Layer layer,
java.lang.Object value)
Sets the attribute associated with a specified layer. |
void |
setColumn(int column)
Set the cell's column in Map coordinates. |
void |
setMap(Map map)
Sets the map associated with this cell. |
void |
setRow(int row)
Set the cell's row in Map coordinates. |
void |
setX(double x)
Set the cell's geographic X coordinate. |
void |
setY(double y)
Set the cell's geographic Y coordinate. |
MapCell |
south()
Returns the cell south of this cell. |
MapCell |
southEast()
Returns the cell southeast of this cell. |
MapCell |
southWest()
Returns the cell southwest of this cell. |
java.lang.String |
toString()
Provide a textual description of the map cell. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MapCell(Map map, int row, int column)
map
- Map in which this cell existsrow
- row of the cell, in Map coordinatescolumn
- column of the cell, in Map coordinatesMethod Detail |
public java.lang.String getName()
public int getRow()
getY()
public void setRow(int row)
row
- new row of the cell, in Map coordinatessetY(double)
public int getColumn()
getX()
public void setColumn(int column)
column
- new column of the cell, in Map coordinatessetX(double)
public double getX()
public void setX(double x)
x
- the horizontal coordinate of the center of the cellpublic double getY()
public void setY(double y)
y
- the vertical coordinate of the center of the cellpublic Map getMap()
public void setMap(Map map)
map
- the map in which this cell existspublic MapCell north()
null
if it does not
exist.Map.northOf(MapCell)
public MapCell south()
null
if it does not
exist.Map.southOf(MapCell)
public MapCell northEast()
null
if it does
not exist.Map.northEastOf(MapCell)
public MapCell southEast()
null
if it does
not exist.Map.southEastOf(MapCell)
public MapCell northWest()
null
if it does
not exist.Map.northWestOf(MapCell)
public MapCell southWest()
null
if it does
not exist.Map.northWestOf(MapCell)
public java.util.Collection getNeighbors()
public double eDistanceTo(MapCell anotherCell)
anotherCell
- cell to which distance should be computed
Map.eDistanceBetweenCells(MapCell,MapCell)
public double cDistanceTo(MapCell anotherCell)
anotherCell
- cell to which distance should be computed
Map.cDistanceBetweenCells(MapCell,MapCell)
public java.util.Collection cellsWithin(int distance)
distance
- Cartesian distance threshold
distance
or less units away
from this cell.public void addLayer(Layer layer)
layer
- layer to associate with this cellpublic java.util.Collection getLayers()
public java.util.Map getLayerAttributes(Layer layer)
layer
- the layer of attributes to be retrieved
public boolean hasAttribute(java.lang.String attributeName, Layer layer)
null
, but easier to read.
attributeName
- name of the attribute to be queriedlayer
- layer with which the attribute is associated
true
if the cell has an attribute with this name
on this layer, false
otherwise.public float getAttribute(java.lang.String attributeName, Layer layer)
getObjectAttribute
method,
which shares the same variables.
attributeName
- name of the attribute to be queriedlayer
- layer with which the attribute is associated
java.util.NoSuchElementException
- if there is no attribute with that name
associated with that layer.public java.util.List attributesInRange(Layer layer, float minValue, float maxValue)
layer
- layer whose attributes should be queriedminValue
- lower end of rangemaxValue
- upper end of range
public float getAttribute(java.lang.String attributeName, Layer layer, float defaultValue)
getObjectAttribute
method,
which shares the same variables.
attributeName
- name of the attribute to be queriedlayer
- layer with which the attribute is associateddefaultValue
- default if the attribute does not exist
public boolean isSet(java.lang.String attributeName, Layer layer)
attributeName
- name of the attribute to be testedlayer
- layer with which the attribute is associated
public java.lang.Object getObjectAttribute(java.lang.String attributeName, Layer layer)
attributeName
- name of the attribute to be queriedlayer
- layer with which the attribute is associated
null
if the attribute does not existpublic void setAttribute(java.lang.String attributeName, Layer layer, float value)
attributeName
- name of the attribute to setlayer
- layer on which the attribute should existvalue
- value to which the attribute should be setPropertyChangeEvent
public void setAttribute(java.lang.String attributeName, Layer layer, java.lang.Object value)
attributeName
- name of the attribute to setlayer
- layer on which the attribute should existvalue
- value to which the attribute should be setPropertyChangeEvent
public java.lang.String printName()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |