Class HierarchyTreeModel<T>

  • All Implemented Interfaces:
    javax.swing.tree.TreeModel

    public class HierarchyTreeModel<T>
    extends java.lang.Object
    implements javax.swing.tree.TreeModel
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HierarchyTreeModel

        public HierarchyTreeModel​(Hierarchy<T> hierarchy)
    • Method Detail

      • getRoot

        public java.lang.Object getRoot()
        Specified by:
        getRoot in interface javax.swing.tree.TreeModel
      • getChild

        public T getChild​(java.lang.Object parent,
                          int index)
        Specified by:
        getChild in interface javax.swing.tree.TreeModel
      • getChildCount

        public int getChildCount​(java.lang.Object parent)
        Specified by:
        getChildCount in interface javax.swing.tree.TreeModel
      • isLeaf

        public boolean isLeaf​(java.lang.Object node)
        Specified by:
        isLeaf in interface javax.swing.tree.TreeModel
      • getIndexOfChild

        public int getIndexOfChild​(java.lang.Object parent,
                                   java.lang.Object child)
        Specified by:
        getIndexOfChild in interface javax.swing.tree.TreeModel
      • valueForPathChanged

        public void valueForPathChanged​(javax.swing.tree.TreePath path,
                                        java.lang.Object newValue)
        Specified by:
        valueForPathChanged in interface javax.swing.tree.TreeModel
      • addTreeModelListener

        public void addTreeModelListener​(javax.swing.event.TreeModelListener l)
        Specified by:
        addTreeModelListener in interface javax.swing.tree.TreeModel
      • removeTreeModelListener

        public void removeTreeModelListener​(javax.swing.event.TreeModelListener l)
        Specified by:
        removeTreeModelListener in interface javax.swing.tree.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 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 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