statalign.postprocess.plugins
Class TreeNode

java.lang.Object
  extended by statalign.postprocess.plugins.TreeNode

public class TreeNode
extends java.lang.Object


Field Summary
 java.util.List<TreeNode> children
          The children of this node.
 double edgeLength
          The branch length of this node.
 boolean ignoreNode
           
 int leafCount
          The number of leaves in this subtree.
 java.lang.String name
          The name/identifier of this node.
 int nameLengthSum
          The sum of the length of the names below this vertex.
 TreeNode parent
          The parent of this node.
 java.util.HashMap<java.lang.String,java.lang.Object> properties
          Properties associated with this node.
 
Constructor Summary
TreeNode()
          A constructor which does not specify a name nor a edge length.
TreeNode(java.lang.String name)
          A constructor specifying the name of the node.
TreeNode(java.lang.String name, double edgeLength)
          A constructor specifying the name and the edge length of the node.
 
Method Summary
 void addChild(TreeNode node)
          Adds a child to this tree's list of children.
 void addProperty(java.lang.String key, java.lang.Object value)
          Adds a key=value property to be associated with this node.
 int countLeaves()
          Calculated the number of leads that exists below this node
 int countNameLengthSum()
          This function calculates the sum of the length of the strings representing the names of the leaves below this subtree.
 int getIntProperty(java.lang.String key)
          Same as getProperty(String) but this method returns a value casted to an Integer.
 java.util.List<TreeNode> getLeaves()
          Finds all of the leaves of the subtree of this node.
 java.util.List<TreeNode> getLeaves(TreeNode node)
          Same as getLeaves().
 TreeNode getLeft()
          TODO: WHAT?
 java.lang.Object getProperty(java.lang.String key)
          Return the value for a certain key property associated with this node.
 TreeNode getRight()
           
 boolean hasProperty(java.lang.String key)
          Determines whether a certain key exists in the properties associated with this node.
 boolean isLeaf()
          Determines whether this node is a leaf or not.
 double maxDepth()
          Calculate the maximum depth below on this vertex.
 int maxSteps()
          Calculate the nodes needed to cross to get to the most distant leaf Used in tree visualisation.
 java.lang.String toString()
          Constructs a Newick string from this subtree.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public java.lang.String name
The name/identifier of this node.


edgeLength

public double edgeLength
The branch length of this node.


children

public java.util.List<TreeNode> children
The children of this node.


parent

public TreeNode parent
The parent of this node.


properties

public java.util.HashMap<java.lang.String,java.lang.Object> properties
Properties associated with this node. Lazy initialized: Not instantiated unless needed.


ignoreNode

public boolean ignoreNode

nameLengthSum

public int nameLengthSum
The sum of the length of the names below this vertex. Used in the tree visualisation to decide how much space this subtree needs to be able to put leaves' names nicely onto the graphical interface.


leafCount

public int leafCount
The number of leaves in this subtree.

Constructor Detail

TreeNode

public TreeNode()
A constructor which does not specify a name nor a edge length.


TreeNode

public TreeNode(java.lang.String name)
A constructor specifying the name of the node.

Parameters:
name - the name of the node.

TreeNode

public TreeNode(java.lang.String name,
                double edgeLength)
A constructor specifying the name and the edge length of the node.

Parameters:
name - the name of the node.
edgeLength - the edge length of the node.
Method Detail

isLeaf

public boolean isLeaf()
Determines whether this node is a leaf or not.

Returns:
whether this node is a leaf or not.

addChild

public void addChild(TreeNode node)
Adds a child to this tree's list of children.

Parameters:
node - the child to be added.

getLeaves

public java.util.List<TreeNode> getLeaves()
Finds all of the leaves of the subtree of this node.

Returns:
a list of the leaves of this node's subtree.

getLeaves

public java.util.List<TreeNode> getLeaves(TreeNode node)
Same as getLeaves().

Parameters:
node - the node that we want to determine the leaves of.
Returns:
a list of the leaves of this nodes subtree.

toString

public java.lang.String toString()
Constructs a Newick string from this subtree.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this subtree in a Newick format.

addProperty

public void addProperty(java.lang.String key,
                        java.lang.Object value)
Adds a key=value property to be associated with this node.

Parameters:
key - the key portion of the property.
value - the value portion of the property.

getProperty

public java.lang.Object getProperty(java.lang.String key)
Return the value for a certain key property associated with this node.

Parameters:
key - the key portion of the property.
Returns:
the value associated with this key (or null if not existing).

getIntProperty

public int getIntProperty(java.lang.String key)
Same as getProperty(String) but this method returns a value casted to an Integer.

Parameters:
key - the key portion of the property.
Returns:
the value associated with this key (casted to an Integer).

hasProperty

public boolean hasProperty(java.lang.String key)
Determines whether a certain key exists in the properties associated with this node.

Parameters:
key - the key of the property.
Returns:
a boolean whether this key actually exists or not.

maxSteps

public int maxSteps()
Calculate the nodes needed to cross to get to the most distant leaf Used in tree visualisation.

Returns:
steps needed to reach the most distant leaf.

countNameLengthSum

public int countNameLengthSum()
This function calculates the sum of the length of the strings representing the names of the leaves below this subtree. Used in tree visualisation.

Returns:
the sum of the lengths of the names below this vertex.

countLeaves

public int countLeaves()
Calculated the number of leads that exists below this node

Returns:
the number of leaves below the node.

maxDepth

public double maxDepth()
Calculate the maximum depth below on this vertex. Used in tree visualisation.

Returns:
maximum depth below this vertex.

getLeft

public TreeNode getLeft()
TODO: WHAT?


getRight

public TreeNode getRight()