public interface Grid<T> extends Projection<T>
Modifier and Type  Method and Description 

GridAdder<T> 
getAdder()
Gets the adder used by this space to add new objects.

CellAccessor 
getCellAccessor()
Gets the cell accessor used to control access to individual
grid cells.

GridDimensions 
getDimensions()
Gets the dimensions of the space.

double 
getDistance(GridPoint point1,
GridPoint point2)
Returns the distance between the GridPoints point1 and point2,
taking into account the space's topology.

double 
getDistanceSq(GridPoint point1,
GridPoint point2)
Returns the square of the distance between the GridPoints point1 and point2,
taking into account the space's topology.

GridPointTranslator 
getGridPointTranslator()
Retrieves the rule being used for controlling what happens at or beyond
the borders of the space.

GridPoint 
getLocation(java.lang.Object obj)
Gets the location of the specified object.

T 
getObjectAt(int... location)
Gets the object at the specified location.

java.lang.Iterable<T> 
getObjects()
Gets all the object currently in the space.

java.lang.Iterable<T> 
getObjectsAt(int... location)
Gets all the objects at the specified location.

T 
getRandomObjectAt(int... location)
Gets a random object from among those at the specified location.

boolean 
isPeriodic()
True if this grid is peri0dic (in the sense that moving off one border
makes you appear on the other one), otherwise false.

GridPoint 
moveByDisplacement(T object,
int... displacement)
Moves the specified object from its current location by the specified
amount.

GridPoint 
moveByVector(T object,
double distance,
double... anglesInRadians)
Moves the specified object the specified distance from its current
position along the specified angle.

boolean 
moveTo(T object,
int... newLocation)
Moves the specified object from its current location to the new location.

void 
setAdder(GridAdder<T> adder)
Sets the adder used by this space to add new objects.

void 
setGridPointTranslator(GridPointTranslator rule)
Sets the rule to use for controlling what happens at or beyond the
borders of the space.

int 
size()
Gets the number of objects currently in the space.

addProjectionListener, evaluate, getName, getProjectionListeners, removeProjectionListener
GridDimensions getDimensions()
void setAdder(GridAdder<T> adder)
adder
 the adderGridAdder<T> getAdder()
boolean moveTo(T object, int... newLocation)
object
 newLocation
 SpatialException
 if the object is not already in the space, if the number of
dimensions in the location does not agree with the number in
the space, or if the object is moved outside the grid
dimensions.GridPoint getLocation(java.lang.Object obj)
obj
 int size()
GridPointTranslator getGridPointTranslator()
CellAccessor getCellAccessor()
void setGridPointTranslator(GridPointTranslator rule)
rule
 the rule for handling out of bounds coordinatesjava.lang.Iterable<T> getObjects()
T getObjectAt(int... location)
location
 java.lang.Iterable<T> getObjectsAt(int... location)
location
 T getRandomObjectAt(int... location)
location
 GridPoint moveByDisplacement(T object, int... displacement)
moveByDisplacement(object, 3, 2, 1)
will move the object by 3 along the xaxis, 2 along the y and 1 along
the z. The displacement argument can be less than the number of
dimensions in the space in which case the remaining argument will be set
to 0. For example, moveByDisplacement(object, 3)
will move
the object 3 along the xaxis and 0 along the y and z axes, assuming a 3D
grid.object
 the object to movedisplacement
 the amount to move the objectSpatialException
 if the object is not already in the space or if the number of
dimensions in the displacement greater than the number of
grid dimensions.GridPoint moveByVector(T object, double distance, double... anglesInRadians)
moveByVector(object, 1, Direction.NORTH)
will move the
object 1 unit "north" up the yaxis, assuming a 2D grid. Similarly,
grid.moveByVector(object, 2, 0, Math.toRadians(90), 0)
will rotate 90 degrees around the yaxis, thus moving the object 2 units
along the zaxis.
Note that the radians / degrees are incremented in a anticlockwise
fashion, such that 0 degrees is "east", 90 degrees is "north", 180 is
"west" and 270 is "south."object
 the object to movedistance
 the distance to moveanglesInRadians
 the angle to move along in radians. Note that
Math.toRadians(degrees) is useful hereSpatialException
 if the object is not already in the space or if the number of
angles is greater than the number of dimensionsDirection.EAST
,
Direction.NORTH
,
Direction.SOUTH
,
Direction.WEST
boolean isPeriodic()
double getDistance(GridPoint point1, GridPoint point2)
point1
 the first pointpoint2
 the second pointdouble getDistanceSq(GridPoint point1, GridPoint point2)
point1
 the first pointpoint2
 the second point