public class TreeUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DESTINATION_TREE
This indicates that the destination tree will be used
|
static int |
SOURCE_TREE
This indicates that the source tree will be used
|
Constructor and Description |
---|
TreeUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
CollapseJTree(javax.swing.JTree aTree)
Collapses all nodes of
aTree and all his descendants |
static javax.swing.tree.TreePath |
ConvertTreeNodeToPath(javax.swing.tree.DefaultMutableTreeNode aNode)
Returns the path having as last component
aNode |
static void |
ExpandJTree(javax.swing.JTree aTree)
Expands all nodes of
aTree |
static javax.swing.tree.TreePath |
findTreePath(javax.swing.JTree tree,
javax.swing.tree.DefaultMutableTreeNode[] nodes)
Finds and returns the
TreePath in tree specified by given
array of DefaultMutableTreeNode objects nodes |
static javax.swing.tree.TreePath |
findTreePathByName(javax.swing.JTree tree,
java.util.ArrayList<java.lang.String> names) |
static javax.swing.tree.TreePath |
findTreePathByName(javax.swing.JTree tree,
java.lang.String[] names)
Finds and returns the
TreePath in tree specified by given
array of String objects names |
static int |
getTotalDescendantsHeight(javax.swing.JTree aTree,
javax.swing.tree.DefaultMutableTreeNode aNode)
Calculates and returns the total height in pixels of all the visible
descendants of
aNode . |
static javax.swing.JTree |
randomJTree(int maxDepth,
int maxChildCount)
This is a test method.
Returns a random
JTree that has maximum tree depth maxDepth |
public static final int SOURCE_TREE
public static final int DESTINATION_TREE
public static javax.swing.tree.TreePath ConvertTreeNodeToPath(javax.swing.tree.DefaultMutableTreeNode aNode)
aNode
aNode
- A TreeNodeaNode
as last component.
Returns null
if aNode
is nullpublic static int getTotalDescendantsHeight(javax.swing.JTree aTree, javax.swing.tree.DefaultMutableTreeNode aNode)
aNode
.
Warning: aNode
should belong to aTree
aTree
- An instance of Jtree
aNode
- An instance of DefaultMutableTreeNode
public static void ExpandJTree(javax.swing.JTree aTree)
aTree
aTree
- An instance of JTree
public static void CollapseJTree(javax.swing.JTree aTree)
aTree
and all his descendantsaTree
- An instance of JTree
public static javax.swing.JTree randomJTree(int maxDepth, int maxChildCount)
JTree
that has maximum tree depth maxDepth
maxDepth
- An integer indicating the maximum tree depthJTree
public static javax.swing.tree.TreePath findTreePath(javax.swing.JTree tree, javax.swing.tree.DefaultMutableTreeNode[] nodes)
TreePath
in tree
specified by given
array of DefaultMutableTreeNode
objects nodes
tree
- An instance of JTree
nodes
- An array of DefaultMutableTreeNode objects characterizing the TreePathTreePath
from tree
or null if
no such TreePath existspublic static javax.swing.tree.TreePath findTreePathByName(javax.swing.JTree tree, java.util.ArrayList<java.lang.String> names)
public static javax.swing.tree.TreePath findTreePathByName(javax.swing.JTree tree, java.lang.String[] names)
TreePath
in tree
specified by given
array of String objects names
tree
- An instance of JTree
names
- An array of String objects characterizing the TreePathTreePath
from tree
or null if
no such TreePath exists