Class 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.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 java.util.Map<V,​PersistentLayout.Point> map
      a container for Vertices
      • Fields inherited from class edu.uci.ics.jung.algorithms.layout.LayoutDecorator

        delegate
    • 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
    • Field Detail

      • 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)
    • Constructor Detail

      • PersistentLayoutImpl

        public PersistentLayoutImpl​(edu.uci.ics.jung.algorithms.layout.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,
                                          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 interface PersistentLayout<V,​E>
        Parameters:
        fileName - the file to save to
        Throws:
        an - IOException if the file cannot be used
        java.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 interface PersistentLayout<V,​E>
        Parameters:
        fileName - the file to use
        Throws:
        java.io.IOException - for file problems
        java.lang.ClassNotFoundException - for classpath problems
      • done

        public boolean done()
        Specified by:
        done in interface edu.uci.ics.jung.algorithms.util.IterativeContext
        Overrides:
        done in class ObservableCachingLayout<V,​E>
        See Also:
        IterativeContext.done()
      • lock

        public void lock​(V v,
                         boolean state)
        Specified by:
        lock in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
        Overrides:
        lock in class edu.uci.ics.jung.algorithms.layout.LayoutDecorator<V,​E>