|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.upenn.crimson.Species
public class Species
A single species object. Species can only exist within a tree and thus the species is added to a tree when it is created. Because species must exist within trees, copy(Tree) is used instead of clone() when duplicating a species for inclusion in a subtree.
Field Summary | |
---|---|
private int |
childIndex
This is used by nextChild() to allow for traversing the tree in a recursive like fashion but without using recursion. |
private Species[] |
children
This contains the set of children. |
private java.lang.String |
id
The ID of the species. |
private int |
level
Level from root to this species. |
private Species |
parent
The parent will be null if this Species is the root. |
private double |
stemLength
Length from parent to this species (default = 1.0). |
private double |
tempDepth
Length from root to this species. |
Constructor Summary | |
---|---|
Species(int id,
Tree tree)
|
|
Species(java.lang.String id,
double stemLength,
int level,
Tree tree)
|
|
Species(java.lang.String id,
Tree tree)
|
Method Summary | |
---|---|
void |
addChild(Species child)
This will add the child to the set of children and then set the parent of the child to be this Species object. |
boolean |
collapse()
This will remove this internal species, linking all children to our parent and adjusting their stem lengths accordingly. |
int |
compareTo(java.lang.Object obj)
When comparing Species objects, we actually just compare the index values. |
void |
computeLevel()
This will compute the level of the species, assuming the parent's level has already been computed. |
void |
computeTempDepth()
This will compute the length to the root, assuming the parent's root length has already been computed. |
Species |
copy(Tree tree)
This will return a copy of the current species WITHOUT the parent, children, or level. |
boolean |
equals(java.lang.Object obj)
When comparing Species to be equal, we compare their IDs. |
boolean |
firstChild()
This will return the true if this is the first child to be returned. |
Species[] |
getChildren()
|
java.lang.String |
getID()
|
int |
getLevel()
|
Species |
getParent()
|
java.util.HashSet |
getSiblings()
It is assumed that all trees have a single root. |
double |
getStemLength()
|
double |
getTempDepth()
|
int |
hashCode()
We use the hash of the ID as the object's hash code. |
boolean |
hasNextChild()
This will return true if there are more children. |
boolean |
isBinary()
Returns true if this node is binary. |
boolean |
isLeaf()
Returns true if this species is a leaf (ie has no children). |
boolean |
isRoot()
Returns true if this species doesn't have a parent. |
Species |
nextChild()
This will return the next child keeping track of the children returned. |
int |
numChildren()
Returns the number of children. |
java.lang.String |
printNexus()
This will print out this species and all children as a NEXUS formatted tree. |
java.lang.String |
printTree(java.lang.String indent)
This will print out the tree, one species per line, indenting each level. |
void |
removeChild(Species child)
This will remove the child from the set of children. |
void |
resetChildIndex()
This resets the index used by nextChild(). |
void |
setID(java.lang.String id)
The species ID is forced to be upper case. |
void |
setLevel(int level)
|
void |
setParent(Species parent)
|
void |
setStemLength(double stemLength)
|
void |
setTempDepth_Level(double parentLength,
int level)
This will set the temporal depth and level at the same time. |
void |
setTempDepth(double tempDepth)
|
java.lang.String |
toString()
|
java.lang.String |
toStringFull()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String id
private int level
private double stemLength
private double tempDepth
private Species parent
private Species[] children
private int childIndex
Constructor Detail |
---|
public Species(int id, Tree tree)
public Species(java.lang.String id, Tree tree)
public Species(java.lang.String id, double stemLength, int level, Tree tree)
Method Detail |
---|
public void setID(java.lang.String id)
public java.lang.String getID()
public void setStemLength(double stemLength)
public double getStemLength()
public void setTempDepth(double tempDepth)
public double getTempDepth()
public void setLevel(int level)
public int getLevel()
public void setParent(Species parent)
public Species getParent()
public Species[] getChildren()
public void computeTempDepth()
public void computeLevel()
public void setTempDepth_Level(double parentLength, int level)
public void addChild(Species child)
public void removeChild(Species child)
public int numChildren()
public java.util.HashSet getSiblings()
public boolean isLeaf()
public boolean isRoot()
public boolean isBinary()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
public Species copy(Tree tree)
public java.lang.String toStringFull()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean collapse()
public void resetChildIndex()
public boolean firstChild()
public boolean hasNextChild()
public Species nextChild()
public java.lang.String printNexus()
public java.lang.String printTree(java.lang.String indent)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |