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:
edu.uci.ics.jung.algorithms.layout.Layout<V,E>
,edu.uci.ics.jung.algorithms.util.IterativeContext
,PersistentLayout<V,E>
,Caching
,ChangeEventSupport
,org.apache.commons.collections4.Transformer<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 class
PersistentLayoutImpl.RandomPointFactory
-
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>
dontmove
a collection of Vertices that should not moveprotected boolean
locked
whether the graph is locked (stops the VisualizationViewer rendering thread)protected java.util.Map<V,PersistentLayout.Point>
map
a container for Vertices-
Fields inherited from class edu.uci.ics.jung.visualization.layout.ObservableCachingLayout
changeSupport, locationMap
-
-
Constructor Summary
Constructors Constructor Description PersistentLayoutImpl(edu.uci.ics.jung.algorithms.layout.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 boolean
done()
protected void
initializeLocation(V v, java.awt.geom.Point2D coord, java.awt.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)
void
persist(java.lang.String fileName)
save the Vertex locations to a filevoid
restore(java.lang.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.visualization.util.ChangeEventSupport
addChangeListener, fireStateChanged, getChangeListeners, removeChangeListener
-
-
-
-
Field Detail
-
map
protected java.util.Map<V,PersistentLayout.Point> map
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, java.awt.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(java.lang.String fileName) throws java.io.IOException
save the Vertex locations to a file- Specified by:
persist
in interfacePersistentLayout<V,E>
- Parameters:
fileName
- the file to save to- Throws:
an
- IOException if the file cannot be usedjava.io.IOException
-
restore
public void restore(java.lang.String fileName) throws java.io.IOException, java.lang.ClassNotFoundException
Restore the graph Vertex locations from a file- Specified by:
restore
in 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:
lock
in interfacePersistentLayout<V,E>
-
done
public boolean done()
- Specified by:
done
in interfaceedu.uci.ics.jung.algorithms.util.IterativeContext
- Overrides:
done
in classObservableCachingLayout<V,E>
- See Also:
IterativeContext.done()
-
-