edu.brook.ascape.model
Class Geometry

java.lang.Object
  |
  +--edu.brook.ascape.model.Geometry

public class Geometry
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

An encapsulation of all of the potential space definitions for any scape of agents, and a factory for creating realizations of these scapes. At the moment, only one-dimensional and two-dimensional spaces are represented, but this class should eventually suport n-dimensional spaces, non-discrete spaces, and complex graphs. Users of this class are encouraged to use the static definitions whenever possible.

Since:
1.0
Version:
1.0
See Also:
Serialized Form

Field Summary
static Geometry APERIODIC_1D
          The one-dimensional, aperiodic geometry, of fixed size and with discrete coordinates.
static Geometry APERIODIC_2D_EUCLIDIAN
          The two-dimensional, aperiodic geometry, of fixed size and with discrete coordinates.
static Geometry APERIODIC_2D_MOORE
          The two-dimensional, aperiodic geometry, of fixed size and with discrete coordinates.
static Geometry APERIODIC_2D_VON_NEUMANN
          The two-dimensional, aperiodic geometry, of fixed size and with discrete coordinates.
static Geometry APERIODIC_3D
          The three-dimensional, aperiodic geometry, of fixed size and with discrete coordinates.
static Geometry APERIODIC_VARIABLESIZED_1D
          The one-dimensional, aperiodic geometry, of variable size and with discrete coordinates.
 int dimensionCount
          If appropriate.
 boolean discrete
          Does this geometry represent space as a set of discrete locations, or do all objects within it have a some aproximate location within continous space? For example, raster graphics would represent a discrete space, while vector graphics would represent a non-discrete space.
static int EUCLIDIAN
          In a Euclidian neighborhood, cells are considered neighbors if they meet the target at any point: OOO OXO OOO This is just an Ascape convention, but you probably shouldn't be concerned with neighbors in a Euclidian model anyway.
 boolean fixedSize
          Is this geometry of fixed extent, as in an array or a closed space, or can it shrink and grow like a vector or open space?
static int MOORE
          In a Moore neighborhood, cells are considered neighbors if they meet the target at any point: OOO OXO OOO
protected  int neighborhood
          The neighborhood (Moore or von Neumann) assumed for this lattice.
static int NOT_APPLICABLE
          Neighborhood not applicable
 boolean periodic
          If appropriate.
static Geometry PERIODIC_1D
          The one-dimensional, periodic geometry, of fixed size and with discrete coordinates.
static Geometry PERIODIC_2D_EUCLIDIAN
          The two-dimensional, periodic geometry, of fixed size and with discrete coordinates.
static Geometry PERIODIC_2D_MOORE
          The two-dimensional, periodic geometry, of fixed size and with discrete coordinates.
static Geometry PERIODIC_2D_VON_NEUMANN
          The two-dimensional, periodic geometry, of fixed size and with discrete coordinates.
static Geometry STRETCHY_1D
          The one-dimensional, aperiodic geometry, of fixed size and with discrete coordinates.
static int VON_NEUMANN
          In a von Neumann neighborhood, cells are considered neighbors if they share an edge with the target: O OXO O
 
Constructor Summary
Geometry(int dimensionCount)
          Creates a closed, discreet, Geometry.
Geometry(int dimensionCount, boolean periodic, boolean fixedSize, boolean discrete, int neighborhood)
          Constructs a new geometry with the appropriate specifications.
 
Method Summary
 java.lang.Object clone()
          Clones the geometry.
 int getDimensionCount()
          Returns the number of dimensions for this lattice.
 int getNeighborhood()
          Returns the geometry's presumed neighborhood.
 boolean isDiscrete()
          Is the geometry dicrete or continous?
 boolean isPeriodic()
          Is the geometry periodic or aperiodic? (Do edges wrap to opposite side or not?)
 Scape newScape()
          Creates an agent scape matching this geometry's specifications.
 Scape newScape(Agent prototypeAgent)
          Creates an agent scape matching this geometry's specifications.
 Scape newScape(Agent prototypeAgent, Coordinate extent)
          Creates an agent scape matching this geometry's specifications.
 Scape newScape(java.lang.String agentClassName)
          Creates an agent scape matching this geometry's specifications.
 void setDimensionCount(int dimensionCount)
          Sets the number of dimensions for this lattice.
 void setDiscrete(boolean discrete)
          Sets the geometry to discrete or continous.
 void setNeighborhood(int symbol)
          Set the neighborhood to use for calculations within this geometry.
 void setPeriodic(boolean periodic)
          Sets the geometry to periodic or aperiodic.
 java.lang.String toString()
          A string representation of this geometry
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

periodic

public boolean periodic
If appropriate. If the geometry is periodic, the edges of the space are connected; for example, a 1D periodic lattice is a ring, and a periodic 2D lattice is a torus, wheras a 1D aperiodic lattice is a line segment, and an aperiodic 2D lattice is a plane.

fixedSize

public boolean fixedSize
Is this geometry of fixed extent, as in an array or a closed space, or can it shrink and grow like a vector or open space?

discrete

public boolean discrete
Does this geometry represent space as a set of discrete locations, or do all objects within it have a some aproximate location within continous space? For example, raster graphics would represent a discrete space, while vector graphics would represent a non-discrete space.

dimensionCount

public int dimensionCount
If appropriate. How many dimensions does this space have?

MOORE

public static final int MOORE
In a Moore neighborhood, cells are considered neighbors if they meet the target at any point:
                                      OOO
                                      OXO
                                      OOO  

VON_NEUMANN

public static final int VON_NEUMANN
In a von Neumann neighborhood, cells are considered neighbors if they share an edge with the target:
                                       O
                                      OXO
                                       O   

EUCLIDIAN

public static final int EUCLIDIAN
In a Euclidian neighborhood, cells are considered neighbors if they meet the target at any point:
                                      OOO
                                      OXO
                                      OOO  
This is just an Ascape convention, but you probably shouldn't be concerned with neighbors in a Euclidian model anyway. Instead, you will want to use distances, so that distance 1 = immeadiate vN distance, and >= Sqrt(2) = immeadiate Moore distance.

NOT_APPLICABLE

public static final int NOT_APPLICABLE
Neighborhood not applicable

neighborhood

protected int neighborhood
The neighborhood (Moore or von Neumann) assumed for this lattice. This is generally only an appropriate distinction in 2D space. (Check this!)

PERIODIC_1D

public static final Geometry PERIODIC_1D
The one-dimensional, periodic geometry, of fixed size and with discrete coordinates. (Circumfrence of a circle.)

APERIODIC_1D

public static final Geometry APERIODIC_1D
The one-dimensional, aperiodic geometry, of fixed size and with discrete coordinates. (Line segment.)

STRETCHY_1D

public static final Geometry STRETCHY_1D
The one-dimensional, aperiodic geometry, of fixed size and with discrete coordinates. (Line segment.)

APERIODIC_VARIABLESIZED_1D

public static final Geometry APERIODIC_VARIABLESIZED_1D
The one-dimensional, aperiodic geometry, of variable size and with discrete coordinates. (Ray.)

PERIODIC_2D_MOORE

public static final Geometry PERIODIC_2D_MOORE
The two-dimensional, periodic geometry, of fixed size and with discrete coordinates. (Tourus.)

PERIODIC_2D_VON_NEUMANN

public static final Geometry PERIODIC_2D_VON_NEUMANN
The two-dimensional, periodic geometry, of fixed size and with discrete coordinates. (Tourus.)

PERIODIC_2D_EUCLIDIAN

public static final Geometry PERIODIC_2D_EUCLIDIAN
The two-dimensional, periodic geometry, of fixed size and with discrete coordinates. (Tourus.)

APERIODIC_2D_MOORE

public static final Geometry APERIODIC_2D_MOORE
The two-dimensional, aperiodic geometry, of fixed size and with discrete coordinates. (Area.)

APERIODIC_2D_VON_NEUMANN

public static final Geometry APERIODIC_2D_VON_NEUMANN
The two-dimensional, aperiodic geometry, of fixed size and with discrete coordinates. (Area.)

APERIODIC_2D_EUCLIDIAN

public static final Geometry APERIODIC_2D_EUCLIDIAN
The two-dimensional, aperiodic geometry, of fixed size and with discrete coordinates. (Area.)

APERIODIC_3D

public static final Geometry APERIODIC_3D
The three-dimensional, aperiodic geometry, of fixed size and with discrete coordinates. (Region of space.)
Constructor Detail

Geometry

public Geometry(int dimensionCount,
                boolean periodic,
                boolean fixedSize,
                boolean discrete,
                int neighborhood)
Constructs a new geometry with the appropriate specifications.
Parameters:
dimensionCount - the number of dimensions of the space
periodic - if the space is connected, or if it has an edge
fixedSize - if the space has a fixed extent
discrete - if the geometry is made up of dicrete locations (nodes)
neighborhood - whether the geometry' assumed neighborhood is Moore, von Neumann, or not applicable for this geometry

Geometry

public Geometry(int dimensionCount)
Creates a closed, discreet, Geometry.
Method Detail

newScape

public Scape newScape()
Creates an agent scape matching this geometry's specifications.

newScape

public Scape newScape(Agent prototypeAgent)
Creates an agent scape matching this geometry's specifications.
Parameters:
prototypeAgent - an agent that may be cloned to populate the scape

newScape

public Scape newScape(java.lang.String agentClassName)
Creates an agent scape matching this geometry's specifications.
Parameters:
agentClassName - the name of an agent to construct that may be cloned to populate the scape

newScape

public Scape newScape(Agent prototypeAgent,
                      Coordinate extent)
Creates an agent scape matching this geometry's specifications.
Parameters:
prototypeAgent - an agent that may be cloned to populate the scape
extent - the size of the scape; the coordinate at its maximium extent

getDimensionCount

public int getDimensionCount()
Returns the number of dimensions for this lattice. Returns null if structure is not dimensional.

setDimensionCount

public void setDimensionCount(int dimensionCount)
Sets the number of dimensions for this lattice. Set to null for non-dimensional Geometry, otherwise, makes Geometry dimensional.
Parameters:
int - dimensionCount the number of dimensions

isPeriodic

public boolean isPeriodic()
Is the geometry periodic or aperiodic? (Do edges wrap to opposite side or not?)

setPeriodic

public void setPeriodic(boolean periodic)
Sets the geometry to periodic or aperiodic.
Parameters:
discrete - true if periodic, false is aperiodic

isDiscrete

public boolean isDiscrete()
Is the geometry dicrete or continous?

setDiscrete

public void setDiscrete(boolean discrete)
Sets the geometry to discrete or continous.
Parameters:
discrete - true if discrete, false is continous

getNeighborhood

public int getNeighborhood()
Returns the geometry's presumed neighborhood.
Returns:
the symbol MOORE, VON_NEUMANN, or NOT_APPLICABLE

setNeighborhood

public void setNeighborhood(int symbol)
Set the neighborhood to use for calculations within this geometry.
Parameters:
symbol - the neighborhood, one of: MOORE, VON_NEUMANN, or NOT_APPLICABLE

toString

public java.lang.String toString()
A string representation of this geometry
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Clones the geometry. Catches clone not supported, as all geometries support cloning.
Overrides:
clone in class java.lang.Object

(c) 1998-2000 The Brookings Insitution
Webpage