org.progeeks.graph.swing
Class RootedTreeViewModel

java.lang.Object
  extended by org.progeeks.util.swing.AbstractTreeModel
      extended by org.progeeks.graph.swing.RootedTreeViewModel
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class RootedTreeViewModel
extends AbstractTreeModel

Wraps a RootedTree implementation in an implementation of TreeModel. If the RootedTree contains or is an ObservableGraph then it is listened to for tree changes. (not yet implemented) The children are automatically sorted and so must implement comparable that will work with their siblings. This behavior may be able to be overridden in the future.

Version:
$Revision: 1.15 $
Author:
Paul Speed

Nested Class Summary
protected  class RootedTreeViewModel.GraphObserver
           
 
Field Summary
static java.lang.String NULL_ROOT
          Constant returned as the root when there is no RootedTree.
 
Constructor Summary
RootedTreeViewModel()
           
 
Method Summary
protected  void clearCache()
           
protected  void fireTreeNodesChanged(javax.swing.event.TreeModelEvent event)
           
protected  void fireTreeNodesInserted(javax.swing.event.TreeModelEvent event)
           
protected  void fireTreeNodesRemoved(javax.swing.event.TreeModelEvent event)
           
protected  void fireTreeStructureChanged(javax.swing.event.TreeModelEvent event)
           
 java.util.List getChildList(java.lang.Object parent)
          Returns a List of child nodes for the specified parent.
 java.util.Comparator getComparator()
          Returns the current comparator used to sort the children.
 java.lang.Object getRoot()
           
 com.phoenixst.plexus.RootedTree getRootedTree()
           
 javax.swing.tree.TreePath getTreePath(java.lang.Object node)
          Returns a TreePath for the specified node based on the parent child relationship defined by the RootedTree.
protected  boolean hasChildren(java.lang.Object parent)
          Optimized method for returning whether or not a node has children without having to retrieve the whole child list and sort it.
 boolean isLeaf(java.lang.Object node)
          Returns true if the specified node is a leaf.
 void setComparator(java.util.Comparator comparator)
          Sets a comparator to use when sorting the tree nodes.
 void setRootedTree(com.phoenixst.plexus.RootedTree tree)
           
 
Methods inherited from class org.progeeks.util.swing.AbstractTreeModel
addTreeModelListener, getChild, getChildCount, getIndexOfChild, getListeners, removeTreeModelListener, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_ROOT

public static final java.lang.String NULL_ROOT
Constant returned as the root when there is no RootedTree. JTree, etc. is happier this way.

See Also:
Constant Field Values
Constructor Detail

RootedTreeViewModel

public RootedTreeViewModel()
Method Detail

setRootedTree

public void setRootedTree(com.phoenixst.plexus.RootedTree tree)

getRootedTree

public com.phoenixst.plexus.RootedTree getRootedTree()

setComparator

public void setComparator(java.util.Comparator comparator)
Sets a comparator to use when sorting the tree nodes. If this is null then the children are expected to be Comparable.


getComparator

public java.util.Comparator getComparator()
Returns the current comparator used to sort the children.


getTreePath

public javax.swing.tree.TreePath getTreePath(java.lang.Object node)
Returns a TreePath for the specified node based on the parent child relationship defined by the RootedTree.


getRoot

public java.lang.Object getRoot()

getChildList

public java.util.List getChildList(java.lang.Object parent)
Description copied from class: AbstractTreeModel
Returns a List of child nodes for the specified parent. This is an optional operation and may throw UnsupportedOperationException.

Overrides:
getChildList in class AbstractTreeModel

hasChildren

protected boolean hasChildren(java.lang.Object parent)
Optimized method for returning whether or not a node has children without having to retrieve the whole child list and sort it.


isLeaf

public boolean isLeaf(java.lang.Object node)
Returns true if the specified node is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Overrides:
isLeaf in class AbstractTreeModel

clearCache

protected void clearCache()

fireTreeNodesChanged

protected void fireTreeNodesChanged(javax.swing.event.TreeModelEvent event)
Overrides:
fireTreeNodesChanged in class AbstractTreeModel

fireTreeNodesInserted

protected void fireTreeNodesInserted(javax.swing.event.TreeModelEvent event)
Overrides:
fireTreeNodesInserted in class AbstractTreeModel

fireTreeNodesRemoved

protected void fireTreeNodesRemoved(javax.swing.event.TreeModelEvent event)
Overrides:
fireTreeNodesRemoved in class AbstractTreeModel

fireTreeStructureChanged

protected void fireTreeStructureChanged(javax.swing.event.TreeModelEvent event)
Overrides:
fireTreeStructureChanged in class AbstractTreeModel


Copyright © 2002-2003 Paul Speed. All Rights Reserved.