public class JavaTreeNode
extends java.lang.Object
Tree
,
GridCell
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<JavaTreeNode> |
children
Array of child nodes that are attached below this internal node.
|
protected int |
computedFrame
The last frame that had a computed
midYPosition , for caching. |
int |
height
Distance from this node to the root node.
|
int |
key
key is unique for nodes in one tree.
|
java.lang.String |
label
The text that appears when the node is highlighted or has a name displayed.
|
JavaTreeNode |
leftmostLeaf
Leftmost (minimum) leaf node under this internal node (or this node for leaves).
|
protected java.lang.String |
name
Node name with default "".
|
int |
numberLeaves
The number of leaves under this internal node (or 1 for leaves).
|
JavaTreeNode |
parent
The parent of this node.
|
JavaTreeNode |
posorderNext
The next postorder node.
|
JavaTreeNode |
preorderNext
The next preorder node.
|
JavaTreeNode |
rightmostLeaf
Rightmost (maximum) leaf node under this internal node (or this node for leaves).
|
float |
weight
Weight is the horizontal edge length for the edge immediately above the node.
|
Constructor and Description |
---|
JavaTreeNode()
Default tree node constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(JavaTreeNode n)
Add a child to the end of the list of children.
|
void |
close()
Clean this node of children.
|
int |
compareTo(java.lang.Object o)
Implements Comparable interface - sorts on key field.
|
boolean |
equals(JavaTreeNode n)
Tests nodes for equality, based on the name of the node.
|
protected void |
finalize()
Destroy this node.
|
JavaTreeNode |
firstChild()
Get the first child of this node.
|
java.lang.Double |
getBcnScore()
Get the BCN score for this treenode.
|
JavaTreeNode |
getChild(int i)
Get a given child for this node, with range checking and casting.
|
protected boolean |
getEdge(int xy)
Tests to see if this node has a vertical or horizontal edge component.
|
int |
getId() |
int |
getKey()
Returns the key for this node.
|
int |
getMax()
Returns the maximum key value of nodes in the subtree rooted but this node.
|
int |
getMin()
Returns the minimum key value of nodes in the subtree rooted by this node.
|
java.lang.String |
getName()
Returns the label for this node, which is
name . |
float |
getWeight()
Get the weight of this treenode, which encodes the length of the horizontal edge.
|
boolean |
isLeaf()
Tests to determine if this node is a leaf.
|
boolean |
isRoot()
Tests to determine if this node is the root of its tree.
|
JavaTreeNode |
lastChild()
Get the last child of this node.
|
void |
linkNodesInPostorder()
Leaf->root traversal, starting at leftmost leaf of tree.
|
void |
linkNodesInPreorder()
root->leaf traversal, depth first in direction of leftmost leaf.
|
int |
numberChildren()
Get the number of children under this node.
|
JavaTreeNode |
parent()
Get the parent for this node.
|
void |
print()
Long form printing for a single node.
|
void |
setBcnScore(float n)
Set the
bcnScore for this node. |
void |
setExtremeLeaves()
Set the extreme leaves for this node.
|
void |
setId(int integer) |
void |
setName(java.lang.String s)
Set the name for this node, the name is usually the label drawn with this node.
|
int |
setNumberLeaves()
Sets the number of leaves, must be run on leaves first (pre-order)
|
void |
setWeight(double w)
Set the weight of this treenode, which encodes the length of the horizontal edge.
|
java.lang.String |
toString()
String value of this node, name + key + tree height information.
|
protected java.util.ArrayList<JavaTreeNode> children
public int key
protected int computedFrame
midYPosition
, for caching.public JavaTreeNode parent
protected java.lang.String name
public java.lang.String label
public int height
public float weight
public JavaTreeNode leftmostLeaf
public JavaTreeNode rightmostLeaf
public int numberLeaves
public JavaTreeNode preorderNext
public JavaTreeNode posorderNext
public JavaTreeNode()
public void setId(int integer)
public int getId()
public int getMin()
public int getMax()
public int getKey()
key
for this node.public java.lang.String getName()
name
.name
for this node.protected boolean getEdge(int xy)
xy
- 0/X for horizontal, 1/Y for vertical nodes.public int compareTo(java.lang.Object o)
o
- The other object to compare this node to.public void close()
protected void finalize() throws java.lang.Throwable
close()
.finalize
in class java.lang.Object
java.lang.Throwable
public void setName(java.lang.String s)
s
- The new value of name
, the name for this node.public int numberChildren()
children
.public JavaTreeNode getChild(int i)
i
- The child index to get.public boolean isLeaf()
public boolean isRoot()
public boolean equals(JavaTreeNode n)
n
- Second node to test vs. this node.public void addChild(JavaTreeNode n)
n
- New child node for this node.public JavaTreeNode parent()
parent
.public void setWeight(double w)
w
- New edge weight for this node, weight
.public float getWeight()
weight
.public JavaTreeNode firstChild()
public JavaTreeNode lastChild()
public void print()
#printSubtree()
to display a whole subtree.public void setExtremeLeaves()
public void linkNodesInPreorder()
public void linkNodesInPostorder()
public int setNumberLeaves()
numberLeaves
) including the
current node (leaves = 1)public java.lang.String toString()
toString
in class java.lang.Object
public void setBcnScore(float n)
bcnScore
for this node.n
- New value of bcnScore
.public java.lang.Double getBcnScore()
bcnScore
for this node.