de.tubs.cs.sc.casim
Class Cell

java.lang.Object
  |
  +--de.tubs.cs.sc.casim.Cell
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CellNC

public class Cell
extends java.lang.Object
implements java.io.Serializable

The class Cell represents and capsulates one cell in the Cellular automatas lattice. This class is used for any kind of lattice. It has it's coordinates, a reference the lattice containing the cell and two references to a State class object as data members. For faster simulation each cell has two State[]s of references for the von Neumann and Moore Neighborhood with radius one, because the neighborhood of a cell will not be changed during simulation. The first state reference is the current one. The second is used as backup copy for the neighborhoods. In each generation of the Cellular Automata a copy is made from the current state to the backup state

See Also:
CALattice, State, Serialized Form

Field Summary
protected  de.tubs.cs.sc.casim.CALattice lattice
          a reference to the lattice containing this cell, necessary for the neighborhood calculation
protected  int x
          position of the cell in th elattice
protected  int y
          position of the cell in th elattice
protected  int z
          position of the cell in th elattice
 
Constructor Summary
Cell(de.tubs.cs.sc.casim.CALattice l, java.lang.Class state, int x, int y, int z)
          Cell constructor sets Lattice reference, creates the two states, current and backup.
 
Method Summary
 void backup()
          copies the current state into the backup state called during a generation step of the Cellular Automat
 de.tubs.cs.sc.casim.State getNeighborRelative(int x)
          Returns a relative neighbor only useful for one dimensional lattices.getNeighborRelative(int x) returns null for two or three dimensional lattices.
 de.tubs.cs.sc.casim.State getNeighborRelative(int x, int y)
          Returns a relative neighbor only useful for two dimensional lattices.
 de.tubs.cs.sc.casim.State getNeighborRelative(int x, int y, int z)
          Returns a relative neighbor only useful for three dimensional lattices.
 de.tubs.cs.sc.casim.State[] getNeighbors()
          getNeighbors uses the settings of the parent lattice for calculation the neighborhood The neighborhood is calculated only once and cached in the cell.
 de.tubs.cs.sc.casim.State[] getNeighborsMoore()
           
 de.tubs.cs.sc.casim.State[] getNeighborsMoore(int r)
           
 de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann()
           
 de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(int r)
           
 de.tubs.cs.sc.casim.State getOldState()
           
 de.tubs.cs.sc.casim.State getState()
           
 void onlyOneState()
           
 java.lang.String toString()
           
 void transition()
          the transition from generation n to generation n+1
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lattice

protected transient de.tubs.cs.sc.casim.CALattice lattice
a reference to the lattice containing this cell, necessary for the neighborhood calculation


x

protected final int x
position of the cell in th elattice


y

protected final int y
position of the cell in th elattice


z

protected final int z
position of the cell in th elattice

Constructor Detail

Cell

public Cell(de.tubs.cs.sc.casim.CALattice l,
            java.lang.Class state,
            int x,
            int y,
            int z)
     throws CAException
Cell constructor sets Lattice reference, creates the two states, current and backup.

Method Detail

getNeighbors

public de.tubs.cs.sc.casim.State[] getNeighbors()
getNeighbors uses the settings of the parent lattice for calculation the neighborhood The neighborhood is calculated only once and cached in the cell. So it's impossible to changed neighborhood conditions during simulation using getNeighbors. You should use getNeighborRelative instead.

See Also:
LatticeDefinition

getNeighborsvonNeumann

public de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(int r)
Returns:
a State[] of States representing the von Neumann neighborhood with radius r of the cell.

getNeighborsMoore

public de.tubs.cs.sc.casim.State[] getNeighborsMoore(int r)
Returns:
a State[] of States representing the Moore neighborhood with radius r of the cell.

getNeighborsvonNeumann

public de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann()
Returns:
a State[] of States representing the von Neumann neighborhood with radius 1 of the cell.

getNeighborsMoore

public de.tubs.cs.sc.casim.State[] getNeighborsMoore()
Returns:
a State[] of States representing the Moore neighborhood with radius 1 of the cell.

getNeighborRelative

public de.tubs.cs.sc.casim.State getNeighborRelative(int x,
                                                     int y,
                                                     int z)
Returns a relative neighbor only useful for three dimensional lattices. getNeighborRelative(int x, int y, int z) returns null for one or two dimensional lattices.

Returns:
the backup state of the neighbor x relative in horizontal direction, y in vertical and z in depth.

getNeighborRelative

public de.tubs.cs.sc.casim.State getNeighborRelative(int x,
                                                     int y)
Returns a relative neighbor only useful for two dimensional lattices. getNeighborRelative(int x, int y) returns null for one or three dimensional lattices.

Returns:
the backup state of the neighbor x relative in horizontal direction and y in vertical.

getNeighborRelative

public de.tubs.cs.sc.casim.State getNeighborRelative(int x)
Returns a relative neighbor only useful for one dimensional lattices.getNeighborRelative(int x) returns null for two or three dimensional lattices.

Returns:
the backup state of the neighbor x relative in horizontal direction

getState

public de.tubs.cs.sc.casim.State getState()
Returns:
the current state of the cell

getOldState

public de.tubs.cs.sc.casim.State getOldState()
Returns:
the backup copy of the cell used for calculating the neighborhood

onlyOneState

public void onlyOneState()
Returns:
the backup copy of the cell used for calculating the neighborhood

backup

public void backup()
copies the current state into the backup state called during a generation step of the Cellular Automat

See Also:
Lattice.transition()

transition

public void transition()
the transition from generation n to generation n+1

See Also:
Lattice.transition()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object