org.jscience.biology.lsystems.growing
Class Rule

java.lang.Object
  extended by org.jscience.biology.lsystems.growing.Rule

public class Rule
extends java.lang.Object

To represent a rule of an LSystem containing a predecessor a successor and a probability this class may be used.


Constructor Summary
Rule(java.lang.String strRule)
          Constructor by passing the string of hte rule
Rule(java.lang.String strPredecessor, java.lang.String strSuccessor)
          Constructor allowing to initialize the predecesor and successor
 
Method Summary
static int getElementAge(java.lang.String strLine)
          Extracts the age of the first occurence of an element in the given string.
static char getElementID(java.lang.String strLine)
          Extracts the ID char of the first occurence of an element in the given string.
 java.lang.String getPredecessor()
          Returns the predecessor value of this rule.
 int getPredecessorAge()
          Retrieves the predecessor age.
 char getPredecessorID()
          Retrieves the predecessor ID
 java.lang.String getSuccessor()
          Returns the successor value of this rule
 void setPredecessor(java.lang.String strPredecessor)
          Stores a new predecessor in the member variable.
 void setSuccessor(java.lang.String strSuccessor)
          Stores a new sucessor in the member variable.
 java.lang.String toString()
          Converts the rule to a string version and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rule

public Rule(java.lang.String strRule)
     throws java.lang.Exception
Constructor by passing the string of hte rule

Parameters:
strRule - The string of this rule.
Throws:
java.lang.Exception - Is thrown if the rule is not in the right form or contains invalid signs.

Rule

public Rule(java.lang.String strPredecessor,
            java.lang.String strSuccessor)
Constructor allowing to initialize the predecesor and successor

Parameters:
strPredecessor - The predecessor of this rule.
strSuccessor - The successor of the rule.
Method Detail

getElementID

public static char getElementID(java.lang.String strLine)
Extracts the ID char of the first occurence of an element in the given string. The element is identified by the C_BEGIN_ELEMENT constant in the Def class.

Parameters:
strLine - The string containing the element.
Returns:
ID char
See Also:
GrowingPlantsDefinitions

getElementAge

public static int getElementAge(java.lang.String strLine)
Extracts the age of the first occurence of an element in the given string. The separator from an element ID to the age is the C_ELEMENT_SEPARATOR constant and the end is the C_END_ELEMENT constant both from the Def class.

Parameters:
strLine - The string containing the element.
Returns:
Age
See Also:
GrowingPlantsDefinitions

getPredecessorID

public char getPredecessorID()
Retrieves the predecessor ID

Returns:
The predecessor id char.

getPredecessorAge

public int getPredecessorAge()
Retrieves the predecessor age.

Returns:
the predecessor age.

setPredecessor

public void setPredecessor(java.lang.String strPredecessor)
Stores a new predecessor in the member variable.

Parameters:
strPredecessor - The new predecessor

setSuccessor

public void setSuccessor(java.lang.String strSuccessor)
Stores a new sucessor in the member variable.

Parameters:
strSuccessor - The new sucessor

getPredecessor

public java.lang.String getPredecessor()
Returns the predecessor value of this rule.

Returns:
The predecessor.

getSuccessor

public java.lang.String getSuccessor()
Returns the successor value of this rule

Returns:
The successor value.

toString

public java.lang.String toString()
Converts the rule to a string version and returns it. The output of the string is in the form predecessor, rulesign, successor.

Overrides:
toString in class java.lang.Object
Returns:
The rule as a string.