Class AggregateLayout<V,​E>

  • Type Parameters:
    V - the vertex type
    E - the edge type
    All Implemented Interfaces:
    com.google.common.base.Function<V,​java.awt.geom.Point2D>, Layout<V,​E>, IterativeContext, java.util.function.Function<V,​java.awt.geom.Point2D>

    public class AggregateLayout<V,​E>
    extends java.lang.Object
    implements Layout<V,​E>, IterativeContext
    A Layout implementation that combines multiple other layouts so that they may be manipulated as one layout. The relaxer thread will step each layout in sequence.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Layout<V,​E> delegate  
      protected java.util.Map<Layout<V,​E>,​java.awt.geom.Point2D> layouts  
    • Constructor Summary

      Constructors 
      Constructor Description
      AggregateLayout​(Layout<V,​E> delegate)
      Creates an instance backed by the specified delegate.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.geom.Point2D apply​(V v)
      Returns the location of the vertex.
      boolean done()  
      java.awt.geom.Point2D get​(Layout<V,​E> layout)  
      Layout<V,​E> getDelegate()  
      Graph<V,​E> getGraph()  
      java.util.Map<Layout<V,​E>,​java.awt.geom.Point2D> getLayouts()  
      java.awt.Dimension getSize()  
      void initialize()
      Initializes fields in the node that may not have been set during the constructor.
      boolean isLocked​(V v)  
      void lock​(V v, boolean state)
      Locks this vertex in the main layout and in any sublayouts whose graph contains this vertex.
      void put​(Layout<V,​E> layout, java.awt.geom.Point2D center)
      Adds the passed layout as a sublayout, and specifies the center of where this sublayout should appear.
      void remove​(Layout<V,​E> layout)
      Removes layout from this instance.
      void removeAll()
      Removes all layouts from this instance.
      void reset()  
      void setDelegate​(Layout<V,​E> delegate)  
      void setGraph​(Graph<V,​E> graph)  
      void setInitializer​(com.google.common.base.Function<V,​java.awt.geom.Point2D> initializer)  
      void setLocation​(V v, java.awt.geom.Point2D location)
      Changes the layout coordinates of v to location.
      void setSize​(java.awt.Dimension d)  
      void step()
      Call step on any sublayout that is also an IterativeContext and is not done
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.google.common.base.Function

        equals
      • Methods inherited from interface java.util.function.Function

        andThen, compose
    • Field Detail

      • delegate

        protected Layout<V,​E> delegate
      • layouts

        protected java.util.Map<Layout<V,​E>,​java.awt.geom.Point2D> layouts
    • Constructor Detail

      • AggregateLayout

        public AggregateLayout​(Layout<V,​E> delegate)
        Creates an instance backed by the specified delegate.
        Parameters:
        delegate - the layout to which this instance is delegating
    • Method Detail

      • getDelegate

        public Layout<V,​E> getDelegate()
        Returns:
        the delegate
      • setDelegate

        public void setDelegate​(Layout<V,​E> delegate)
        Parameters:
        delegate - the delegate to set
      • put

        public void put​(Layout<V,​E> layout,
                        java.awt.geom.Point2D center)
        Adds the passed layout as a sublayout, and specifies the center of where this sublayout should appear.
        Parameters:
        layout - the layout algorithm to use as a sublayout
        center - the center of the coordinates for the sublayout
      • get

        public java.awt.geom.Point2D get​(Layout<V,​E> layout)
        Parameters:
        layout - the layout whose center is to be returned
        Returns:
        the center of the passed layout
      • remove

        public void remove​(Layout<V,​E> layout)
        Removes layout from this instance.
        Parameters:
        layout - the layout to remove
      • removeAll

        public void removeAll()
        Removes all layouts from this instance.
      • getGraph

        public Graph<V,​E> getGraph()
        Specified by:
        getGraph in interface Layout<V,​E>
        Returns:
        the graph that this Layout refers to
      • getSize

        public java.awt.Dimension getSize()
        Specified by:
        getSize in interface Layout<V,​E>
        Returns:
        the current size of the visualization's space
      • initialize

        public void initialize()
        Description copied from interface: Layout
        Initializes fields in the node that may not have been set during the constructor. Must be called before the iterations begin.
        Specified by:
        initialize in interface Layout<V,​E>
      • isLocked

        public boolean isLocked​(V v)
        Specified by:
        isLocked in interface Layout<V,​E>
        Parameters:
        v - the vertex whose locked state is to be returned
        Returns:
        true if v is locked in any of the layouts, and false otherwise
      • lock

        public void lock​(V v,
                         boolean state)
        Locks this vertex in the main layout and in any sublayouts whose graph contains this vertex.
        Specified by:
        lock in interface Layout<V,​E>
        Parameters:
        v - the vertex whose locked state is to be set
        state - true if the vertex is to be locked, and false if unlocked
      • reset

        public void reset()
        Specified by:
        reset in interface Layout<V,​E>
      • setGraph

        public void setGraph​(Graph<V,​E> graph)
        Specified by:
        setGraph in interface Layout<V,​E>
        Parameters:
        graph - the graph that this algorithm is to operate on
      • setInitializer

        public void setInitializer​(com.google.common.base.Function<V,​java.awt.geom.Point2D> initializer)
        Specified by:
        setInitializer in interface Layout<V,​E>
        Parameters:
        initializer - a function that specifies initial locations for all vertices
      • setLocation

        public void setLocation​(V v,
                                java.awt.geom.Point2D location)
        Description copied from interface: Layout
        Changes the layout coordinates of v to location.
        Specified by:
        setLocation in interface Layout<V,​E>
        Parameters:
        v - the vertex whose location is to be specified
        location - the coordinates of the specified location
      • setSize

        public void setSize​(java.awt.Dimension d)
        Specified by:
        setSize in interface Layout<V,​E>
        Parameters:
        d - the space to use to lay out this graph
      • getLayouts

        public java.util.Map<Layout<V,​E>,​java.awt.geom.Point2D> getLayouts()
        Returns:
        a map from each Layout instance to its center point.
      • apply

        public java.awt.geom.Point2D apply​(V v)
        Returns the location of the vertex. The location is specified first by the sublayouts, and then by the base layout if no sublayouts operate on this vertex.
        Specified by:
        apply in interface com.google.common.base.Function<V,​E>
        Specified by:
        apply in interface java.util.function.Function<V,​E>
        Returns:
        the location of the vertex
      • done

        public boolean done()
        Specified by:
        done in interface IterativeContext
        Returns:
        true iff the delegate layout and all sublayouts are done
      • step

        public void step()
        Call step on any sublayout that is also an IterativeContext and is not done
        Specified by:
        step in interface IterativeContext