uk.ac.manchester.cs.bhig.util
Class MutableTree<N>

java.lang.Object
  extended by uk.ac.manchester.cs.bhig.util.MutableTree<N>
All Implemented Interfaces:
Tree<N>
Direct Known Subclasses:
ExplanationTree

public class MutableTree<N>
extends java.lang.Object
implements Tree<N>

Author: Matthew Horridge
The University Of Manchester
Bio-Health Informatics Group
Date: 22-Jan-2008


Constructor Summary
MutableTree(N userObject)
           
 
Method Summary
 void addChild(MutableTree<N> child)
           
 void addChild(MutableTree<N> child, java.lang.Object edge)
           
 void clearChildren()
           
 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)
           
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutableTree

public MutableTree(N userObject)
Method Detail

getUserObject

public N getUserObject()
Description copied from interface: Tree
Gets the "content" of this tree node.

Specified by:
getUserObject in interface Tree<N>
Returns:
The user content of this node.

setParent

public void setParent(MutableTree<N> parent)

addChild

public void addChild(MutableTree<N> child)

addChild

public void addChild(MutableTree<N> child,
                     java.lang.Object edge)

removeChild

public void removeChild(MutableTree<N> child)

getEdge

public java.lang.Object getEdge(Tree<N> child)
Specified by:
getEdge in interface Tree<N>

sortChildren

public void sortChildren(java.util.Comparator<Tree<N>> comparator)
Description copied from interface: Tree
Sorts the children using the specified comparator

Specified by:
sortChildren in interface Tree<N>
Parameters:
comparator - The comparator to be used for the sorting.

clearChildren

public void clearChildren()

getParent

public Tree<N> getParent()
Description copied from interface: Tree
Gets the parent of this tree node.

Specified by:
getParent in interface Tree<N>
Returns:
The parent tree node, or null if this node doesn't have a parent.

getChildren

public java.util.List<Tree<N>> getChildren()
Description copied from interface: Tree
Gets the children of this tree node.

Specified by:
getChildren in interface Tree<N>
Returns:
A list of children. If this tree node doesn't have any children then the list will be empty.

getChildCount

public int getChildCount()
Description copied from interface: Tree
A convenience method that gets the number of child nodes that this node has.

Specified by:
getChildCount in interface Tree<N>
Returns:
The count of the number of children of this node.

isRoot

public boolean isRoot()
Description copied from interface: Tree
A convenience method that determines if this is a root node (because it has no parent node)

Specified by:
isRoot in interface Tree<N>
Returns:
true if this is a root node, otherwise false.

isLeaf

public boolean isLeaf()
Description copied from interface: Tree
A convenience method that determines if this node is a leaf node (because it has no children).

Specified by:
isLeaf in interface Tree<N>
Returns:
true if this node is a leaf node otherwise false.

getRoot

public Tree<N> getRoot()
Description copied from interface: Tree
A convenience method that gets the root of this tree.

Specified by:
getRoot in interface Tree<N>
Returns:
The root node, which could be this node.

getPathToRoot

public java.util.List<Tree<N>> getPathToRoot()
Specified by:
getPathToRoot in interface Tree<N>

getUserObjectPathToRoot

public java.util.List<N> getUserObjectPathToRoot()
Specified by:
getUserObjectPathToRoot in interface Tree<N>

getUserObjectClosure

public java.util.Set<N> getUserObjectClosure()
Specified by:
getUserObjectClosure in interface Tree<N>

dump

public void dump(java.io.PrintWriter writer)
Specified by:
dump in interface Tree<N>

dump

public void dump(java.io.PrintWriter writer,
                 int indent)
Specified by:
dump in interface Tree<N>

setNodeRenderer

public void setNodeRenderer(NodeRenderer<N> renderer)
Specified by:
setNodeRenderer in interface Tree<N>

fillDepthFirst

public java.util.List<N> fillDepthFirst()
Specified by:
fillDepthFirst in interface Tree<N>

replace

public void replace(MutableTree<N> tree)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSize

public int getSize()

getMaxDepth

public int getMaxDepth()