org.jscience.biology.lsystems.growing
Class Plant

java.lang.Object
  extended by org.jscience.biology.lsystems.growing.Plant
All Implemented Interfaces:
java.lang.Comparable

public class Plant
extends java.lang.Object
implements java.lang.Comparable

This class represents a plant which can be built with a lindenmayer system.


Constructor Summary
Plant(java.io.File fileLsy, int iX, int iY)
          Constructor.
 
Method Summary
 javax.media.j3d.TransformGroup build()
          Builds the scene graph from the input file.
 javax.vecmath.Matrix3f buildMatrix(javax.vecmath.Vector3f v3fCol0, javax.vecmath.Vector3f v3fCol1, javax.vecmath.Vector3f v3fCol2)
          Builds a new 3x3 matrix with the given three vectors by inserting the vector values in the matrix columns.
 int compareTo(java.lang.Object obj)
          Compares a plant to another.
 java.util.Vector getAnimationList()
          Gets the list of AnimtionGroup objects.
 java.lang.String getName()
          Gets the name of the plant.
static Plant getSelected()
          Retrieves the selectedd plant.
 int getX()
          Gets the X position of this plant.
 int getY()
          Gets the Y position of this plant.
 boolean isSelected()
          Checks if this plant is selected.
 void parseRule(javax.media.j3d.TransformGroup tgPrevious, char cID, float fStartAge, int iDepth, float fThickness)
          Searches the rule for the specified id and adds the scenegraph subtree.
 javax.vecmath.Matrix3f rotationMatrix(javax.vecmath.Vector3f v3fAxe, float fAngle)
          Calculates the rotation matrix for a 3D rotation around the axe going through the point 0,0,0 with the direction described by the vector of the given angle.
 void setSelected()
          Sets this plant instance as the selected one.
 void setX(int iX)
          Sets the X position of this plant.
 void setY(int iY)
          Sets the Y position of this plant.
 java.lang.String toString()
          Returns a string representation of this plant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Plant

public Plant(java.io.File fileLsy,
             int iX,
             int iY)
      throws java.lang.Exception
Constructor. Makes ney LSystem for his plant and stores placement of plant in the scene.

Parameters:
fileLsy - A file descriptor to the .lsy file for this LSystem.
iX - The X position in the scene.
iY - The Y position in the scene.
Throws:
java.lang.Exception - an exception if the file could not be opened.
Method Detail

build

public javax.media.j3d.TransformGroup build()
Builds the scene graph from the input file.

Returns:
The top transformgroup node of the plant.

parseRule

public void parseRule(javax.media.j3d.TransformGroup tgPrevious,
                      char cID,
                      float fStartAge,
                      int iDepth,
                      float fThickness)
Searches the rule for the specified id and adds the scenegraph subtree.

Parameters:
tgPrevious - The transformgroup where to add the subtree.
cID - The char of the rule which has to be searched.
fStartAge - The start age of the next elements.
iDepth - The recursion depth at this time. Apply rules until iDepth is equal to the depth of the LSystem.
fThickness - The bottom thicknes of a branch. Top is fThickness minus the decrement stored in the LSystem.

rotationMatrix

public javax.vecmath.Matrix3f rotationMatrix(javax.vecmath.Vector3f v3fAxe,
                                             float fAngle)
Calculates the rotation matrix for a 3D rotation around the axe going through the point 0,0,0 with the direction described by the vector of the given angle.

Parameters:
v3fAxe - The vector describing the axis going through the origin (0,0,0).
fAngle - The angle describing the rotation value.
Returns:
The 3x3 float matrix which is the rotation matrix.

buildMatrix

public javax.vecmath.Matrix3f buildMatrix(javax.vecmath.Vector3f v3fCol0,
                                          javax.vecmath.Vector3f v3fCol1,
                                          javax.vecmath.Vector3f v3fCol2)
Builds a new 3x3 matrix with the given three vectors by inserting the vector values in the matrix columns.

Parameters:
v3fCol0 - The vector to be inserted in the first column.
v3fCol1 - The vector to be inserted in the second column.
v3fCol2 - The vector to be inserted in the third column.
Returns:
A newly created 3x3 matrix.

getAnimationList

public java.util.Vector getAnimationList()
Gets the list of AnimtionGroup objects. These are all objects of this plant which have to be scaled or translated.

Returns:
The vector containing the objects.

getX

public int getX()
Gets the X position of this plant.

Returns:
The X position.

getY

public int getY()
Gets the Y position of this plant.

Returns:
The Y position.

setX

public void setX(int iX)
Sets the X position of this plant.

Parameters:
iX - The X position.

setY

public void setY(int iY)
Sets the Y position of this plant.

Parameters:
iY - The Y position.

toString

public java.lang.String toString()
Returns a string representation of this plant. The name followed by the X and Y position.

Overrides:
toString in class java.lang.Object
Returns:
The string of this plant.

setSelected

public void setSelected()
Sets this plant instance as the selected one.


isSelected

public boolean isSelected()
Checks if this plant is selected.

Returns:
True if selected else false.

getSelected

public static Plant getSelected()
Retrieves the selectedd plant.

Returns:
The selected plant

getName

public java.lang.String getName()
Gets the name of the plant.

Returns:
The name of the plant.

compareTo

public int compareTo(java.lang.Object obj)
Compares a plant to another. This method overrrides the method from the comparable interface. It compared the strings of the names.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - Object to compare with. Must be an instance of Plant.
Returns:
Returns the return value of the compareto methos from the String class. The names of the plants are compared.