edu.brook.ascape.model
Class Cell

java.lang.Object
  |
  +--edu.brook.ascape.model.AscapeObject
        |
        +--edu.brook.ascape.model.Agent
              |
              +--edu.brook.ascape.model.Cell
Direct Known Subclasses:
CellOccupant, HostCell

public class Cell
extends Agent

The base class for all members of lattices. Currently considered a node, although nodes might be become a superclass of this class as the notion of a coordinate may not be useful in all graphs.

Version:
1.2
See Also:
Serialized Form

Field Summary
protected  Cell[] cellsNear
          Cells near to this one in ever exanding radiis, including self.
protected  CoordinateDiscrete coordinate
          The coordinate location of this cell within the relevant scape.
protected  Cell[] neighbors
          For better performance we store neighbors so we only have to calculate them once.
protected  int thisUpdate
           
 
Fields inherited from class edu.brook.ascape.model.Agent
DEATH_RULE, deleteMarker, FISSIONING_RULE, FORCE_DIE_RULE, FORCE_FISSION_RULE, FORCE_MOVE_RULE, INITIALIZE_RULE, initialized, ITERATE_AND_UPDATE_RULE, ITERATE_RULE, METABOLISM_RULE, MOVEMENT_RULE, UPDATE_RULE
 
Fields inherited from class edu.brook.ascape.model.AscapeObject
ARBITRARY_SEED, count, name, scape
 
Constructor Summary
Cell()
           
 
Method Summary
 java.lang.Object clone()
          Clones the host cell, making coordinate null.
 int countNeighbors(Conditional condition)
          Returns the number of cells that are neighbors and that meet the supplied condition.
 int countWithin(Conditional condition, boolean includeOrigin, double maximumDistance)
          Returns the number of cells within the supplied distance that meet the supplied condition.
 void die()
          Kill the agent.
 Cell findMaximumWithin(DataPoint point, int distance, boolean includeOrigin)
           
 Cell findNearestCell(Conditional condition)
          Finds the nearest cell that meets some condition.
 Cell findNearestCell(Conditional condition, boolean includeOrigin)
          Finds the nearest cell that meets some condition.
 Cell findNearestCell(Conditional condition, boolean includeOrigin, double maximumDistance)
          Finds the nearest cell that meets some condition.
 Cell findRandomNeighbor()
          Returns a cell randomly selected from among this cell's neighbors.
 Cell[] getCellsNear(int distance, boolean includeSelf)
          Returns cells that are near this cell.
 CoordinateDiscrete getCoordinate()
          Gets the location of this cell within the relevant scape.
 int getDistance(Cell target)
           
 Cell[] getNeighbors()
          Returns this cells neighbors, that is, the set of cells adjoing this cell as defined by the scape's geometry.
 java.util.Vector getNeighbors(Conditional condition)
          Returns the neighbors of the cell that meet the supplied condition.
 Cell[] getNetwork()
          Returns some network of related cells.
 CellOccupant getOccupant()
          Returns any occupants of this cell.
 boolean hasWithin(Conditional condition, boolean includeOrigin, double maximumDistance)
          Returns true of there is a cell within the supplied distance that meets the supplied condition.
 void initialize()
          Initializes the cell, calculating neighbors if appropriate.
 boolean isAvailable()
          Is this cell available for occupation? Again, this will always return false because base cells can not host agents.
 boolean isUpdateNeeded(int within)
          Has a view update been requested for this cell?
 void removeOccupant()
          Removes this cell's occupant.
 void requestUpdate()
          Indicate to all views of this cell that an update is needed.
 void requestUpdateNext()
          Indicate to all views of this cell that an update is needed next iteration.
 void setCoordinate(CoordinateDiscrete coordinate)
          Returns the extent of the nth dimension.
 void setNeighbors(Cell[] neighbors)
          Sets this cell's neighbors.
 void setNetwork(Cell[] network)
          Sets a network of related cells.
 void setOccupant(CellOccupant occupant)
          Sets this cell's occupant.
 java.lang.String toString()
          A string representation of this cell.
 
Methods inherited from class edu.brook.ascape.model.Agent
death, deathCondition, execute, execute, fission, fissionCondition, fissioning, getColor, getColor, getImage, getImage, getIteration, getModel, getRoot, isDelete, isInitialized, iterate, markForDeletion, metabolism, move, movement, movementCondition, play, scapeCreated, update
 
Methods inherited from class edu.brook.ascape.model.AscapeObject
getName, getRandom, getRandomSeed, getScape, randomInRange, randomInRange, randomIs, randomToLimit, reseed, setName, setRandom, setRandomSeed, setScape
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

coordinate

protected CoordinateDiscrete coordinate
The coordinate location of this cell within the relevant scape.

neighbors

protected Cell[] neighbors
For better performance we store neighbors so we only have to calculate them once. Typically only used by scapes with a static strucure.

cellsNear

protected Cell[] cellsNear
Cells near to this one in ever exanding radiis, including self.

