Search this API

y.view
Class GraphTreeModel

java.lang.Object
  extended by y.view.GraphTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class GraphTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel

This class represents a flat tree model for a graph. The model consists of one root node whose children are the nodes of the graph. For hierarchically nested graph structures use HierarchyTreeModel instead.

 
Your browser does not support SVG content.

Constructor Summary
GraphTreeModel(Graph graph)
          Creates a model for a given Graph
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          Adds a listener to this model.
 java.lang.Object getChild(java.lang.Object parent, int index)
          If parent is the root node then then node at index in the graph is returned.
 int getChildCount(java.lang.Object parent)
          If parent is the root then the number of nodes in the graph is returned.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Returns the index of the node in the graph.
 java.lang.Object getRoot()
          Returns the dummy root node.
 boolean isLeaf(java.lang.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(javax.swing.event.TreeModelListener l)
          Removes a listener from this model.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.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 java.lang.Object getChild(java.lang.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 javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.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 javax.swing.tree.TreeModel

getIndexOfChild

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

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

getRoot

public java.lang.Object getRoot()
Returns the dummy root node.

Specified by:
getRoot in interface javax.swing.tree.TreeModel

isLeaf

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

Specified by:
isLeaf in interface javax.swing.tree.TreeModel

addTreeModelListener

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

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

removeTreeModelListener

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

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Does nothing yet.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

postEvent

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


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