uchicago.src.sim.space
Class Object2DTorus

java.lang.Object
  extended by uchicago.src.sim.space.Object2DGrid
      extended by uchicago.src.sim.space.Object2DTorus
All Implemented Interfaces:
Discrete2DSpace, Torus

public class Object2DTorus
extends Object2DGrid
implements Torus

A discrete 2 dimensional torus of objects, accessed by x and y coordinates.

Version:
$Revision: 1.7 $ $Date: 2004/11/03 19:50:58 $
Author:
Nick Collier

Field Summary
 
Fields inherited from class uchicago.src.sim.space.Object2DGrid
matrix, Mneigh, PGM_ASCII, RASTER_ASCII, VNneigh, xSize, ySize
 
Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace
MOORE, VON_NEUMANN
 
Constructor Summary
Object2DTorus(java.io.InputStream stream, int type)
          Creates a new torus from the specified InputStream.
Object2DTorus(int xSize, int ySize)
          Creates a new torus of the specified size.
Object2DTorus(java.lang.String fileName, int type)
          Creates a new torus from the specified file.
 
Method Summary
 java.lang.Object getObjectAt(int x, int y)
          Gets the object at the specified coordinate
 double getValueAt(int x, int y)
          Gets the value at (x,y)
 void putObjectAt(int x, int y, java.lang.Object object)
          Puts the specified object at (x,y), wrapping the coordinates around the torus if necessary.
 void putValueAt(int x, int y, double value)
          Puts the specified double at (x,y), wrapping the coordinates around the torus if necessary.
 int xnorm(int x)
          Normalize the x value to the toroidal coordinates
 int ynorm(int y)
          Normalize the y value to the toroidal coordinates
 
Methods inherited from class uchicago.src.sim.space.Object2DGrid
findMaximum, findMinimum, getMatrix, getMooreNeighbors, getMooreNeighbors, getSize, getSizeX, getSizeY, getVonNeumannNeighbors, getVonNeumannNeighbors, rangeCheck, setComparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Object2DTorus

public Object2DTorus(int xSize,
                     int ySize)
Creates a new torus of the specified size.

Parameters:
xSize - the size of the x dimension
ySize - the size of the y dimension

Object2DTorus

public Object2DTorus(java.lang.String fileName,
                     int type)
Creates a new torus from the specified file.

Parameters:
fileName - the name of the file to create the torus from
type - the type of the file
See Also:
Object2DGrid

Object2DTorus

public Object2DTorus(java.io.InputStream stream,
                     int type)
Creates a new torus from the specified InputStream.

Parameters:
stream - the InputStream to create the torus from.
type - the type of the file
See Also:
Object2DGrid
Method Detail

putObjectAt

public void putObjectAt(int x,
                        int y,
                        java.lang.Object object)
Puts the specified object at (x,y), wrapping the coordinates around the torus if necessary.

Specified by:
putObjectAt in interface Discrete2DSpace
Overrides:
putObjectAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
object - the object to put at (x,y)

putValueAt

public void putValueAt(int x,
                       int y,
                       double value)
Puts the specified double at (x,y), wrapping the coordinates around the torus if necessary.

Specified by:
putValueAt in interface Discrete2DSpace
Overrides:
putValueAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
value - the value to put at (x,y)

getObjectAt

public java.lang.Object getObjectAt(int x,
                                    int y)
Gets the object at the specified coordinate

Specified by:
getObjectAt in interface Discrete2DSpace
Overrides:
getObjectAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the object at x, y

getValueAt

public double getValueAt(int x,
                         int y)
Gets the value at (x,y)

Specified by:
getValueAt in interface Discrete2DSpace
Overrides:
getValueAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the value at x, y

xnorm

public int xnorm(int x)
Normalize the x value to the toroidal coordinates

Parameters:
x - the value to normalize
Returns:
the normalized value

ynorm

public int ynorm(int y)
Normalize the y value to the toroidal coordinates

Parameters:
y - the value to normalize
Returns:
the normalized value