barsuift.simLife.tree
Class BasicTreeBranchPart

java.lang.Object
  extended by barsuift.simLife.tree.BasicTreeBranchPart
All Implemented Interfaces:
LivingPart, TreeBranchPart, java.util.Observer

public class BasicTreeBranchPart
extends java.lang.Object
implements TreeBranchPart


Constructor Summary
BasicTreeBranchPart(Universe universe, TreeBranchPartState state)
           
 
Method Summary
protected  boolean canCreateOneNewLeaf()
           
protected  boolean canIncreaseOneLeafSize()
           
 java.math.BigDecimal collectFreeEnergy()
           
protected  javax.vecmath.Point3d computeAttachPointForNewLeaf()
           
protected  void createOneNewLeaf()
           
 boolean equals(java.lang.Object obj)
           
 int getAge()
           
 TreeBranchPart3D getBranchPart3D()
           
 java.math.BigDecimal getEnergy()
          Return the sum of leaves energies
 java.lang.Long getId()
           
 java.util.List<TreeLeaf> getLeaves()
           
 int getNbLeaves()
           
protected  TreeLeaf getRandomLeafToIncrease()
          Returns one random leaf, with max odd to smallest leaf
 TreeBranchPartState getState()
           
 int hashCode()
           
protected  void increaseOneLeafSize()
           
protected  boolean shouldCreateOneNewLeaf()
          Test if we should create a new leaf or not.
protected  boolean shouldIncreaseOneLeafSize()
          Test if we should increase a leaf size or not.
 void spendTime()
          Make all leaves spend time.
 java.lang.String toString()
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicTreeBranchPart

public BasicTreeBranchPart(Universe universe,
                           TreeBranchPartState state)
Method Detail

getId

public java.lang.Long getId()
Specified by:
getId in interface LivingPart

getAge

public int getAge()
Specified by:
getAge in interface LivingPart

spendTime

public void spendTime()
Make all leaves spend time.

Specified by:
spendTime in interface LivingPart

increaseOneLeafSize

protected void increaseOneLeafSize()

getRandomLeafToIncrease

protected TreeLeaf getRandomLeafToIncrease()
Returns one random leaf, with max odd to smallest leaf


canIncreaseOneLeafSize

protected boolean canIncreaseOneLeafSize()

shouldIncreaseOneLeafSize

protected boolean shouldIncreaseOneLeafSize()
Test if we should increase a leaf size or not. The result is a random function with :
  1. 0% odd to be true if energy <= 20
  2. 100% odd to be true if energy >= 5 * 20
  3. a linear progression between the two values


canCreateOneNewLeaf

protected boolean canCreateOneNewLeaf()

shouldCreateOneNewLeaf

protected boolean shouldCreateOneNewLeaf()
Test if we should create a new leaf or not. The result is a random function with :
  1. 0% odd to be true if energy < 90
  2. 100% odd to be true if energy >= 2 * 90
  3. a linear progression between the two values


createOneNewLeaf

protected void createOneNewLeaf()

computeAttachPointForNewLeaf

protected javax.vecmath.Point3d computeAttachPointForNewLeaf()

getEnergy

public java.math.BigDecimal getEnergy()
Return the sum of leaves energies

Specified by:
getEnergy in interface TreeBranchPart

collectFreeEnergy

public java.math.BigDecimal collectFreeEnergy()
Specified by:
collectFreeEnergy in interface TreeBranchPart

getNbLeaves

public int getNbLeaves()
Specified by:
getNbLeaves in interface TreeBranchPart

getLeaves

public java.util.List<TreeLeaf> getLeaves()
Specified by:
getLeaves in interface TreeBranchPart

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

getState

public TreeBranchPartState getState()
Specified by:
getState in interface TreeBranchPart

getBranchPart3D

public TreeBranchPart3D getBranchPart3D()
Specified by:
getBranchPart3D in interface TreeBranchPart

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2010. All Rights Reserved.