uchicago.src.sim.space
Class AbsMulti2DHexagonalTorus

java.lang.Object
  extended by uchicago.src.sim.space.AbsMulti2DGrid
      extended by uchicago.src.sim.space.AbsMulti2DTorus
          extended by uchicago.src.sim.space.AbsMulti2DHexagonalTorus
All Implemented Interfaces:
Discrete2DSpace, IMulti2DGrid, Torus
Direct Known Subclasses:
Multi2DHexagonalTorus, OrderedMulti2DHexagonalTorus

public abstract class AbsMulti2DHexagonalTorus
extends AbsMulti2DTorus

Base class for hexagonal torii whose cells can hold more that one occupant. The actual object held in the grid cell is a Cell object.

The hexagonal cells are referenced by x, y coordinates as follows:

       _
   _ / 1 \ _
 / 0 \ _ / 2 \
 \ _ / 4 \ _ /
 / 3 \ _ / 5 \
 \ _ / 7 \ _ /
 / 6 \ _ / 8 \
 \ _ /   \ _ /

 
Here we have a 3 x 3 hexagonal grid. The first row of cells is 0, 1, 2 such that 0,0 refers to cell 0, and 0,2 refers to cell 2. The next row of cells is 3, 4, 5, so 1,0 refers to cell 3 and so on. The last row of cells is 6, 7, and 8, so 2, 0 refers to cell 6. The ring of neighbors with radius one that surrounds cell 4 is composed of 1, 2, 5, 7, 3, and 0. The grid wraps as a toriod such that cell -1, 0 refers to cell 2 and cell 0, -1 is cell 6.

Version:
$Revision $ $Date: 2004/11/03 19:50:58 $

Field Summary
 
Fields inherited from class uchicago.src.sim.space.AbsMulti2DGrid
matrix, roIter, roList, xSize, ySize
 
Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace
MOORE, VON_NEUMANN
 
Constructor Summary
AbsMulti2DHexagonalTorus(int xSize, int ySize, boolean sparse)
          Creates this AbsMulti2DHexagonalGrid with the specified dimensions.
 
Method Summary
 java.util.ArrayList getMooreNeighbors(int x, int y, boolean returnNulls)
          The notion of Moore neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getMooreNeighbors(int x, int y, int xExtent, int yExtent, boolean returnNulls)
          The notion of Moore neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getMooreNeighborsLoc(int x, int y, boolean returnNulls)
          The notion of Moore neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getMooreNeighborsLoc(int x, int y, int xExtent, int yExtent, boolean returnNulls)
          The notion of Moore neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getNeighbors(int x, int y, boolean returnNulls)
          Returns the ring of neighbors with a radius of 1 surrounding the object at x, y.
 java.util.ArrayList getNeighbors(int x, int y, int extent, boolean returnNulls)
          Returns the rings of neighbors surrounding the cell at x, y.
 java.util.ArrayList getNeighborsLoc(int x, int y, boolean returnNulls)
          Returns the ring of neighbors with a radius of 1 surrounding the object at x, y.
 java.util.ArrayList getNeighborsLoc(int x, int y, int extent, boolean returnNulls)
          Returns the rings of neighbors surrounding the cell at x, y.
 java.util.ArrayList getVNNeighbors(int x, int y, boolean returnNulls)
          The notion of VonNeumann neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getVNNeighbors(int x, int y, int xExtent, int yExtent, boolean returnNulls)
          The notion of VonNeumann neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getVNNeighborsLoc(int x, int y, boolean returnNulls)
          The notion of VonNeumann neighbors is incoherent on a Hexagonal grid.
 java.util.ArrayList getVNNeighborsLoc(int x, int y, int xExtent, int yExtent, boolean returnNulls)
          The notion of VonNeumann neighbors is incoherent on a Hexagonal grid.
 
Methods inherited from class uchicago.src.sim.space.AbsMulti2DTorus
clear, getCellAt, getCellSizeAt, getIteratorAt, getMatrix, getObjectAt, getObjectsAt, getValueAt, putObjectAt, putValueAt, removeObjectAt, trim, xnorm, ynorm
 
Methods inherited from class uchicago.src.sim.space.AbsMulti2DGrid
getSize, getSizeX, getSizeY, rangeCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbsMulti2DHexagonalTorus

public AbsMulti2DHexagonalTorus(int xSize,
                                int ySize,
                                boolean sparse)
Creates this AbsMulti2DHexagonalGrid with the specified dimensions. sparse specifies whether the grid will be sparsely filled or not. Specifying sparse can result in substantial memory savings.

Parameters:
xSize - the number of columns in the grid
ySize - the number of rows in the grid
sparse - whether the grid will be sparsely populated or not
Method Detail

getNeighbors

public java.util.ArrayList getNeighbors(int x,
                                        int y,
                                        int extent,
                                        boolean returnNulls)
Returns the rings of neighbors surrounding the cell at x, y. The number of rings is specified by the extent parameter.

Parameters:
x - the x coordinate of the cell
y - the y coordinate of the cell
extent - the number of neighbor rings to return
returnNulls - whether or not the returned list should return null when a neighbor cell is empty
Returns:
an ArrayList of Objexts beginning with the outermost ring of neighbors, starting with the north or "12 o'clock" neighboring cell, continuing clockwise and spiraling inwards

getNeighbors

public java.util.ArrayList getNeighbors(int x,
                                        int y,
                                        boolean returnNulls)
Returns the ring of neighbors with a radius of 1 surrounding the object at x, y.

Parameters:
x - the x coordinate of the cell
y - the y coordinate of the cell
returnNulls - whether or not the returned list should return null when a neighbor cell is empty
Returns:
an ArrayList of Objects in clockwise order starting with the north or "12 o'clock" neighboring cell

