Class HierarchyLayout<V,​E>

  • Type Parameters:
    V -
    E -
    All Implemented Interfaces:
    edu.uci.ics.jung.algorithms.layout.Layout<V,​E>, org.apache.commons.collections15.Transformer<V,​java.awt.geom.Point2D>

    public class HierarchyLayout<V,​E>
    extends java.lang.Object
    implements edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
    A custom layout to be able to draw a hierarchy. This implementation is inspired by TreeLayout, which only works if 2 parents do not have the same child (see TreeUtils.getRoots(Forest)).
    • Constructor Summary

      Constructors 
      Constructor Description
      HierarchyLayout​(edu.uci.ics.jung.graph.Graph<V,​E> g, int distx, int disty)
      Creates an instance for the specified graph, X distance, and Y distance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      edu.uci.ics.jung.graph.Graph<V,​E> getGraph()  
      java.awt.Dimension getSize()  
      void horizontalSqueeze​(java.util.List<V> vertices)
      Shifts the vertices horizontally ensuring that there is no more than "distx" units between each column of vertices.
      void initialize()  
      boolean isLocked​(V v)  
      void lock​(V v, boolean state)  
      void reset()  
      void setGraph​(edu.uci.ics.jung.graph.Graph<V,​E> graph)  
      void setInitializer​(org.apache.commons.collections15.Transformer<V,​java.awt.geom.Point2D> initializer)  
      void setLocation​(V v, java.awt.geom.Point2D location)  
      void setSize​(java.awt.Dimension d)  
      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
    • Constructor Detail

      • HierarchyLayout

        public HierarchyLayout​(edu.uci.ics.jung.graph.Graph<V,​E> g,
                               int distx,
                               int disty)
        Creates an instance for the specified graph, X distance, and Y distance.
    • Method Detail

      • horizontalSqueeze

        public void horizontalSqueeze​(java.util.List<V> vertices)
        Shifts the vertices horizontally ensuring that there is no more than "distx" units between each column of vertices. The resulting layout is a denser visual that maintains the existing structure of the original layout. For the purposes of this algorithm, vertices with the same value of the X coordinate are deemed to be in the same "column".
        Parameters:
        vertices - list of vertices that will be displayed
      • getGraph

        public edu.uci.ics.jung.graph.Graph<V,​E> getGraph()
        Specified by:
        getGraph in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • getSize

        public java.awt.Dimension getSize()
        Specified by:
        getSize in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • initialize

        public void initialize()
        Specified by:
        initialize in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • isLocked

        public boolean isLocked​(V v)
        Specified by:
        isLocked in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • lock

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

        public void reset()
        Specified by:
        reset in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • setSize

        public void setSize​(java.awt.Dimension d)
        Specified by:
        setSize in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • setGraph

        public void setGraph​(edu.uci.ics.jung.graph.Graph<V,​E> graph)
        Specified by:
        setGraph in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • setInitializer

        public void setInitializer​(org.apache.commons.collections15.Transformer<V,​java.awt.geom.Point2D> initializer)
        Specified by:
        setInitializer in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • setLocation

        public void setLocation​(V v,
                                java.awt.geom.Point2D location)
        Specified by:
        setLocation in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • transform

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