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

    • locations

      protected Map<V,PersistentLayout.Point> locations
      a container for Vertices
    • dontmove

      protected 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 Details

    • PersistentLayoutImpl

      public PersistentLayoutImpl(Layout<V,E> layout)
      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

      protected void initializeLocation(V v, 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 initialized
      coord - the location
    • persist

      public void persist(String fileName) throws IOException
      save the Vertex locations to a file
      Specified by:
      persist in interface PersistentLayout<V,E>
      Parameters:
      fileName - the file to save to
      Throws:
      IOException - if the file cannot be used
    • restore

      public void restore(String fileName) throws IOException, ClassNotFoundException
      Restore the graph Vertex locations from a file
      Specified by:
      restore in interface PersistentLayout<V,E>
      Parameters:
      fileName - the file to use
      Throws:
      IOException - for file problems
      ClassNotFoundException - for classpath problems
    • lock

      public void lock(boolean locked)
      Specified by:
      lock in interface PersistentLayout<V,E>
    • done

      public boolean done()
      Specified by:
      done in interface IterativeContext
      Overrides:
      done in class ObservableCachingLayout<V,E>
      Returns:
      true if this iterative process is finished, and false otherwise.
    • lock

      public void lock(V v, boolean state)
      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.
      Specified by:
      lock in interface Layout<V,E>
      Overrides:
      lock in class LayoutDecorator<V,E>
      Parameters:
      v - the vertex to lock/unlock
      state - true to lock the vertex, false to unlock it