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 voidaddTreeModelListener(javax.swing.event.TreeModelListener l)TgetChild(java.lang.Object parent, int index)intgetChildCount(java.lang.Object parent)intgetIndexOfChild(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.ObjectgetRoot()booleanisLeaf(java.lang.Object node)protected voidnotifyNodesAdded(T parent, int index, T child)protected voidnotifyNodesChanged(T child)protected voidnotifyNodesRemoved(T parent, int index, T child)voidnotifyStructureChanged()voidremoveTreeModelListener(javax.swing.event.TreeModelListener l)voidvalueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
-
-
-
Method Detail
-
getRoot
public java.lang.Object getRoot()
- Specified by:
getRootin interfacejavax.swing.tree.TreeModel
-
getChild
public T getChild(java.lang.Object parent, int index)
- Specified by:
getChildin interfacejavax.swing.tree.TreeModel
-
getChildCount
public int getChildCount(java.lang.Object parent)
- Specified by:
getChildCountin interfacejavax.swing.tree.TreeModel
-
isLeaf
public boolean isLeaf(java.lang.Object node)
- Specified by:
isLeafin interfacejavax.swing.tree.TreeModel
-
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)- Specified by:
getIndexOfChildin interfacejavax.swing.tree.TreeModel
-
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)- Specified by:
valueForPathChangedin interfacejavax.swing.tree.TreeModel
-
addTreeModelListener
public void addTreeModelListener(javax.swing.event.TreeModelListener l)
- Specified by:
addTreeModelListenerin interfacejavax.swing.tree.TreeModel
-
removeTreeModelListener
public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
- Specified by:
removeTreeModelListenerin 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
-
-