|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.space.Object2DGrid
public class Object2DGrid
A discrete 2 dimensional grid of objects, accessed by x and y coordinates.
| Field Summary | |
|---|---|
protected NewMatrix |
matrix
|
protected Neighborhooder |
Mneigh
|
static int |
PGM_ASCII
|
static int |
RASTER_ASCII
|
protected Neighborhooder |
VNneigh
|
protected int |
xSize
|
protected int |
ySize
|
| Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace |
|---|
MOORE, VON_NEUMANN |
| Constructor Summary | |
|---|---|
Object2DGrid(java.io.InputStream stream,
int type)
Constructs a grid from an InputStream. |
|
Object2DGrid(int xSize,
int ySize)
Constructs a grid with the specified size. |
|
Object2DGrid(java.lang.String fileName,
int type)
Constructs a grid from a file. |
|
| Method Summary | |
|---|---|
java.util.Vector |
findMaximum(int x,
int y,
int range,
boolean includeOrigin,
int neighborhoodType)
Finds the maximum grid cell occupant within a specified range from the specified origin coordinate. |
java.util.Vector |
findMinimum(int x,
int y,
int range,
boolean includeOrigin,
int neighborhoodType)
Finds the minimum grid cell occupant within a specified range from the specified origin coordinate. |
BaseMatrix |
getMatrix()
Returns the matrix collection object associated with this 2d grid |
java.util.Vector |
getMooreNeighbors(int x,
int y,
boolean returnNulls)
Gets the Moore neighbors of the object at x, y. |
java.util.Vector |
getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
Gets the extended Moore neighbors of the object at x, y. |
java.lang.Object |
getObjectAt(int x,
int y)
Gets the object at (x,y) |
java.awt.Dimension |
getSize()
Gets the size as a Dimension. |
int |
getSizeX()
Gets the size of the x dimension. |
int |
getSizeY()
Gets the size of the y dimension. |
double |
getValueAt(int x,
int y)
Gets the double value at (x,y) if possible |
java.util.Vector |
getVonNeumannNeighbors(int x,
int y,
boolean returnNulls)
Gets the von Neumann neighbors of the object at x, y. |
java.util.Vector |
getVonNeumannNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
Gets the extended von Neumann neighbors of the object at x, y. |
void |
putObjectAt(int x,
int y,
java.lang.Object object)
Puts the specified object at (x,y) |
void |
putValueAt(int x,
int y,
double value)
Puts the specified double at (x,y) |
protected void |
rangeCheck(int x,
int y)
|
void |
setComparator(java.util.Comparator comparator)
Sets the comparator class used by the findMaximum and findMinimum methods. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PGM_ASCII
public static final int RASTER_ASCII
protected NewMatrix matrix
protected int xSize
protected int ySize
protected Neighborhooder VNneigh
protected Neighborhooder Mneigh
| Constructor Detail |
|---|
public Object2DGrid(int xSize,
int ySize)
xSize - the size of the lattice in the x dimension.ySize - the size of the lattice in the y dimension.
public Object2DGrid(java.io.InputStream stream,
int type)
public Object2DGrid(java.lang.String fileName,
int type)
| Method Detail |
|---|
public java.util.Vector getVonNeumannNeighbors(int x,
int y,
boolean returnNulls)
x - the x coordinate of the objecty - the y coordinate of the objectreturnNulls - whether nulls (nothing at x,y) should be returned
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.Vector getVonNeumannNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y directionreturnNulls - whether nulls should be returned
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.Vector getMooreNeighbors(int x,
int y,
boolean returnNulls)
x - the x coordinate of the objecty - the y coordinate of the objectreturnNulls - should the returned Vector contain null objects
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.Vector getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent,
boolean returnNulls)
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y directionreturnNulls - should the returned Vector contain null objects
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)public void setComparator(java.util.Comparator comparator)
comparator - the comparator to use for finding maximum and minimum.
public java.util.Vector findMaximum(int x,
int y,
int range,
boolean includeOrigin,
int neighborhoodType)
x - the x origin coordinatey - the y origin coordinaterange - the range out from the coordinate to searchincludeOrigin - include object at origin in searchneighborhoodType - the type of neighborhood to search. Can be one
of Discrete2DSpace.VON_NEUMANN or Discrete2DSpace.MOORE.
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public java.util.Vector findMinimum(int x,
int y,
int range,
boolean includeOrigin,
int neighborhoodType)
x - the x origin coordinatey - the y origin coordinaterange - the range out from the coordinate to searchincludeOrigin - include object at origin in searchneighborhoodType - the type of neighborhood to search. Can be one
of Discrete2DSpace.VON_NEUMANN or Discrete2DSpace.MOORE.
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
protected void rangeCheck(int x,
int y)
public int getSizeX()
getSizeX in interface Discrete2DSpacepublic int getSizeY()
getSizeY in interface Discrete2DSpacepublic java.awt.Dimension getSize()
getSize in interface Discrete2DSpace
public java.lang.Object getObjectAt(int x,
int y)
getObjectAt in interface Discrete2DSpacex - the x coordinatey - the y coordinate
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public double getValueAt(int x,
int y)
getValueAt in interface Discrete2DSpacex - the x coordinatey - the y coordinate
java.lang.IllegalArgumentException - if object at x,y cannot
be converted to a number.
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public void putObjectAt(int x,
int y,
java.lang.Object object)
putObjectAt in interface Discrete2DSpacex - the x coordinatey - the y coordinateobject - the object to put at (x,y)
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)
public void putValueAt(int x,
int y,
double value)
putValueAt in interface Discrete2DSpacex - the x coordinatey - the y coordinatevalue - the double to put at (x,y)
java.lang.IndexOutOfBoundsException - if the given coordinates are out of
range (x < 0 || x >= xSize || y < 0 || y >= ySize)public BaseMatrix getMatrix()
getMatrix in interface Discrete2DSpace
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||