uchicago.src.sim.topology.space.d2
Class AbstractObject2DSpace

java.lang.Object
  extended byuchicago.src.sim.topology.space.d2.AbstractObject2DTopology
      extended byuchicago.src.sim.topology.space.d2.AbstractObject2DSpace
All Implemented Interfaces:
ModifyableTopology, Object2DSpace, RelationTopology, Space
Direct Known Subclasses:
Multi2DGrid, Object2DGrid

public abstract class AbstractObject2DSpace
extends AbstractObject2DTopology
implements Object2DSpace

Base class for grids whose cells can hold one or more occupants. The actual object held in the grid cell is a Object2DLocation object.

Version:
$Revision: 1.4 $ $Date: 2004/11/03 19:51:05 $

Nested Class Summary
 class AbstractObject2DSpace.Abstract2DLocation
          A data structure holding an object and the x and y coordinates of that object.
 
Field Summary
protected  BaseMatrix matrix
           
 
Fields inherited from class uchicago.src.sim.topology.space.d2.AbstractObject2DTopology
locations
 
Constructor Summary
AbstractObject2DSpace(java.lang.String type)
           
 
Method Summary
abstract  Location getLocation(int x, int y)
          Gets the Object2DLocation object at the specified coordinates.
 Location getLocation(java.lang.Object obj)
          Attempts to get the Location for a specific object.
 BaseMatrix getMatrix()
          Returns the matrix collection object associated with this 2d grid
 double[] getSize()
          Gets the dimension of the space
 int getSizeX()
           
 int getSizeY()
           
 void removeLocation(int x, int y)
          Clears the contents the specified cell.
 void removeLocation(Location location)
          Clears the contents the specified location.
 void trim()
          Releases any superfluous memory.
 int xnorm(int x)
           
 int ynorm(int y)
           
 
Methods inherited from class uchicago.src.sim.topology.space.d2.AbstractObject2DTopology
addRelation, distance, getRelations, getRelations, getRelationType, removeRelation, setRelationType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matrix

protected BaseMatrix matrix
Constructor Detail

AbstractObject2DSpace

public AbstractObject2DSpace(java.lang.String type)
Method Detail

removeLocation

public void removeLocation(Location location)
Clears the contents the specified location.

Specified by:
removeLocation in interface Space
Parameters:
location - the location to remove from the space

removeLocation

public void removeLocation(int x,
                           int y)
Clears the contents the specified cell.

Specified by:
removeLocation in interface Object2DSpace
Parameters:
x - the x coordinate of the cell to clear
y - the y coordinate of the cell to clear

getLocation

public abstract Location getLocation(int x,
                                     int y)
Gets the Object2DLocation object at the specified coordinates.

Specified by:
getLocation in interface Object2DSpace
Parameters:
x - the x coordinate
y - the y coordinate
Throws:
java.lang.IndexOutOfBoundsException - if the given coordinates are out of range (x < 0 || x >= xSize || y < 0 || y >= ySize)

getLocation

public Location getLocation(java.lang.Object obj)
Description copied from interface: Space
Attempts to get the Location for a specific object.

Specified by:
getLocation in interface Space

getMatrix

public BaseMatrix getMatrix()
Returns the matrix collection object associated with this 2d grid


getSize

public double[] getSize()
Description copied from interface: Space
Gets the dimension of the space

Specified by:
getSize in interface Space

getSizeX

public int getSizeX()
Specified by:
getSizeX in interface Object2DSpace

getSizeY

public int getSizeY()
Specified by:
getSizeY in interface Object2DSpace

trim

public void trim()
Releases any superfluous memory. This is only usefull when working with sparse grids.

Specified by:
trim in interface Object2DSpace

xnorm

public int xnorm(int x)
Specified by:
xnorm in interface Object2DSpace

ynorm

public int ynorm(int y)
Specified by:
ynorm in interface Object2DSpace