thisUpdate

protected int thisUpdate
Constructor Detail

Cell

public Cell()
Method Detail

getCoordinate

public CoordinateDiscrete getCoordinate()
Gets the location of this cell within the relevant scape. Warning, may be null for memebrs of scape vector. A more elegant way of handling this will be worked out. (We don't want to simply test for membership in a 'stretchy' geometry, because of performance concerns.)
Parameters:
int - dimensionCount the number of dimensions

setCoordinate

public void setCoordinate(CoordinateDiscrete coordinate)
Returns the extent of the nth dimension.

initialize

public void initialize()
Initializes the cell, calculating neighbors if appropriate.
Overrides:
initialize in class Agent

die

public void die()
Kill the agent.
Overrides:
die in class Agent

getNeighbors

public Cell[] getNeighbors()
Returns this cells neighbors, that is, the set of cells adjoing this cell as defined by the scape's geometry.

getCellsNear

public Cell[] getCellsNear(int distance,
                           boolean includeSelf)
Returns cells that are near this cell.
Parameters:
centralAgent - the agent to find cells near
distance - the distance from origin to return cells
includeSelf - should supplied agent be included in the return set

findNearestCell

public Cell findNearestCell(Conditional condition)
Finds the nearest cell that meets some condition.
Parameters:
condition - the condition that found cell must meet

findNearestCell

public Cell findNearestCell(Conditional condition,
                            boolean includeOrigin)
Finds the nearest cell that meets some condition.
Parameters:
condition - the condition that found cell must meet
includeOrigin - should this agent be included in the search

findNearestCell

public Cell findNearestCell(Conditional condition,
                            boolean includeOrigin,
                            double maximumDistance)
Finds the nearest cell that meets some condition.
Parameters:
condition - the condition that found cell must meet
includeOrigin - should this agent be included in the search
maximumDistance - the maximum distance to search within

findMaximumWithin

public Cell findMaximumWithin(DataPoint point,
                              int distance,
                              boolean includeOrigin)

getNeighbors

public java.util.Vector getNeighbors(Conditional condition)
Returns the neighbors of the cell that meet the supplied condition.
Parameters:
condition - the condition that found cell must meet

countNeighbors

public int countNeighbors(Conditional condition)
Returns the number of cells that are neighbors and that meet the supplied condition.
Parameters:
condition - the condition that found cell must meet

hasWithin

public boolean hasWithin(Conditional condition,
                         boolean includeOrigin,
                         double maximumDistance)
Returns true of there is a cell within the supplied distance that meets the supplied condition.
Parameters:
condition - the condition that found cell must meet
includeOrigin - should this cell be included in the search
maximumDistance - the distance to search within

countWithin

public int countWithin(Conditional condition,
                       boolean includeOrigin,
                       double maximumDistance)
Returns the number of cells within the supplied distance that meet the supplied condition.
Parameters:
condition - the condition that found cell must meet
includeOrigin - should this cell be included in the count
maximumDistance - the distance to search within

getDistance

public int getDistance(Cell target)

setNeighbors

public void setNeighbors(Cell[] neighbors)
Sets this cell's neighbors. Used by agent scape intialize methods to inform the cell of it's neighbors. When creating new lattice classes, be sure to set all cell's neighbors using this method. Note that this method could also be used for creating dynamic spaces!
Parameters:
neighbors - the array of neighbors to set

findRandomNeighbor

public Cell findRandomNeighbor()
Returns a cell randomly selected from among this cell's neighbors.

getOccupant

public CellOccupant getOccupant()
Returns any occupants of this cell. Cell occupants are incapable of hosting agents, so this will always be null for instantiations of this class.

getNetwork

public Cell[] getNetwork()
Returns some network of related cells. The network itself is implementation specific.

setNetwork

public void setNetwork(Cell[] network)
Sets a network of related cells.

isAvailable

public boolean isAvailable()
Is this cell available for occupation? Again, this will always return false because base cells can not host agents.

setOccupant

public void setOccupant(CellOccupant occupant)
Sets this cell's occupant. Produces an error, because base cells can not host agents.

removeOccupant

public void removeOccupant()
Removes this cell's occupant. Produces an error, because base cells can not host agents.

requestUpdate

public void requestUpdate()
Indicate to all views of this cell that an update is needed. Should be called whenever the cell state has changed in a way that might affect how it is drawn.

requestUpdateNext

public void requestUpdateNext()
Indicate to all views of this cell that an update is needed next iteration. Called when a paint action in the current iteration might need cleanup in the next cycle.

isUpdateNeeded

public boolean isUpdateNeeded(int within)
Has a view update been requested for this cell?

clone

public java.lang.Object clone()
Clones the host cell, making coordinate null.
Overrides:
clone in class Agent

toString

public java.lang.String toString()
A string representation of this cell.
Overrides:
toString in class Agent

(c) 1998-2000 The Brookings Insitution
Webpage