easik.sketch.util
Class SketchAdapter.JGraphListener

java.lang.Object
  extended by easik.sketch.util.SketchAdapter.JGraphListener
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, org.jgraph.event.GraphModelListener
Enclosing class:
SketchAdapter

private class SketchAdapter.JGraphListener
extends java.lang.Object
implements org.jgraph.event.GraphModelListener, java.io.Serializable

Inner class listening to the GraphModel. If something is changed in the GraphModel, this Listener gets notified and propagates the change back to the JGraphT graph, if it didn't originate there.

If this change contains changes that would make this an illegal JGraphT graph, like adding an edge that is incident with only one vertex, the illegal parts of the change are undone.


Field Summary
private  Sketch _ourSketch
          The sketch
 
Constructor Summary
SketchAdapter.JGraphListener(Sketch inSketch)
          Default constructor
 
Method Summary
private  void filterEdgesAndVertices(java.lang.Object[] allCells, java.util.Set jEdges, java.util.Set jVertices)
          Filters an array of JGraph GraphCell objects into edges and vertices.
 void graphChanged(org.jgraph.event.GraphModelEvent e)
          This method is called for all JGraph changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ourSketch

private Sketch _ourSketch
The sketch

Constructor Detail

SketchAdapter.JGraphListener

public SketchAdapter.JGraphListener(Sketch inSketch)
Default constructor

Parameters:
inSketch - The sketch
Method Detail

graphChanged

public void graphChanged(org.jgraph.event.GraphModelEvent e)
This method is called for all JGraph changes.

Specified by:
graphChanged in interface org.jgraph.event.GraphModelListener
Parameters:
e -

filterEdgesAndVertices

private void filterEdgesAndVertices(java.lang.Object[] allCells,
                                    java.util.Set jEdges,
                                    java.util.Set jVertices)
Filters an array of JGraph GraphCell objects into edges and vertices. Ports and 'groups' are thrown away.

Parameters:
allCells - Array of cells to be filtered. These are just plain Objects in principle, but if they aren't GraphCells we can't detect what they are. So we ignore the non-GraphCell elements.
jEdges - Set to which all edges are added.
jVertices - Set to which all vertices are added.