Package ca.spatial.util
Class PathTree
java.lang.Object
javax.swing.tree.DefaultTreeModel
ca.spatial.util.PathTree
- All Implemented Interfaces:
Serializable
,TreeModel
A class that creates and manipulates sorted trees.
This is useful for displaying trees of accounts or reports.
Nodes are added by specifying a label. The label is split into parts by the separator character, and nodes are added hierarchicaly for each name part. The object is added to the leaf node with the label of the last part of the name.
Leaf nodes may be retrieved by using the full label.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLabelInOrder(String label, Object object)
boolean
Determine if a label exists in the tree.static DefaultMutableTreeNode
findObject(Object comp)
static Object
findObject(DefaultMutableTreeNode node, Object comp)
getLabel(DefaultMutableTreeNode node)
Return the path string for a given node.static String
getLabel(DefaultMutableTreeNode node, String sep)
Return the path string for an array of TreeNode's.static String
Return the path string for a given tree path.getLastPathComponent(String label, boolean folder)
Get the last node for this label.Get a vector containing the names of all the terminal paths that are located under the selected node.Get a vector containing the objects at all the terminal paths that are located under the selected node.Get a tree path for a particular labelvoid
insertInOrder(DefaultMutableTreeNode parent, DefaultMutableTreeNode node)
Insert a node under parent in sorted order according to tokenvoid
insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index)
Override the superclass method to ensure that duplicates are not permitted.Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getRoot, getTreeModelListeners, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
-
Constructor Details
-
PathTree
public PathTree()Create a new empty tree model, with a top level folder name of 'Top', and a default separator character of '.' -
PathTree
Create a new empty tree model, with a top level folder name of 'Top', and a default separator character of '.'.- Parameters:
label
- the name for the top level nodeseparator
- the character used to split labels in to parts for intermidate nodes.
-
-
Method Details
-
exists
Determine if a label exists in the tree. The label is split in to parts using the separator character, and the parts are matched against the nodes in the tree. Returns true if the label can be matched in the tree.- Parameters:
label
- the label to search forfolder
- if true then allow matches where the last part of the label is not a leaf node.
-
addLabel
-
addLabelInOrder
-
addFolder
-
insertInOrder
Insert a node under parent in sorted order according to token -
insertNodeInto
Override the superclass method to ensure that duplicates are not permitted.- Overrides:
insertNodeInto
in classDefaultTreeModel
-
getLabel
Return the path string for a given node. -
getLabel
-
getLabel
Return the path string for a given tree path. -
getLabel
Return the path string for an array of TreeNode's. Ignore the root node label. -
getLabel
-
getPath
Get a tree path for a particular label -
getLastPathComponent
Get the last node for this label. The folder parameter specifies if you are looking for a folder or a terminal. -
findChild
-
findObject
-
findObject
-
getLeafNames
Get a vector containing the names of all the terminal paths that are located under the selected node. -
getLeafNames
-
getLeafObjects
Get a vector containing the objects at all the terminal paths that are located under the selected node. -
getLeafObjects
-
getTipEnumerator
-
getCommonLabel
-