org.melati.util
Class ChildrenDrivenMutableTree

Package class diagram package ChildrenDrivenMutableTree
java.lang.Object
  extended by org.melati.util.ChildrenDrivenMutableTree

public class ChildrenDrivenMutableTree
extends Object

A tree of DefaultMutableTreeNodes, the userObjects of which are Treeable objects which supply their own getChildren() functions. This is used to build the tree of DefaultMutableTreeNodes.

It also allows you to search the subtree for a particular Treeable object and returns the corresponding DefaultMutableTreeNode object if one exists.

Since:
04/10/2000
Author:
Myles Chippendale
See Also:
DefaultMutableTreeNode

Field Summary
static Enumeration EMPTY_ENUMERATION
          An enumeration that is always empty.
protected  DefaultMutableTreeNode root
          root node
 
Constructor Summary
ChildrenDrivenMutableTree()
          Constructor.
ChildrenDrivenMutableTree(Treeable userObject)
          Constructor.
 
Method Summary
 Enumeration breadthFirstEnumeration()
           
 void buildTree()
          Compute the children.
 void buildTree(Enumeration<DefaultMutableTreeNode> nodes)
          Compute the children given the nodes.
 Enumeration depthFirstEnumeration()
           
 DefaultMutableTreeNode getRoot()
           
 DefaultMutableTreeNode getTreeNodeFor(Treeable search)
          Find a node in a tree.
 Enumeration postorderEnumeration()
          Return an enumeration of nodes in postorder, whatever that means.
 Enumeration preorderEnumeration()
          Return an enumeration of nodes in preorder, whatever that means.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ENUMERATION

public static final Enumeration EMPTY_ENUMERATION
An enumeration that is always empty. This is used when an enumeration of a leaf node's children is requested.


root

protected DefaultMutableTreeNode root
root node

Constructor Detail

ChildrenDrivenMutableTree

public ChildrenDrivenMutableTree()
Constructor.


ChildrenDrivenMutableTree

public ChildrenDrivenMutableTree(Treeable userObject)
Constructor.

Parameters:
userObject - the root
Method Detail

buildTree

public void buildTree()
Compute the children.


buildTree

public void buildTree(Enumeration<DefaultMutableTreeNode> nodes)
Compute the children given the nodes.

Parameters:
nodes - an Enumeration of nodes

getTreeNodeFor

public DefaultMutableTreeNode getTreeNodeFor(Treeable search)
Find a node in a tree.

Parameters:
search - the node object
Returns:
a tree node

getRoot

public DefaultMutableTreeNode getRoot()
Returns:
the root

preorderEnumeration

public Enumeration preorderEnumeration()
Return an enumeration of nodes in preorder, whatever that means.

Root is first node. What is the difference from breadth first?

Returns:
the nodes

postorderEnumeration

public Enumeration postorderEnumeration()
Return an enumeration of nodes in postorder, whatever that means.

Leftmost leaf is first. What is the difference from depth first?

Returns:
the nodes

breadthFirstEnumeration

public Enumeration breadthFirstEnumeration()
Returns:
an enumeration of nodes in breadth first order.

depthFirstEnumeration

public Enumeration depthFirstEnumeration()
Returns:
an enumeration of nodes in depth first order.


Copyright © 2000-2010 PanEris. All Rights Reserved.