org.progeeks.graph.swing
Class SwingGraphSynchronizer

java.lang.Object
  extended by org.progeeks.graph.swing.SwingGraphSynchronizer
All Implemented Interfaces:
com.phoenixst.plexus.GraphListener, java.util.EventListener

public class SwingGraphSynchronizer
extends java.lang.Object
implements com.phoenixst.plexus.GraphListener

GraphListener that will forward graph changes to another graph. The tricky part is that it does the forwarding on the swing thread thus allowing changes to the souce graph to happen in a background thread. Furthermore, changes are queued up in the background to reduce background->swing message processing. On the swing thread, as many changes as possible are done before relinquishing control. Note: removal of edges is a weird case and so only works when using an ImmutableIdentityEdge based graph as source and target.

Version:
$Revision: 1.5 $
Author:
Paul Speed

Constructor Summary
SwingGraphSynchronizer()
           
SwingGraphSynchronizer(com.phoenixst.plexus.Graph target)
           
 
Method Summary
protected  void addChange(org.progeeks.graph.swing.SwingGraphSynchronizer.GraphChange change)
          Adds a change to the queue of changes waiting to be processed by the SwingCommand.
 void edgeAdded(com.phoenixst.plexus.GraphEvent event)
           
 void edgeRemoved(com.phoenixst.plexus.GraphEvent event)
           
protected  org.progeeks.graph.swing.SwingGraphSynchronizer.GraphChange[] getChanges()
          Returns all of the current changes as an array and clears the queue.
 com.phoenixst.plexus.Graph getTargetGraph()
           
 void nodeAdded(com.phoenixst.plexus.GraphEvent event)
           
 void nodeRemoved(com.phoenixst.plexus.GraphEvent event)
           
 void setTargetGraph(com.phoenixst.plexus.Graph target)
           
 void waitForPending()
          Waits for all current pending operations to complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingGraphSynchronizer

public SwingGraphSynchronizer()

SwingGraphSynchronizer

public SwingGraphSynchronizer(com.phoenixst.plexus.Graph target)
Method Detail

waitForPending

public void waitForPending()
                    throws java.lang.InterruptedException
Waits for all current pending operations to complete.

Throws:
java.lang.InterruptedException

setTargetGraph

public void setTargetGraph(com.phoenixst.plexus.Graph target)

getTargetGraph

public com.phoenixst.plexus.Graph getTargetGraph()

addChange

protected void addChange(org.progeeks.graph.swing.SwingGraphSynchronizer.GraphChange change)
Adds a change to the queue of changes waiting to be processed by the SwingCommand.


getChanges

protected org.progeeks.graph.swing.SwingGraphSynchronizer.GraphChange[] getChanges()
Returns all of the current changes as an array and clears the queue.


nodeAdded

public void nodeAdded(com.phoenixst.plexus.GraphEvent event)
Specified by:
nodeAdded in interface com.phoenixst.plexus.GraphListener

nodeRemoved

public void nodeRemoved(com.phoenixst.plexus.GraphEvent event)
Specified by:
nodeRemoved in interface com.phoenixst.plexus.GraphListener

edgeAdded

public void edgeAdded(com.phoenixst.plexus.GraphEvent event)
Specified by:
edgeAdded in interface com.phoenixst.plexus.GraphListener

edgeRemoved

public void edgeRemoved(com.phoenixst.plexus.GraphEvent event)
Specified by:
edgeRemoved in interface com.phoenixst.plexus.GraphListener


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