N
- type of elementspublic class MutableTree<N> extends java.lang.Object implements Tree<N>
Constructor and Description |
---|
MutableTree(N userObject) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(MutableTree<N> child) |
void |
addChild(MutableTree<N> child,
java.lang.Object edge) |
void |
clearChildren()
remove all children
|
void |
dump(java.io.PrintWriter writer) |
void |
dump(java.io.PrintWriter writer,
int indent) |
java.util.List<N> |
fillDepthFirst() |
int |
getChildCount()
A convenience method that gets the number of child
nodes that this node has.
|
java.util.List<Tree<N>> |
getChildren()
Gets the children of this tree node.
|
java.lang.Object |
getEdge(Tree<N> child) |
int |
getMaxDepth() |
Tree<N> |
getParent()
Gets the parent of this tree node.
|
java.util.List<Tree<N>> |
getPathToRoot() |
Tree<N> |
getRoot()
A convenience method that gets the root of this tree.
|
int |
getSize() |
N |
getUserObject()
Gets the "content" of this tree node.
|
java.util.Set<N> |
getUserObjectClosure() |
java.util.List<N> |
getUserObjectPathToRoot() |
boolean |
isLeaf()
A convenience method that determines if this node is
a leaf node (because it has no children).
|
boolean |
isRoot()
A convenience method that determines if this is
a root node (because it has no parent node)
|
void |
removeChild(MutableTree<N> child) |
void |
replace(MutableTree<N> tree)
Deprecated.
this method is not in the public interface and is unused.
|
void |
setNodeRenderer(NodeRenderer<N> renderer) |
void |
setParent(MutableTree<N> parent) |
void |
sortChildren(java.util.Comparator<Tree<N>> comparator)
Sorts the children using the specified comparator
|
java.lang.String |
toString() |
public MutableTree(N userObject)
userObject
- the user objectpublic N getUserObject()
Tree
getUserObject
in interface Tree<N>
public void setParent(MutableTree<N> parent)
parent
- the new parentpublic void addChild(MutableTree<N> child)
child
- child to addpublic void addChild(MutableTree<N> child, java.lang.Object edge)
child
- child to addedge
- the edgepublic void removeChild(MutableTree<N> child)
child
- child to removepublic void sortChildren(java.util.Comparator<Tree<N>> comparator)
Tree
sortChildren
in interface Tree<N>
comparator
- The comparator to be used for the sorting.public void clearChildren()
public Tree<N> getParent()
Tree
public java.util.List<Tree<N>> getChildren()
Tree
getChildren
in interface Tree<N>
public int getChildCount()
Tree
getChildCount
in interface Tree<N>
public boolean isRoot()
Tree
public boolean isLeaf()
Tree
public Tree<N> getRoot()
Tree
public java.util.List<Tree<N>> getPathToRoot()
getPathToRoot
in interface Tree<N>
public java.util.List<N> getUserObjectPathToRoot()
getUserObjectPathToRoot
in interface Tree<N>
public java.util.Set<N> getUserObjectClosure()
getUserObjectClosure
in interface Tree<N>
public void dump(java.io.PrintWriter writer)
public void dump(java.io.PrintWriter writer, int indent)
public void setNodeRenderer(NodeRenderer<N> renderer)
setNodeRenderer
in interface Tree<N>
renderer
- the renderer to usepublic java.util.List<N> fillDepthFirst()
fillDepthFirst
in interface Tree<N>
@Deprecated public void replace(MutableTree<N> tree)
tree
- the node to put in place of this onepublic java.lang.String toString()
toString
in class java.lang.Object
public int getSize()
public int getMaxDepth()