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 edu.uci.ics.jung.visualization.layout.PersistentLayout
PersistentLayout.Point
-
Field Summary
FieldsModifier and TypeFieldDescriptiona collection of Vertices that should not moveprotected Map
<V, PersistentLayout.Point> a container for Verticesprotected boolean
whether 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
ConstructorsConstructorDescriptionPersistentLayoutImpl
(Layout<V, E> layout) create an instance with a passed layout create containers for graph components -
Method Summary
Modifier and TypeMethodDescriptionboolean
done()
protected void
initializeLocation
(V v, Point2D coord) Sets persisted location for a vertex within the dimensions of the space.protected void
This method calls initialize_local_vertex for each vertex, and also adds initial coordinate information for each vertex.void
lock
(boolean locked) void
Locks or unlocks the specified vertex.void
save the Vertex locations to a filevoid
Restore the graph Vertex locations from a fileMethods 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 com.google.common.base.Function
apply, equals
Methods inherited from interface edu.uci.ics.jung.algorithms.layout.Layout
getGraph, getSize, initialize, isLocked, reset, setGraph, setInitializer, setLocation, setSize
-
Field Details
-
locations
a container for Vertices -
dontmove
a collection of Vertices that should not move -
locked
protected boolean lockedwhether the graph is locked (stops the VisualizationViewer rendering thread)
-
-
Constructor Details
-
PersistentLayoutImpl
create an instance with a passed layout create containers for graph components- Parameters:
layout
- the layout whose positions are to be persisted
-
-
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:
persist
in 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:
restore
in 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:
lock
in interfacePersistentLayout<V,
E>
-
done
public boolean done()- Specified by:
done
in interfaceIterativeContext
- Overrides:
done
in classObservableCachingLayout<V,
E> - Returns:
true
if this iterative process is finished, andfalse
otherwise.
-
lock
Description copied from interface:Layout
Locks 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.
-