samples.preview_new_graphdraw.iter
Class UpdatableIterableLayout

java.lang.Object
  extended by samples.preview_new_graphdraw.iter.IterableLayout
      extended by samples.preview_new_graphdraw.iter.UpdatableIterableLayout
All Implemented Interfaces:
LayoutEmitter
Direct Known Subclasses:
SpringLayout, UnmovingIterableLayout

public abstract class UpdatableIterableLayout
extends IterableLayout

Author:
danyelf

Field Summary
 
Fields inherited from class samples.preview_new_graphdraw.iter.IterableLayout
currentLayout, returnableLayout
 
Constructor Summary
UpdatableIterableLayout()
           
 
Method Summary
protected  VisEdge addVisEdge(Edge e)
          Creates and returns a default VisEdge based on e.
protected  VisVertex addVisVertex(Vertex v)
          Creates and returns a default VisVertex based on v.
protected  void cleanupReferences(Graph g)
          This OPTIONAL OPTIMIZATION allows the java garbage collector to work.
static Pair getSymmetricDifference(Set set1, Set set2)
          Returns a pair consisting of two collections: set1 - set2, and set2-set1.
protected  void removeEdge(Edge e)
          Removes e from the layout.
protected  void removeVertex(Vertex v)
          Removes v from the layout.
protected  void updateGraph(Pair oldAndNewVertices, Pair oldAndNewEdges)
          This DEFAULT IMPLEMENTATION immediately removes all OLD items, and immediate creates new items for the NEW.
 void updateGraphToMatch(Graph g)
          Updates the stored set of of vertices and edges to match the input graph.
 
Methods inherited from class samples.preview_new_graphdraw.iter.IterableLayout
advance, calculate, emit, getScreenSize, getVisEdge, getVisVertex, initializeLocationsFromLayout, isFinite, iterationsAreDone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdatableIterableLayout

public UpdatableIterableLayout()
Method Detail

updateGraphToMatch

public void updateGraphToMatch(Graph g)
Updates the stored set of of vertices and edges to match the input graph. This trivial default implementation removes all the vertices in the set that aren't in g, and calls new VisVertex for each that should be. Calls updateGraph and cleanupReferences. A reasonable implementation should probably care about internal data structures that may need to be updated.

Parameters:
g -

cleanupReferences

protected void cleanupReferences(Graph g)
This OPTIONAL OPTIMIZATION allows the java garbage collector to work. In particular, it ensures that all the vertices in the visVertexMap are in the CURRENT graph, not in some past graph. (Yes, I think it's a brutal and hackish way to solve this problem. I guess I could index by the non-public "id" field of the vertex, but that's probably unfair.)


updateGraph

protected void updateGraph(Pair oldAndNewVertices,
                           Pair oldAndNewEdges)
This DEFAULT IMPLEMENTATION immediately removes all OLD items, and immediate creates new items for the NEW. Calls createVisVertex and createVisEdge to handle the new locations. Override if you don't need them.

Parameters:
oldAndNewVertices -
oldAndNewVertices -

removeVertex

protected void removeVertex(Vertex v)
Removes v from the layout. Override to do something different. (For example, if you want vertices to resurface later where they currently are, then override this method to do nothing.)


removeEdge

protected void removeEdge(Edge e)
Removes e from the layout. Override to do something different. (For example, if you want edges to resurface later where they currently are, then override this method to do nothing.)


addVisEdge

protected VisEdge addVisEdge(Edge e)
Creates and returns a default VisEdge based on e. Note that if you have overridden removeEdge, then an entry MAY ALREADY EXIST! (This version does not check) // TODO THIS VERSION SHOUDL CHECK

Parameters:
e -
Returns:

addVisVertex

protected VisVertex addVisVertex(Vertex v)
Creates and returns a default VisVertex based on v. Default implementation places the new vertex at a RANDOM location. Override to place someplace more sensible. Note that if you have overridden removeEdge, then an entry MAY ALREADY EXIST! (This version does not check) // TODO THIS VERSION SHOUDL CHECK


getSymmetricDifference

public static Pair getSymmetricDifference(Set set1,
                                          Set set2)
Returns a pair consisting of two collections: set1 - set2, and set2-set1.