edu.northwestern.at.utils.swing
Class TreeUtils

java.lang.Object
  extended by edu.northwestern.at.utils.swing.TreeUtils

public class TreeUtils
extends java.lang.Object

Swing tree utilities.


Method Summary
static boolean compare(javax.swing.tree.TreeNode node1, javax.swing.tree.TreeNode node2)
          Compares two trees.
static void dumpTree(javax.swing.tree.TreeNode node, int level)
          Dumps a tree to stdout for debugging.
static java.util.Collection getNodes(javax.swing.tree.TreeNode node)
          Gets all the nodes in a tree.
static java.util.ArrayList pruneDescendantsFromTreePathList(javax.swing.tree.TreeModel model, javax.swing.tree.TreePath[] treePathList)
          Prunes descendants from a tree path list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pruneDescendantsFromTreePathList

public static java.util.ArrayList pruneDescendantsFromTreePathList(javax.swing.tree.TreeModel model,
                                                                   javax.swing.tree.TreePath[] treePathList)
Prunes descendants from a tree path list.

Any elements of the list which are descendants of other elements of the list are removed.

Parameters:
model - A tree model.
treePathList - An array of tree paths in the model.
Returns:
A list of the nodes for the pruned list (the last path components of the tree paths in the pruned list).

compare

public static boolean compare(javax.swing.tree.TreeNode node1,
                              javax.swing.tree.TreeNode node2)
Compares two trees.

Parameters:
node1 - Root of first tree.
node2 - Root of second tree.
Returns:
True if trees are equal.

getNodes

public static java.util.Collection getNodes(javax.swing.tree.TreeNode node)
Gets all the nodes in a tree.

Parameters:
node - The root of the tree.
Returns:
A collection of all the tree's nodes.

dumpTree

public static void dumpTree(javax.swing.tree.TreeNode node,
                            int level)
Dumps a tree to stdout for debugging.

Parameters:
node - Root of tree.
level - Indentation level.