Class AbstractLayout<V,​E>

  • Type Parameters:
    V - the vertex type
    E - the edge type
    All Implemented Interfaces:
    Layout<V,​E>, org.apache.commons.collections4.Transformer<V,​java.awt.geom.Point2D>
    Direct Known Subclasses:
    CircleLayout, FRLayout, FRLayout2, ISOMLayout, KKLayout, SpringLayout, StaticLayout

    public abstract class AbstractLayout<V,​E>
    extends java.lang.Object
    implements Layout<V,​E>
    Abstract class for implementations of Layout. It handles some of the basic functions: storing coordinates, maintaining the dimensions, initializing the locations, maintaining locked vertices.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected edu.uci.ics.jung.graph.Graph<V,​E> graph  
      protected boolean initialized  
      protected java.util.Map<V,​java.awt.geom.Point2D> locations  
      protected java.awt.Dimension size  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph)
      Creates an instance which does not initialize the vertex locations.
      protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph, java.awt.Dimension size)  
      protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph, org.apache.commons.collections4.Transformer initializer)  
      protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph, org.apache.commons.collections4.Transformer initializer, java.awt.Dimension size)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      edu.uci.ics.jung.graph.Graph<V,​E> getGraph()
      Accessor for the graph that represets all vertices.
      java.awt.Dimension getSize()
      Returns the current size of the visualization space, accoring to the last call to resize().
      double getX​(V v)
      Returns the x coordinate of the vertex from the Coordinates object.
      double getY​(V v)
      Returns the y coordinate of the vertex from the Coordinates object.
      boolean isLocked​(V v)
      Returns true if the position of vertex v is locked.
      void lock​(boolean lock)
      Locks all vertices in place if lock is true, otherwise unlocks all vertices.
      void lock​(V v, boolean state)
      Locks v in place if state is true, otherwise unlocks it.
      protected void offsetVertex​(V v, double xOffset, double yOffset)  
      void setGraph​(edu.uci.ics.jung.graph.Graph<V,​E> graph)
      setter for graph
      void setInitializer​(org.apache.commons.collections4.Transformer initializer)
      provides initial locations for all vertices.
      void setLocation​(V picked, double x, double y)
      Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location.
      void setLocation​(V picked, java.awt.geom.Point2D p)
      set the location of a vertex
      void setSize​(java.awt.Dimension size)
      When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.
      java.awt.geom.Point2D transform​(V v)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • size

        protected java.awt.Dimension size
      • graph

        protected edu.uci.ics.jung.graph.Graph<V,​E> graph
      • initialized

        protected boolean initialized
      • locations

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

      • AbstractLayout

        protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph)
        Creates an instance which does not initialize the vertex locations.
        Parameters:
        graph - the graph for which the layout algorithm is to be created.
      • AbstractLayout

        protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph,
                                 org.apache.commons.collections4.Transformer initializer)
      • AbstractLayout

        protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph,
                                 java.awt.Dimension size)
      • AbstractLayout

        protected AbstractLayout​(edu.uci.ics.jung.graph.Graph<V,​E> graph,
                                 org.apache.commons.collections4.Transformer initializer,
                                 java.awt.Dimension size)
    • Method Detail

      • setGraph

        public void setGraph​(edu.uci.ics.jung.graph.Graph<V,​E> graph)
        Description copied from interface: Layout
        setter for graph
        Specified by:
        setGraph in interface Layout<V,​E>
      • setSize

        public void setSize​(java.awt.Dimension size)
        When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local.
        Specified by:
        setSize in interface Layout<V,​E>
      • isLocked

        public boolean isLocked​(V v)
        Description copied from interface: Layout
        Returns true if the position of vertex v is locked.
        Specified by:
        isLocked in interface Layout<V,​E>
      • setInitializer

        public void setInitializer​(org.apache.commons.collections4.Transformer initializer)
        Description copied from interface: Layout
        provides initial locations for all vertices.
        Specified by:
        setInitializer in interface Layout<V,​E>
      • getSize

        public java.awt.Dimension getSize()
        Returns the current size of the visualization space, accoring to the last call to resize().
        Specified by:
        getSize in interface Layout<V,​E>
        Returns:
        the current size of the screen
      • transform

        public java.awt.geom.Point2D transform​(V v)
        Specified by:
        transform in interface org.apache.commons.collections4.Transformer<V,​E>
      • getX

        public double getX​(V v)
        Returns the x coordinate of the vertex from the Coordinates object. in most cases you will be better off calling transform(v).
      • getY

        public double getY​(V v)
        Returns the y coordinate of the vertex from the Coordinates object. In most cases you will be better off calling transform(v).
      • offsetVertex

        protected void offsetVertex​(V v,
                                    double xOffset,
                                    double yOffset)
        Parameters:
        v -
        xOffset -
        yOffset -
      • getGraph

        public edu.uci.ics.jung.graph.Graph<V,​E> getGraph()
        Accessor for the graph that represets all vertices.
        Specified by:
        getGraph in interface Layout<V,​E>
        Returns:
        the graph that contains all vertices.
      • setLocation

        public void setLocation​(V picked,
                                double x,
                                double y)
        Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location. Does not add the vertex to the "dontmove" list, and (in the default implementation) does not make any adjustments to the rest of the graph.
      • setLocation

        public void setLocation​(V picked,
                                java.awt.geom.Point2D p)
        Description copied from interface: Layout
        set the location of a vertex
        Specified by:
        setLocation in interface Layout<V,​E>
      • lock

        public void lock​(V v,
                         boolean state)
        Locks v in place if state is true, otherwise unlocks it.
        Specified by:
        lock in interface Layout<V,​E>
        Parameters:
        v - vertex
      • lock

        public void lock​(boolean lock)
        Locks all vertices in place if lock is true, otherwise unlocks all vertices.