AccordionTreeDrawer
Class Tree

java.lang.Object
  |
  +--AccordionTreeDrawer.Tree

public class Tree
extends java.lang.Object

A public class representing a (phylognenetic) tree. Nodes of the tree are of type TreeNode. Nodes are traversed in pre- and post-orders.

Version:
Author:
Yunhong Zhou, Li Zhang
See Also:
TreeNode, Newick, Nexus, Status

Field Summary
 java.util.ArrayList nodes
          The list of nodes of the tree indexed by their keys, indexed by key
 TreeNode posorderStartNode
          the start node for postorder list of all the nodes
 TreeNode preorderStartNode
          the start node for preorder list of all the nodes
 
Constructor Summary
Tree()
           
Tree(java.lang.String tn)
           
Tree(Tree t)
           
Tree(TreeNode rn)
           
 
Method Summary
 void close()
          clean up method, called when the tree is deleted
 int computeBin(int fontRange)
           
 int getKey()
           
 int getLeafCount()
           
 TreeNode getLeftmostLeaf()
           
 java.lang.String getName()
           
 TreeNode getNodeByKey(int key)
           
 TreeNode getNodeByName(java.lang.String s)
           
 TreeNode getRightmostLeaf()
           
 TreeNode getRoot()
           
 int getSize()
           
 void load_nexus(java.lang.String fname, int index)
          Reads a tree with giving index in a file fname with Nexus format and initiates the Tree object.
 void load(java.lang.String fname)
          Reads a tree in file fname described in Newick format and initiate the tree object.
 void postProcess()
          Post processing includes computing size of each node, linking nodes in different order, etc.
 void printLeaves()
           
 void setKey(int i)
           
 void setNodeFontSize(int maxFontSize, int minFontSize)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

public java.util.ArrayList nodes
The list of nodes of the tree indexed by their keys, indexed by key


preorderStartNode

public TreeNode preorderStartNode
the start node for preorder list of all the nodes


posorderStartNode

public TreeNode posorderStartNode
the start node for postorder list of all the nodes

Constructor Detail

Tree

public Tree()

Tree

public Tree(java.lang.String tn)

Tree

public Tree(TreeNode rn)

Tree

public Tree(Tree t)
Method Detail

close

public void close()
clean up method, called when the tree is deleted

See Also:
TreeJuxtaposer.TreeJuxtaposer.deleteTree, TreeNode.close

load

public void load(java.lang.String fname)
Reads a tree in file fname described in Newick format and initiate the tree object. Function load reads in the file, call the newick parser to parse it, and do some post processing afterwards. The tree object is originally empty. After calling the parser, it generates all the nodes decedant to the root. For each node of the tree, its name and edge weight will be set after parsing is complete. If the node has no name (internal nodes) or weight (some trees have no edge weight), then these fields will take the default value.

Parameters:
fname - The file name
See Also:
Newick

load_nexus

public void load_nexus(java.lang.String fname,
                       int index)
Reads a tree with giving index in a file fname with Nexus format and initiates the Tree object. Function load_nexus reads in the file, call the nexus parser to parse it, and do some post processing afterwards. The tree object is originally empty. After calling the parser, it generates all the nodes decedant to the root. For each node of the tree, its name and edge weight will be set after parsing is complete. If the node has no name (internal nodes) or weight (some trees have no edge weight), then these fields will take the default value.

Parameters:
fname - The file name
index - Index of the tree in the nexus file
See Also:
Nexus

getNodeByKey

public TreeNode getNodeByKey(int key)

getNodeByName

public TreeNode getNodeByName(java.lang.String s)

setKey

public void setKey(int i)

getKey

public int getKey()

getName

public java.lang.String getName()

getSize

public int getSize()

getLeftmostLeaf

public TreeNode getLeftmostLeaf()

getRightmostLeaf

public TreeNode getRightmostLeaf()

getRoot

public TreeNode getRoot()

getLeafCount

public int getLeafCount()

postProcess

public void postProcess()
Post processing includes computing size of each node, linking nodes in different order, etc. Sets left and right-most leaves of the tree Computes and stores pre- and post-orders for leaves can't do minmax until after linkNodesInPreorder is called to set index values!

See Also:
TreeNode

printLeaves

public void printLeaves()

computeBin

public int computeBin(int fontRange)

setNodeFontSize

public void setNodeFontSize(int maxFontSize,
                            int minFontSize)