Class HierarchyTreeModel<T>

java.lang.Object
com.macrofocus.hierarchy.swing.HierarchyTreeModel<T>
All Implemented Interfaces:
TreeModel

public class HierarchyTreeModel<T> extends Object implements TreeModel
  • Constructor Details

    • HierarchyTreeModel

      public HierarchyTreeModel(Hierarchy<T> hierarchy)
  • Method Details

    • getRoot

      public Object getRoot()
      Specified by:
      getRoot in interface TreeModel
    • getChild

      public T getChild(Object parent, int index)
      Specified by:
      getChild in interface TreeModel
    • getChildCount

      public int getChildCount(Object parent)
      Specified by:
      getChildCount in interface TreeModel
    • isLeaf

      public boolean isLeaf(Object node)
      Specified by:
      isLeaf in interface TreeModel
    • getIndexOfChild

      public int getIndexOfChild(Object parent, Object child)
      Specified by:
      getIndexOfChild in interface TreeModel
    • valueForPathChanged

      public void valueForPathChanged(TreePath path, Object newValue)
      Specified by:
      valueForPathChanged in interface TreeModel
    • addTreeModelListener

      public void addTreeModelListener(TreeModelListener l)
      Specified by:
      addTreeModelListener in interface TreeModel
    • removeTreeModelListener

      public void removeTreeModelListener(TreeModelListener l)
      Specified by:
      removeTreeModelListener in interface TreeModel
    • notifyNodesAdded

      protected void notifyNodesAdded(T parent, int index, T child)
    • notifyNodesChanged

      protected void notifyNodesChanged(T child)
    • notifyNodesRemoved

      protected void notifyNodesRemoved(T parent, int index, T child)
    • notifyStructureChanged

      public void notifyStructureChanged()
    • getPathToRoot

      public 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 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 for
      depth - 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