de.tubs.cs.sc.casim
Class TableState

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

public class TableState
extends State

A state class driven by a given state set and transition rule list. Base class for exported classes from state set and transition rule list.

See Also:
Serialized Form

Field Summary
protected  int condition
           
 
Constructor Summary
TableState()
          Constructor set's current state to 0
 
Method Summary
 void copy(de.tubs.cs.sc.casim.State s)
          copies the state member from s to current
protected  boolean doesNeighborhoodMatch(int[] rule, de.tubs.cs.sc.casim.State[] neighbors)
           
 boolean equals(java.lang.Object obj)
          Default implementation for virtual Object.equals
 java.awt.Color getColor()
          returns the color of current state using the ColorTable of state set definition
 int getCondition()
           
protected static int getConditionFromProbability(double p)
          Calculates the initial state in dependence of the probability p.
 int getNrOfStates()
           
static int getNrOfStatesStatic()
           
static double getProbability(int iState)
           
static de.tubs.cs.sc.casim.StateSetDefinition getStateDefinition()
           
static void initialize(de.tubs.cs.sc.casim.Lattice l)
          Initializes the lattice with the given probabilities for each state of the set.
 void setCondition(int c)
           
protected static void setStateDefinition(de.tubs.cs.sc.casim.StateSetDefinition ssd)
          sets the static reference of StateSetDefinition to ssd is called only once from CellularAutomat
 java.lang.String toString()
          returns a String representation of the TableState
 void transition(de.tubs.cs.sc.casim.Cell cell)
          performs the transition from the current state to the new calculated state using the StateSetDefinition
 
Methods inherited from class de.tubs.cs.sc.casim.State
getComponent, getConstant, getConstant, getIcon, globalTransition, hashCode, initialize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

condition

protected int condition
Constructor Detail

TableState

public TableState()
Constructor set's current state to 0

Method Detail

initialize

public static void initialize(de.tubs.cs.sc.casim.Lattice l)
Initializes the lattice with the given probabilities for each state of the set. If all probabilities are 0.0 nothing is done and every state is left unchanged.


getColor

public java.awt.Color getColor()
returns the color of current state using the ColorTable of state set definition

Overrides:
getColor in class State
Returns:
the drawing color
See Also:
StateSetDefinition

getProbability

public static double getProbability(int iState)
Returns:
the probability of the State iState in start configuration. Subclasses of TableState should override this method to provide their own probability table.

getConditionFromProbability

protected static int getConditionFromProbability(double p)
Calculates the initial state in dependence of the probability p.

Returns:
the initial state for the probability p

copy

public void copy(de.tubs.cs.sc.casim.State s)
copies the state member from s to current

Specified by:
copy in class State

transition

public void transition(de.tubs.cs.sc.casim.Cell cell)
performs the transition from the current state to the new calculated state using the StateSetDefinition

Specified by:
transition in class State
See Also:
StateSetDefinition

setStateDefinition

protected static void setStateDefinition(de.tubs.cs.sc.casim.StateSetDefinition ssd)
sets the static reference of StateSetDefinition to ssd is called only once from CellularAutomat


getStateDefinition

public static de.tubs.cs.sc.casim.StateSetDefinition getStateDefinition()
Returns:
the static reference of StateSetDefinition

getCondition

public int getCondition()
Returns:
the current condition

setCondition

public void setCondition(int c)

toString

public java.lang.String toString()
returns a String representation of the TableState

Overrides:
toString in class State
Returns:
String value of condition

equals

public boolean equals(java.lang.Object obj)
Description copied from class: State
Default implementation for virtual Object.equals

Overrides:
equals in class State
Returns:
true if this TableState is in equal condition as obj and obj is a TableState, otherwise false

getNrOfStates

public int getNrOfStates()
Returns:
the number of states, the size of the state set

getNrOfStatesStatic

public static int getNrOfStatesStatic()
Returns:
the number of states, the size of the state set

doesNeighborhoodMatch

protected boolean doesNeighborhoodMatch(int[] rule,
                                        de.tubs.cs.sc.casim.State[] neighbors)
Returns:
true if the current neighborhood matches the specified rule from the transition rule list