y.view.hierarchy
Class HierarchyTreeModel

java.lang.Object
  |
  +--y.view.hierarchy.HierarchyTreeModel
All Implemented Interfaces:
TreeModel

public class HierarchyTreeModel
extends Object
implements TreeModel

This class represents a tree model view of a graph hierarchy managed by HierarchyManager. The tree model can be used with a JTree to visualize the nodes within the graph hierarchy.

The root of the tree model will be the root graph of the graph hierarchy. Any other element of the tree model will be a node within a graph within the hierarchy. Regular nodes within the graph hierarchy that are not folder nodes

Whenever the graph hierarchy within the associated hierarchy manager changes the tree model will fire corresponding tree model events.


Constructor Summary
HierarchyTreeModel(HierarchyManager hierarchy)
          Creates a new instance of HierarchyTreeModel for the nodes within the given HierarchyManager.
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
           
static Comparator createLabelTextComparator()
          Returns a comparator that compares Graph2D nodes by their label text
static Comparator createNodeStateComparator(HierarchyManager hierarchy)
          Returns a comparator that uses the hierarchical state of the nodes as a first criterum.
static Comparator createToStringComparator()
          Returns a comparator that compares the nodes in the tree by their default string value.
 Object getChild(Object parent, int index)
           
 Comparator getChildComparator()
          Returns the comparator used to sort the children in each folder.
 int getChildCount(Object parent)
           
 int getIndexOfChild(Object parent, Object child)
           
 Object getRoot()
           
 boolean isLeaf(Object node)
           
 void removeTreeModelListener(TreeModelListener l)
           
 void setChildComparator(Comparator c)
          Sets a comparator used to sort the children in each folder.
 void valueForPathChanged(TreePath path, Object newValue)
          This method propagates the result of the inline editor to the label of the node in the Graph2D, as long as there is one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HierarchyTreeModel

public HierarchyTreeModel(HierarchyManager hierarchy)
Creates a new instance of HierarchyTreeModel for the nodes within the given HierarchyManager.

Method Detail

setChildComparator

public void setChildComparator(Comparator c)
Sets a comparator used to sort the children in each folder.

By default no comparator is set.


getChildComparator

public Comparator getChildComparator()
Returns the comparator used to sort the children in each folder.


addTreeModelListener

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

getChild

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

getChildCount

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

getIndexOfChild

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

getRoot

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

isLeaf

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

removeTreeModelListener

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

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
This method propagates the result of the inline editor to the label of the node in the Graph2D, as long as there is one. Finally it updates all views, which might be affected by this change.

Specified by:
valueForPathChanged in interface TreeModel

createToStringComparator

public static Comparator createToStringComparator()
Returns a comparator that compares the nodes in the tree by their default string value.


createLabelTextComparator

public static Comparator createLabelTextComparator()
Returns a comparator that compares Graph2D nodes by their label text


createNodeStateComparator

public static Comparator createNodeStateComparator(HierarchyManager hierarchy)
Returns a comparator that uses the hierarchical state of the nodes as a first criterum. GRoup nodes and folder nodes will come first, then normal nodes. If two nodes have the same state then the label text of these nodes decides their order.


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003