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,Point2D>, Layout<V, E>, IterativeContext, LayoutEventSupport<V, E>, PersistentLayout<V, E>, Caching, ChangeEventSupport, Function<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
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface PersistentLayout
PersistentLayout.Point -
Field Summary
FieldsModifier and TypeFieldDescriptiona collection of Vertices that should not moveprotected Map<V, PersistentLayout.Point> a container for Verticesprotected booleanwhether the graph is locked (stops the VisualizationViewer rendering thread)Fields inherited from class ObservableCachingLayout
changeSupportFields inherited from class LayoutDecorator
delegate -
Constructor Summary
ConstructorsConstructorDescriptionPersistentLayoutImpl(Layout<V, E> layout) create an instance with a passed layout create containers for graph components -
Method Summary
Modifier and TypeMethodDescriptionbooleandone()protected voidinitializeLocation(V v, Point2D coord) Sets persisted location for a vertex within the dimensions of the space.protected voidThis method calls initialize_local_vertex for each vertex, and also adds initial coordinate information for each vertex.voidlock(boolean locked) voidLocks or unlocks the specified vertex.voidsave the Vertex locations to a filevoidRestore the graph Vertex locations from a fileMethods inherited from class ObservableCachingLayout
addChangeListener, addLayoutChangeListener, apply, clear, fireStateChanged, getChangeListeners, init, initialize, removeChangeListener, removeLayoutChangeListener, setGraph, setLocation, stepMethods inherited from class LayoutDecorator
getDelegate, getGraph, getSize, isLocked, reset, setDelegate, setInitializer, setSize, transformMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChangeEventSupport
addChangeListener, fireStateChanged, getChangeListeners, removeChangeListenerMethods inherited from interface com.google.common.base.Function
apply, equalsMethods inherited from interface Layout
getGraph, getSize, initialize, isLocked, reset, setGraph, setInitializer, setLocation, setSize
-
Field Details
-
locations
a container for Vertices -
dontmove
-
locked
protected boolean lockedwhether the graph is locked (stops the VisualizationViewer rendering thread)
-
-
Constructor Details
-
PersistentLayoutImpl
-
-
Method Details
-
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
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
save the Vertex locations to a file- Specified by:
persistin interfacePersistentLayout<V,E> - Parameters:
fileName- the file to save to- Throws:
IOException- if the file cannot be used
-
restore
Restore the graph Vertex locations from a file- Specified by:
restorein interfacePersistentLayout<V,E> - Parameters:
fileName- the file to use- Throws:
IOException- for file problemsClassNotFoundException- 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
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.
-