getNeighborsLoc

public java.util.ArrayList getNeighborsLoc(int x,
                                           int y,
                                           int extent,
                                           boolean returnNulls)
Returns the rings of neighbors surrounding the cell at x, y. The number of rings is specified by the extent parameter.

Parameters:
x - the x coordinate of the cell
y - the y coordinate of the cell
extent - the number of neighbor rings to return
returnNulls - whether or not the returned list should return null when a neighbor cell is empty
Returns:
an ArrayList of ObjectLocations beginning with the outermost ring of neighbors, starting with the north or "12 o'clock" neighboring cell, continuing clockwise and spiraling inwards

getNeighborsLoc

public java.util.ArrayList getNeighborsLoc(int x,
                                           int y,
                                           boolean returnNulls)
Returns the ring of neighbors with a radius of 1 surrounding the object at x, y.

Parameters:
x - the x coordinate of the cell
y - the y coordinate of the cell
returnNulls - whether or not the returned list should return null when a neighbor cell is empty
Returns:
an ArrayList of ObjectLocation-s in clockwise order starting with the north or "12 o'clock" neighboring cell

getVNNeighborsLoc

public java.util.ArrayList getVNNeighborsLoc(int x,
                                             int y,
                                             boolean returnNulls)
The notion of VonNeumann neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the * getNeighborsLoc method.

Overrides:
getVNNeighborsLoc in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
returnNulls - whether nulls (nothing at x,y) should be returned
Returns:
an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
Throws:
java.lang.UnsupportedOperationException - when called.
See Also:
ObjectLocation

getVNNeighborsLoc

public java.util.ArrayList getVNNeighborsLoc(int x,
                                             int y,
                                             int xExtent,
                                             int yExtent,
                                             boolean returnNulls)
The notion of VonNeumann neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the getNeighborsLoc method.

Overrides:
getVNNeighborsLoc in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
xExtent - the extension of the neighborhood in the x direction
yExtent - the extension of the neighborhood in the y direction
returnNulls - whether nulls should be returned
Returns:
an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
Throws:
java.lang.UnsupportedOperationException - when called.
See Also:
ObjectLocation

getMooreNeighborsLoc

public java.util.ArrayList getMooreNeighborsLoc(int x,
                                                int y,
                                                boolean returnNulls)
The notion of Moore neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the getNeighborsLoc method.

Overrides:
getMooreNeighborsLoc in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
returnNulls - should the returned Vector contain null objects
Returns:
an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
Throws:
java.lang.UnsupportedOperationException - when called.
See Also:
ObjectLocation

getMooreNeighborsLoc

public java.util.ArrayList getMooreNeighborsLoc(int x,
                                                int y,
                                                int xExtent,
                                                int yExtent,
                                                boolean returnNulls)
The notion of Moore neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the getNeighborsLoc method.

Overrides:
getMooreNeighborsLoc in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
xExtent - the extension of the neighborhood in the x direction
yExtent - the extension of the neighborhood in the y direction
returnNulls - should the returned ArrayList contain null objects
Returns:
an ArrayList of ObjectLocation objects. The object contained by the ObjectLocation object may be null.
Throws:
java.lang.UnsupportedOperationException - when called.
See Also:
ObjectLocation

getVNNeighbors

public java.util.ArrayList getVNNeighbors(int x,
                                          int y,
                                          boolean returnNulls)
The notion of VonNeumann neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the #getNeighborsint, int, int, boolean) getNeighbors method.

Overrides:
getVNNeighbors in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
returnNulls - whether nulls (nothing at x,y) should be returned
Returns:
an ArrayList of objects (and possibly nulls).
Throws:
java.lang.UnsupportedOperationException - when called.

getVNNeighbors

public java.util.ArrayList getVNNeighbors(int x,
                                          int y,
                                          int xExtent,
                                          int yExtent,
                                          boolean returnNulls)
The notion of VonNeumann neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the #getNeighborsint, int, int, boolean) getNeighbors method.

Overrides:
getVNNeighbors in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
xExtent - the extension of the neighborhood in the x direction
yExtent - the extension of the neighborhood in the y direction
returnNulls - whether nulls should be returned
Returns:
an ArrayList of objects (and possibly nulls).
Throws:
java.lang.UnsupportedOperationException - when called.

getMooreNeighbors

public java.util.ArrayList getMooreNeighbors(int x,
                                             int y,
                                             boolean returnNulls)
The notion of Moore neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the #getNeighborsint, int, int, boolean) getNeighbors method.

Overrides:
getMooreNeighbors in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
returnNulls - should the returned ArrayList contain null objects
Returns:
an ArrayList of objects (and possibly nulls) ordered by row starting with the "NW corner" and ending with the "SE corner."
Throws:
java.lang.UnsupportedOperationException - when called.

getMooreNeighbors

public java.util.ArrayList getMooreNeighbors(int x,
                                             int y,
                                             int xExtent,
                                             int yExtent,
                                             boolean returnNulls)
The notion of Moore neighbors is incoherent on a Hexagonal grid. Consequently, this method throws an UnsupportedOperationException. To get the neighbors in a hexagonal grid, use the #getNeighborsint, int, int, boolean) getNeighbors method.

Overrides:
getMooreNeighbors in class AbsMulti2DTorus
Parameters:
x - the x coordinate of the object
y - the y coordinate of the object
xExtent - the extension of the neighborhood in the x direction
yExtent - the extension of the neighborhood in the y direction
returnNulls - should the returned ArrayList contain null objects
Returns:
an ArrayList of objects (and possibly nulls) ordered by row starting with the "NW corner" and ending with the "SE corner."
Throws:
java.lang.UnsupportedOperationException - when called.
See Also:
ObjectLocation