edu.uci.ics.jung.visualization.layout
Class PersistentLayoutImpl<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.LayoutDecorator<V,E>
      extended by edu.uci.ics.jung.visualization.layout.ObservableCachingLayout<V,E>
          extended by edu.uci.ics.jung.visualization.layout.PersistentLayoutImpl<V,E>
All Implemented Interfaces:
Layout<V,E>, IterativeContext, PersistentLayout<V,E>, Caching, ChangeEventSupport, org.apache.commons.collections15.Transformer<V,Point2D>

public class PersistentLayoutImpl<V,E>
extends ObservableCachingLayout<V,E>
implements PersistentLayout<V,E>, ChangeEventSupport, Caching

Implementation of PersistentLayout. Defers to another layout until 'restore' is called, then it uses the saved vertex locations

Author:
Tom Nelson

Nested Class Summary
static class PersistentLayoutImpl.RandomPointFactory
           
 
Nested classes/interfaces inherited from interface edu.uci.ics.jung.visualization.layout.PersistentLayout
PersistentLayout.Point
 
Field Summary
protected  Set<V> dontmove
          a collection of Vertices that should not move
protected  boolean locked
          whether the graph is locked (stops the VisualizationViewer rendering thread)
protected  Map<V,PersistentLayout.Point> map
          a container for Vertices
 
Fields inherited from class edu.uci.ics.jung.visualization.layout.ObservableCachingLayout
changeSupport, locationMap
 
Fields inherited from class edu.uci.ics.jung.algorithms.layout.LayoutDecorator
delegate
 
Constructor Summary
PersistentLayoutImpl(Layout<V,E> layout)
          create an instance with a passed layout create containers for graph components
 
Method Summary
 boolean done()
          Returns true if this iterative process is finished, and false otherwise.
protected  void initializeLocation(V v, Point2D coord, Dimension d)
          Sets persisted location for a vertex within the dimensions of the space.
protected  void initializeLocations()
          This method calls initialize_local_vertex for each vertex, and also adds initial coordinate information for each vertex.
 void lock(boolean locked)
           
 void lock(V v, boolean state)
          Sets a flag which fixes this vertex in place.
 void persist(String fileName)
          save the Vertex locations to a file
 void restore(String fileName)
          Restore the graph Vertex locations from a file
 
Methods inherited from class edu.uci.ics.jung.visualization.layout.ObservableCachingLayout
addChangeListener, clear, fireStateChanged, getChangeListeners, init, initialize, removeChangeListener, setGraph, setLocation, step, transform
 
Methods inherited from class edu.uci.ics.jung.algorithms.layout.LayoutDecorator
getDelegate, getGraph, getSize, isLocked, reset, setDelegate, setInitializer, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.uci.ics.jung.algorithms.layout.Layout
getGraph, getSize, initialize, isLocked, reset, setGraph, setInitializer, setLocation, setSize
 
Methods inherited from interface org.apache.commons.collections15.Transformer
transform
 
Methods inherited from interface edu.uci.ics.jung.visualization.util.ChangeEventSupport
addChangeListener, fireStateChanged, getChangeListeners, removeChangeListener
 
Methods inherited from interface edu.uci.ics.jung.visualization.util.Caching
clear, init
 

Field Detail

map

protected Map<V,PersistentLayout.Point> map
a container for Vertices


dontmove

protected Set<V> dontmove
a collection of Vertices that should not move


locked

protected boolean locked
whether the graph is locked (stops the VisualizationViewer rendering thread)

Constructor Detail

PersistentLayoutImpl

public PersistentLayoutImpl(Layout<V,E> layout)
create an instance with a passed layout create containers for graph components

Parameters:
layout -
Method Detail

initializeLocations

protected void initializeLocations()
This method calls initialize_local_vertex for each vertex, and also adds initial coordinate information for each vertex. (The vertex's initial location is set by calling initializeLocation.


initializeLocation

protected void initializeLocation(V v,
                                  Point2D coord,
                                  Dimension d)
Sets persisted location for a vertex within the dimensions of the space. If the vertex has not been persisted, sets a random location. If you want to initialize in some different way, override this method.

Parameters:
v -
coord -
d -

persist

public void persist(String fileName)
             throws IOException
save the Vertex locations to a file

Specified by:
persist in interface PersistentLayout<V,E>
Parameters:
fileName - the file to save to
Throws:
an - IOException if the file cannot be used
IOException

restore

public void restore(String fileName)
             throws IOException,
                    ClassNotFoundException
Restore the graph Vertex locations from a file

Specified by:
restore in interface PersistentLayout<V,E>
Parameters:
fileName - the file to use
Throws:
IOException - for file problems
ClassNotFoundException - for classpath problems

lock

public void lock(boolean locked)
Specified by:
lock in interface PersistentLayout<V,E>

done

public boolean done()
Description copied from interface: IterativeContext
Returns true if this iterative process is finished, and false otherwise.

Specified by:
done in interface IterativeContext
Overrides:
done in class ObservableCachingLayout<V,E>
See Also:
IterativeContext.done()

lock

public void lock(V v,
                 boolean state)
Description copied from interface: Layout
Sets a flag which fixes this vertex in place.

Specified by:
lock in interface Layout<V,E>
Overrides:
lock in class LayoutDecorator<V,E>
Parameters:
v - vertex
See Also:
Layout.lock(Object, boolean)


Copyright © 2009. All Rights Reserved.