y.view
Class GraphTreeModel

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

public class GraphTreeModel
extends Object
implements TreeModel

This class represents a flat tree model for a graph. The treemodel consist of one root node whose children are the nodes of the graph.


Constructor Summary
GraphTreeModel(Graph graph)
          Creates a model for a given Graph
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
          Adds a listener to this model.
 Object getChild(Object parent, int index)
          If parent is the root node then then node at index in the graph is returned.
 int getChildCount(Object parent)
          If parent is the root then the number of nodes in the graph is returned.
 int getIndexOfChild(Object parent, Object child)
          Returns the index of the node in the graph.
 Object getRoot()
          Returns the dummy root node.
 boolean isLeaf(Object node)
          Whether or not the node is a leaf in the tree.
 void postEvent()
          Sends out a TreeModelEvent to all registered listeners.
 void removeTreeModelListener(TreeModelListener l)
          Removes a listener from this model.
 void valueForPathChanged(TreePath path, Object newValue)
          Does nothing yet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphTreeModel

public GraphTreeModel(Graph graph)
Creates a model for a given Graph

Method Detail

getChild

public Object getChild(Object parent,
                       int index)
If parent is the root node then then node at index in the graph is returned.

Specified by:
getChild in interface TreeModel

getChildCount

public int getChildCount(Object parent)
If parent is the root then the number of nodes in the graph is returned. Otherwise return 0.

Specified by:
getChildCount in interface TreeModel

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Returns the index of the node in the graph.

Specified by:
getIndexOfChild in interface TreeModel

getRoot

public Object getRoot()
Returns the dummy root node.

Specified by:
getRoot in interface TreeModel

isLeaf

public boolean isLeaf(Object node)
Whether or not the node is a leaf in the tree.

Specified by:
isLeaf in interface TreeModel

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Adds a listener to this model.

Specified by:
addTreeModelListener in interface TreeModel

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Removes a listener from this model.

Specified by:
removeTreeModelListener in interface TreeModel

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Does nothing yet.

Specified by:
valueForPathChanged in interface TreeModel

postEvent

public void postEvent()
Sends out a TreeModelEvent to all registered listeners.


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

2003