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,​Point2D>

    public class HierarchyLayout<V,​E>
    extends 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 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​(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 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​(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,​Point2D> initializer)
        Specified by:
        setInitializer in interface edu.uci.ics.jung.algorithms.layout.Layout<V,​E>
      • setLocation

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

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