de.tubs.cs.sc.casim
Class State

java.lang.Object
  |
  +--de.tubs.cs.sc.casim.State
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BlockState, TableState

public abstract class State
extends java.lang.Object
implements java.io.Serializable

The State class is the base class for all cellular automata. You must inherit a subclass and override appropriate methods

See Also:
TableState, BlockState, Serialized Form

Constructor Summary
State()
           
 
Method Summary
abstract  void copy(de.tubs.cs.sc.casim.State s)
          is called before transition for every cell do a field to field copy from s to this
 boolean equals(java.lang.Object obj)
          Default implementation for virtual Object.equals
 java.awt.Color getColor()
          returns the draw Color of the cell depending on the state or condition.
 java.lang.Object getComponent(int i)
          returns the i-th component of the state, as derived from the automatic translation from CDL.
 de.tubs.cs.sc.casim.State getConstant()
          if the state class is used in lattices with constant boundary conditions, it should return the constant state the base class implementation returns null
 de.tubs.cs.sc.casim.State getConstant(int dim, boolean dir)
          if the state class is used in lattices with constant boundary conditions, it should return the constant state, here dependent on the boundary direction.
 java.awt.image.ImageProducer getIcon()
          returns the icon with which the cell should be drawn.
static void globalTransition()
          is called after backup once to change global (static) variables
 int hashCode()
          Default implementation returns the RGB value.
static void initialize(de.tubs.cs.sc.casim.Lattice l)
          is called only once the base class implementation does nothing
static void initialize(de.tubs.cs.sc.casim.Lattice l, int option)
          is called only once to initialize all cells.
 java.lang.String toString()
          Default implementation returns empty String.
abstract  void transition(de.tubs.cs.sc.casim.Cell cell)
          is called after backup for every cell evaluate the new state of the cell use neighborhood methods of cell to get the neighborhood conditions
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

State

public State()
Method Detail

initialize

public static void initialize(de.tubs.cs.sc.casim.Lattice l,
                              int option)
is called only once to initialize all cells.

Parameters:
l - Lattice throough which all cells can be accessed.
option - An optional integer that can indicate different initial conditions. the base class implementation does nothing

initialize

public static void initialize(de.tubs.cs.sc.casim.Lattice l)
is called only once the base class implementation does nothing


getColor

public java.awt.Color getColor()
returns the draw Color of the cell depending on the state or condition. An array of colors is recommended. Returning null means the cell will not be drawn. Different states must return different colors.

Returns:
the drawing color

getIcon

public java.awt.image.ImageProducer getIcon()
returns the icon with which the cell should be drawn. For this to be used, getColor must return null, otherwise the color is used.

Returns:
the image to be displayed.

copy

public abstract void copy(de.tubs.cs.sc.casim.State s)
is called before transition for every cell do a field to field copy from s to this


transition

public abstract void transition(de.tubs.cs.sc.casim.Cell cell)
is called after backup for every cell evaluate the new state of the cell use neighborhood methods of cell to get the neighborhood conditions

See Also:
Cell

globalTransition

public static void globalTransition()
is called after backup once to change global (static) variables


getConstant

public de.tubs.cs.sc.casim.State getConstant()
if the state class is used in lattices with constant boundary conditions, it should return the constant state the base class implementation returns null


getConstant

public de.tubs.cs.sc.casim.State getConstant(int dim,
                                             boolean dir)
if the state class is used in lattices with constant boundary conditions, it should return the constant state, here dependent on the boundary direction. the base class implementation returns null


equals

public boolean equals(java.lang.Object obj)
Default implementation for virtual Object.equals

Overrides:
equals in class java.lang.Object
Returns:
true if both objects are State derived and the getColor method returns equal colors, otherwise false

hashCode

public int hashCode()
Default implementation returns the RGB value.

Overrides:
hashCode in class java.lang.Object
Returns:
a unique hash code depending on the getColor value

toString

public java.lang.String toString()
Default implementation returns empty String. It is used for the statistics.

Overrides:
toString in class java.lang.Object
Returns:
a String describing the state.

getComponent

public java.lang.Object getComponent(int i)
returns the i-th component of the state, as derived from the automatic translation from CDL. Need not otherwise be implemented.

Parameters:
i - number of the component (starting with 0).