com.jgraph.example
Class GraphSelectionDemo

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by com.jgraph.example.GraphSelectionDemo
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.swing.tree.TreeModel, org.jgraph.event.GraphModelListener

public class GraphSelectionDemo
extends javax.swing.tree.DefaultTreeModel
implements org.jgraph.event.GraphModelListener

With this example you'll learn how to listen to graph selection event, program graph selections and navigate accross the graph groups. This demo is is a bit like the GraphTreeModel demo. But this time, we synchronize the graph and the tree selection with two listeners. There are two issues actually. The first is that we should disable one listener when we programatically change its selection after the other listener receives a selection event (else we would fail in infinite loops). The other issue is navigating the graph and especially its group in order to get the equivalent tree selection. Also notice that ports should be handled like a special kind of group children.

Author:
rvalyi
See Also:
Serialized Form

Nested Class Summary
static class GraphSelectionDemo.GraphModelTreeNode
          See the GraphModelTree demo
static class GraphSelectionDemo.MyMouseListener
          Prevent from loosing the synchronisation after a graph element is dragged
static class GraphSelectionDemo.SyncGraphSelectionListener
           
static class GraphSelectionDemo.SyncTreeSelectionListener
           
 
Constructor Summary
GraphSelectionDemo(org.jgraph.graph.GraphModel model)
           
 
Method Summary
 void graphChanged(org.jgraph.event.GraphModelEvent e)
           
static void main(java.lang.String[] args)
           
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphSelectionDemo

public GraphSelectionDemo(org.jgraph.graph.GraphModel model)
Method Detail

main

public static void main(java.lang.String[] args)

graphChanged

public void graphChanged(org.jgraph.event.GraphModelEvent e)
Specified by:
graphChanged in interface org.jgraph.event.GraphModelListener