Package com.macrofocus.hierarchy.swing
Class HierarchyTreeModel<T>
- java.lang.Object
-
- com.macrofocus.hierarchy.swing.HierarchyTreeModel<T>
-
- All Implemented Interfaces:
javax.swing.tree.TreeModel
public class HierarchyTreeModel<T> extends java.lang.Object implements javax.swing.tree.TreeModel
-
-
Constructor Summary
Constructors Constructor Description HierarchyTreeModel(Hierarchy<T> hierarchy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTreeModelListener(javax.swing.event.TreeModelListener l)
T
getChild(java.lang.Object parent, int index)
int
getChildCount(java.lang.Object parent)
int
getIndexOfChild(java.lang.Object parent, java.lang.Object child)
java.lang.Object[]
getPathToRoot(T aNode)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.protected java.lang.Object[]
getPathToRoot(T aNode, int depth)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.java.lang.Object
getRoot()
boolean
isLeaf(java.lang.Object node)
protected void
notifyNodesAdded(T parent, int index, T child)
protected void
notifyNodesChanged(T child)
protected void
notifyNodesRemoved(T parent, int index, T child)
void
notifyStructureChanged()
void
removeTreeModelListener(javax.swing.event.TreeModelListener l)
void
valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
-
-
-
Method Detail
-
getRoot
public java.lang.Object getRoot()
- Specified by:
getRoot
in interfacejavax.swing.tree.TreeModel
-
getChild
public T getChild(java.lang.Object parent, int index)
- Specified by:
getChild
in interfacejavax.swing.tree.TreeModel
-
getChildCount
public int getChildCount(java.lang.Object parent)
- Specified by:
getChildCount
in interfacejavax.swing.tree.TreeModel
-
isLeaf
public boolean isLeaf(java.lang.Object node)
- Specified by:
isLeaf
in interfacejavax.swing.tree.TreeModel
-
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
- Specified by:
getIndexOfChild
in interfacejavax.swing.tree.TreeModel
-
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
- Specified by:
valueForPathChanged
in interfacejavax.swing.tree.TreeModel
-
addTreeModelListener
public void addTreeModelListener(javax.swing.event.TreeModelListener l)
- Specified by:
addTreeModelListener
in interfacejavax.swing.tree.TreeModel
-
removeTreeModelListener
public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
- Specified by:
removeTreeModelListener
in interfacejavax.swing.tree.TreeModel
-
notifyNodesChanged
protected void notifyNodesChanged(T child)
-
notifyStructureChanged
public void notifyStructureChanged()
-
getPathToRoot
public java.lang.Object[] getPathToRoot(T aNode)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.- Parameters:
aNode
- the TreeNode to get the path for
-
getPathToRoot
protected java.lang.Object[] getPathToRoot(T aNode, int depth)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.- Parameters:
aNode
- the TreeNode to get the path fordepth
- an int giving the number of steps already taken towards the root (on recursive calls), used to size the returned array- Returns:
- an array of TreeNodes giving the path from the root to the specified node
-
-