de.tubs.cs.sc.casim
Class StateSetDefinition

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

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

StateSetDefinition represents a direct specified cellular automaton. It contains a state set, a list of transition rules, a color table and a probability table for initial condition.

See Also:
TableState, Serialized Form

Constructor Summary
StateSetDefinition()
          Construction
 
Method Summary
 de.tubs.cs.sc.casim.TransitionRule addTransitionRule()
          Creates a new empty TransitionRule and adds it to the list of TransitionRules
protected  int calculateNewState(int iOldState, de.tubs.cs.sc.casim.State[] neighbors)
          This method is used during the execution of the CA.
 boolean deleteTransitionRule(java.lang.String s)
          Deletes the specified TransitionRule from the list
 java.awt.Color getColor(int iState)
           
 java.lang.String getFileName()
          returns the last used file name of the CA
 java.lang.String getName()
           
 int getNrOfStates()
           
 int getNrOfTransitionRules()
          Returns the number of elements in the transition rule list.
 double getProbability(int iState)
           
 double getProbabilitySum()
           
 de.tubs.cs.sc.casim.TransitionRule getTransitionRule(int i)
          Returns the i'th element of the transition rule list if exists.
 de.tubs.cs.sc.casim.TransitionRule getTransitionRule(java.lang.String s)
          Searches through the list of TransitionRules and returns the TransitionRule if can be found
 boolean moveDown(java.lang.String s)
          Moves the specified TransitionRule one position down in the list.
 boolean moveUp(java.lang.String s)
          Moves the specified TransitionRule one position up in the list
 void setColor(int i, java.awt.Color color)
          sets the color for the specified state
 void setFileName(java.lang.String s)
          sets the file name of the CA
 void setName(java.lang.String s)
          sets the name of the CA
 void setNrOfStates(int newNrOfStates)
          sets the new number of states
 void setProbability(int i, double prob)
          sets the probability for the specified state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateSetDefinition

public StateSetDefinition()
Construction

Method Detail

getColor

public java.awt.Color getColor(int iState)
Returns:
the color for state iState

setColor

public void setColor(int i,
                     java.awt.Color color)
sets the color for the specified state


getProbability

public double getProbability(int iState)
Returns:
the probability for state iState

setProbability

public void setProbability(int i,
                           double prob)
sets the probability for the specified state


getProbabilitySum

public double getProbabilitySum()
Returns:
the sum of all state probabilities

getName

public java.lang.String getName()
Returns:
the name of the CA

setName

public void setName(java.lang.String s)
sets the name of the CA


setFileName

public void setFileName(java.lang.String s)
sets the file name of the CA


getFileName

public java.lang.String getFileName()
returns the last used file name of the CA


getNrOfStates

public int getNrOfStates()
Returns:
the number of states

setNrOfStates

public void setNrOfStates(int newNrOfStates)
sets the new number of states


getNrOfTransitionRules

public int getNrOfTransitionRules()
Returns the number of elements in the transition rule list. Can be used for iterating over all TransitionRules.

Returns:
the number of transition rules
See Also:
TransitionRule

getTransitionRule

public de.tubs.cs.sc.casim.TransitionRule getTransitionRule(int i)
Returns the i'th element of the transition rule list if exists. Can be used for iterating over all TransitionRules.

Parameters:
i - the index i to be returned
Returns:
the transition rule at position i
See Also:
TransitionRule

getTransitionRule

public de.tubs.cs.sc.casim.TransitionRule getTransitionRule(java.lang.String s)
Searches through the list of TransitionRules and returns the TransitionRule if can be found

Parameters:
s - a string returned by TransitionRule.toString representing a transition rule
Returns:
the found TransitionRule or null if no rule could be found
See Also:
TransitionRule

addTransitionRule

public de.tubs.cs.sc.casim.TransitionRule addTransitionRule()
Creates a new empty TransitionRule and adds it to the list of TransitionRules

See Also:
TransitionRule

deleteTransitionRule

public boolean deleteTransitionRule(java.lang.String s)
Deletes the specified TransitionRule from the list

Parameters:
s - a string returned by TransitionRule.toString representing a transition rule
Returns:
true if the TransitionRule was in the list and could be removed, otherwise false
See Also:
TransitionRule

moveUp

public boolean moveUp(java.lang.String s)
Moves the specified TransitionRule one position up in the list

Parameters:
s - a string returned by TransitionRule.toString representing a transition rule
Returns:
true if the element could be moved up successfully otherwise false
See Also:
TransitionRule

moveDown

public boolean moveDown(java.lang.String s)
Moves the specified TransitionRule one position down in the list.

Parameters:
s - a string returned by TransitionRule.toString representing a transition rule
Returns:
true if the element could be moved down successfully otherwise false
See Also:
TransitionRule

calculateNewState

protected int calculateNewState(int iOldState,
                                de.tubs.cs.sc.casim.State[] neighbors)
This method is used during the execution of the CA. Calculates the new state of the cell by searching for matching neighborhoods in all transition rules. If a matching neighborhood can be found the new state of the transitionrule will be returned. If no matching rule can be found the old state of the cell will be returned, so the cell's state will be unchanged.

Parameters:
iOldState - the current state of the Cell which should be updated
neighbors - a vector of neighbors of the cell
Returns:
the new State of the cell
See Also:
State, TransitionRule