org.jscience.biology.lsystems.fixed
Class LSystem

java.lang.Object
  extended by org.jscience.biology.lsystems.fixed.LSystem

public class LSystem
extends java.lang.Object

This class represents an LSystem as we know it in text form. It can read values from a file or stream and store them in this class. After a system has been read and validated you can make the derivations and obtain the final string representing the figure. With this string the turtle is able to build the system and make it visible to the user.
The file or stram must respect some definitions: All codewords listed in the Def class must stand at the beginning of the line and written in the right case. As separator to the value only the specified symbol may be used. The order of the lines does not matter. Lines which do not begin with a codeword are ignored. White spaces may be used or not.

Example:

 depth = 5
 angle = 90
 

axiom = F-F-F-F rule = F -> F-F+F+FF-F-F+F


Constructor Summary
LSystem()
          Constructor.
 
Method Summary
 void build(java.io.File fileValues)
          Reads the values for the LSystem from a file and stores them in the member fields.
 void derivate()
          This method derivates the LSystem.
 float getAngle()
          Gets the angle of the LSystem
 float getDecrement()
          Gets the value of decrenentation of the thickness of a branch.
 float getLength()
          Gets the length of the branch at beginning.
 java.lang.String getSystem()
          Gets the LSystem represented by a string.
 float getThickness()
          Get the thickness of the branch at beginning.
 void setAngle(float fAngle)
          Sets the angle for the LSystem to the member field.
 void setAxiom(java.lang.String strAxiom)
          Stores the new axiom for this class.
 void setDepth(int iDepth)
          Sets the derivation depth for the LSystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LSystem

public LSystem()
Constructor. Initializes the member variables.

Method Detail

build

public void build(java.io.File fileValues)
           throws java.lang.Exception
Reads the values for the LSystem from a file and stores them in the member fields. Note that the values have to be declared in a certain manner defined in this class.

Parameters:
fileValues - The file to extract and store.
Throws:
java.lang.Exception

derivate

public void derivate()
              throws java.lang.Exception
This method derivates the LSystem. Once all values as depth, axiom and all rules are stored in this class a string representing the derivated LSystem can be generated. Beginning with the axiom the letters will be replaced using the rules. This is repeated as many times as indicated in the depth.

Throws:
java.lang.Exception - If the derivation process fails.

setDepth

public void setDepth(int iDepth)
Sets the derivation depth for the LSystem.

Parameters:
iDepth - The depth to set.

setAngle

public void setAngle(float fAngle)
Sets the angle for the LSystem to the member field.

Parameters:
fAngle - The new value for the angle.

setAxiom

public void setAxiom(java.lang.String strAxiom)
Stores the new axiom for this class.

Parameters:
strAxiom - The new axiom to set.

getSystem

public java.lang.String getSystem()
Gets the LSystem represented by a string.

Returns:
The system.

getAngle

public float getAngle()
Gets the angle of the LSystem

Returns:
The angle of the system

getThickness

public float getThickness()
Get the thickness of the branch at beginning.

Returns:
The thickness of the branch.

getLength

public float getLength()
Gets the length of the branch at beginning.

Returns:
The length of the branches.

getDecrement

public float getDecrement()
Gets the value of decrenentation of the thickness of a branch.

Returns:
The decrementation value.