Class PersistentLayoutImpl<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.layout.LayoutDecorator<V,E>
-
- edu.uci.ics.jung.visualization.layout.ObservableCachingLayout<V,E>
-
- edu.uci.ics.jung.visualization.layout.PersistentLayoutImpl<V,E>
-
- All Implemented Interfaces:
com.google.common.base.Function<V,java.awt.geom.Point2D>,Layout<V,E>,IterativeContext,LayoutEventSupport<V,E>,PersistentLayout<V,E>,Caching,ChangeEventSupport,java.util.function.Function<V,java.awt.geom.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPersistentLayoutImpl.RandomPointFactory<V>-
Nested classes/interfaces inherited from interface edu.uci.ics.jung.visualization.layout.PersistentLayout
PersistentLayout.Point
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<V>dontmovea collection of Vertices that should not moveprotected java.util.Map<V,PersistentLayout.Point>locationsa container for Verticesprotected booleanlockedwhether the graph is locked (stops the VisualizationViewer rendering thread)-
Fields inherited from class edu.uci.ics.jung.visualization.layout.ObservableCachingLayout
changeSupport
-
Fields inherited from class edu.uci.ics.jung.algorithms.layout.LayoutDecorator
delegate
-
-
Constructor Summary
Constructors Constructor Description PersistentLayoutImpl(Layout<V,E> layout)create an instance with a passed layout create containers for graph components
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandone()protected voidinitializeLocation(V v, java.awt.geom.Point2D coord)Sets persisted location for a vertex within the dimensions of the space.protected voidinitializeLocations()This method calls initialize_local_vertex for each vertex, and also adds initial coordinate information for each vertex.voidlock(boolean locked)voidlock(V v, boolean state)Locks or unlocks the specified vertex.voidpersist(java.lang.String fileName)save the Vertex locations to a filevoidrestore(java.lang.String fileName)Restore the graph Vertex locations from a file-
Methods inherited from class edu.uci.ics.jung.visualization.layout.ObservableCachingLayout
addChangeListener, addLayoutChangeListener, apply, clear, fireStateChanged, getChangeListeners, init, initialize, removeChangeListener, removeLayoutChangeListener, setGraph, setLocation, step
-
Methods inherited from class edu.uci.ics.jung.algorithms.layout.LayoutDecorator
getDelegate, getGraph, getSize, isLocked, reset, setDelegate, setInitializer, setSize, transform
-
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.visualization.util.ChangeEventSupport
addChangeListener, fireStateChanged, getChangeListeners, removeChangeListener
-
Methods inherited from interface edu.uci.ics.jung.algorithms.layout.Layout
getGraph, getSize, initialize, isLocked, reset, setGraph, setInitializer, setLocation, setSize
-
-
-
-
Field Detail
-
locations
protected java.util.Map<V,PersistentLayout.Point> locations
a container for Vertices
-
dontmove
protected java.util.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)
-
-
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, java.awt.geom.Point2D coord)
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- the vertex whose location is to be initializedcoord- the location
-
persist
public void persist(java.lang.String fileName) throws java.io.IOExceptionsave the Vertex locations to a file- Specified by:
persistin interfacePersistentLayout<V,E>- Parameters:
fileName- the file to save to- Throws:
java.io.IOException- if the file cannot be used
-
restore
public void restore(java.lang.String fileName) throws java.io.IOException, java.lang.ClassNotFoundExceptionRestore the graph Vertex locations from a file- Specified by:
restorein interfacePersistentLayout<V,E>- Parameters:
fileName- the file to use- Throws:
java.io.IOException- for file problemsjava.lang.ClassNotFoundException- for classpath problems
-
lock
public void lock(boolean locked)
- Specified by:
lockin interfacePersistentLayout<V,E>
-
done
public boolean done()
- Specified by:
donein interfaceIterativeContext- Overrides:
donein classObservableCachingLayout<V,E>- Returns:
trueif this iterative process is finished, andfalseotherwise.
-
lock
public void lock(V v, boolean state)
Description copied from interface:LayoutLocks or unlocks the specified vertex. Locking the vertex fixes it at its current position, so that it will not be affected by the layout algorithm. Unlocking it allows the layout algorithm to change the vertex's position.
-
-