Package pal.tree
Class Tree.TreeBase
- java.lang.Object
-
- pal.tree.Tree.TreeBase
-
- All Implemented Interfaces:
java.io.Serializable,IdGroup,Report,Units,UnitsProvider,Tree
- Enclosing interface:
- Tree
public abstract static class Tree.TreeBase extends java.lang.Object implements Tree, Report, Units, java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface pal.misc.IdGroup
IdGroup.Utils
-
Nested classes/interfaces inherited from interface pal.tree.Tree
Tree.TreeBase
-
-
Field Summary
-
Fields inherited from interface pal.misc.Units
DAYS, EXPECTED_SUBSTITUTIONS, GENERATIONS, MONTHS, SAMPLE, SHORT_UNIT_NAMES, UNIT_NAMES, UNKNOWN, YEARS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateNodeList()count and list external and internal nodes and compute heights of each nodeNodefindNode(int num)return node with number num (as displayed in ASCII tree)java.lang.ObjectgetAttribute(Node node, java.lang.String name)NodegetExternalNode(int i)Returns the ith external node.intgetExternalNodeCount()Returns the number of external nodes.intgetIdCount()Returns the number of identifiers in this groupIdentifiergetIdentifier(int i)Returns the ith identifier.NodegetInternalNode(int i)Returns the ith internal node.intgetInternalNodeCount()Returns the number of internal nodes.NodegetRoot()Returns the root node of this tree.intgetUnits()Return the units that this tree is expressed in.voidreport(java.io.PrintWriter out)print human readable report (e.g., on parameters and associated model)voidreroot(int num)make node with number num to root nodevoidreroot(Node node)make provided node the root nodevoidsetAttribute(Node node, java.lang.String name, java.lang.Object value)Sets an named attribute for a given node.voidsetIdentifier(int i, Identifier id)Sets the ith identifier.voidsetRoot(Node theRoot)Called by subclasses that can't give root at time of construction (of this class)protected voidsetSetupLengthsAndHeights(boolean value)Set whether or not this class should call methods to adjust either heights or lengths automaticallyvoidsetUnits(int units)Sets the units that this tree is expressed in.java.lang.StringtoString()intwhichIdNumber(java.lang.String s)returns the index of the identifier with the given name.
-
-
-
Constructor Detail
-
TreeBase
protected TreeBase(Node theRoot)
constructor- Parameters:
theRoot- the node to base tree on
-
TreeBase
protected TreeBase()
constructor
-
TreeBase
protected TreeBase(Tree.TreeBase tree, Node newRoot)
clone constructor
-
-
Method Detail
-
setRoot
public void setRoot(Node theRoot)
Called by subclasses that can't give root at time of construction (of this class)
-
getUnits
public final int getUnits()
Return the units that this tree is expressed in.- Specified by:
getUnitsin interfaceTree- Specified by:
getUnitsin interfaceUnitsProvider- Returns:
- the units relating to this object.
-
setUnits
public final void setUnits(int units)
Sets the units that this tree is expressed in.
-
getExternalNodeCount
public final int getExternalNodeCount()
Returns the number of external nodes.- Specified by:
getExternalNodeCountin interfaceTree- Returns:
- a count of the number of external nodes (tips) in this tree.
-
getExternalNode
public final Node getExternalNode(int i)
Returns the ith external node.- Specified by:
getExternalNodein interfaceTree- Returns:
- the ith external node in the tree.
-
getInternalNodeCount
public final int getInternalNodeCount()
Returns the number of internal nodes.- Specified by:
getInternalNodeCountin interfaceTree- Returns:
- a count of the number of internal nodes (and hence clades) in this tree.
-
getInternalNode
public final Node getInternalNode(int i)
Returns the ith internal node.- Specified by:
getInternalNodein interfaceTree- Returns:
- the ith internal node in the tree.
-
getRoot
public final Node getRoot()
Returns the root node of this tree.
-
findNode
public Node findNode(int num)
return node with number num (as displayed in ASCII tree)- Parameters:
num- number of node- Returns:
- node
-
createNodeList
public void createNodeList()
count and list external and internal nodes and compute heights of each node- Specified by:
createNodeListin interfaceTree
-
setSetupLengthsAndHeights
protected void setSetupLengthsAndHeights(boolean value)
Set whether or not this class should call methods to adjust either heights or lengths automatically
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setAttribute
public void setAttribute(Node node, java.lang.String name, java.lang.Object value)
Sets an named attribute for a given node.- Specified by:
setAttributein interfaceTree- Parameters:
node- the node whose attribute is being set.name- the name of the attribute.value- the new value of the attribute.
-
getAttribute
public java.lang.Object getAttribute(Node node, java.lang.String name)
- Specified by:
getAttributein interfaceTree- Parameters:
node- the node being interrogated.name- the name of the attribute of interest.- Returns:
- an object representing the named attributed for the numbered node.
-
reroot
public void reroot(int num)
make node with number num to root node- Parameters:
num- number of node
-
reroot
public void reroot(Node node)
make provided node the root node- Parameters:
node- the node to make the root.
-
getIdCount
public int getIdCount()
Description copied from interface:IdGroupReturns the number of identifiers in this group- Specified by:
getIdCountin interfaceIdGroup
-
getIdentifier
public Identifier getIdentifier(int i)
Description copied from interface:IdGroupReturns the ith identifier.- Specified by:
getIdentifierin interfaceIdGroup
-
setIdentifier
public void setIdentifier(int i, Identifier id)Description copied from interface:IdGroupSets the ith identifier.- Specified by:
setIdentifierin interfaceIdGroup
-
whichIdNumber
public int whichIdNumber(java.lang.String s)
Description copied from interface:IdGroupreturns the index of the identifier with the given name.- Specified by:
whichIdNumberin interfaceIdGroup
-
-