|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.ultrametrics.util.Node
A class representing a node or collection of nodes which can paint themselves onto a canvas
Constructor Summary | |
Node()
Constructs an unnamed node. |
|
Node(java.lang.String name)
Constructs a node with the specified name. |
Method Summary | |
void |
addChild(Node child)
Adds a child to this node. |
void |
dump(int depth)
Deprecated. Provided for testing. Dumps the contents of this node on stdout. Recursively invokes dump() on the children of this node, causing the complete tree to be displayed. |
void |
generate(int depth)
recursively populates this tree. |
void |
generateChildren(int maxBranches,
int maxDepth)
Randomly and recursively populates this tree. |
void |
generateChildren(int minBranches,
int maxBranches,
int maxDepth)
|
java.util.Enumeration |
getChildren()
Returns an enumeration of this node's children. |
int |
getMaxBranches()
Deprecated. Provided for testing. Returns the maximum branching-factor of this tree if generateChildren was used to randomly populate this tree. |
int |
getMaxDepth()
Deprecated. Provided for testing. Returns the maximum depth of this tree if generateChildren was used to randomly populate this tree. |
int |
getMinBranches()
Deprecated. Provided for testing. Returns the maximum branching-factor of this tree if generateChildren was used to randomly populate this tree. |
java.lang.String |
getName()
Returns the name of this node. |
Node |
getParent()
Returns the parent node of this node. |
int |
getSize()
Returns the number of children of this node. |
void |
setName(java.lang.String name)
Sets the name of this node. |
void |
setParent(Node parent)
Sets the parent of this node. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Node()
public Node(java.lang.String name)
name
- the name of the nodeMethod Detail |
public void setParent(Node parent)
parent
- the parent node of this node.public void addChild(Node child)
public java.util.Enumeration getChildren()
public Node getParent()
public java.lang.String getName()
public int getSize()
public void setName(java.lang.String name)
public java.lang.String toString()
public void generateChildren(int maxBranches, int maxDepth)
For example: Node tree = new Node("top"); tree.generateChildren(4, 4);
Random node generation is constrained by the branching-factor and depth specified. Each node of the tree can have between 0 and maxBranches children. The resulting tree will have a depth between 0 and maxDepth measured from the top to leaf node. Each child node is named "x, y" where x is the depth and y the child's index (position relative to its siblings.)
maxBranches
- the maximum allowed branching-factormaxDepth
- the maximum allowed depthpublic void generateChildren(int minBranches, int maxBranches, int maxDepth)
public void generate(int depth)
depth
- initial depth; usually 0.public int getMaxDepth()
public int getMaxBranches()
public int getMinBranches()
public void dump(int depth)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |