Class TreeLayout<V,E>

java.lang.Object
edu.uci.ics.jung.algorithms.layout.TreeLayout<V,E>
All Implemented Interfaces:
com.google.common.base.Function<V,Point2D>, Layout<V,E>, Function<V,Point2D>
Direct Known Subclasses:
BalloonLayout, RadialTreeLayout

public class TreeLayout<V,E> extends Object implements Layout<V,E>
  • Field Details

    • size

      protected Dimension size
    • graph

      protected Forest<V,E> graph
    • basePositions

      protected Map<V,Integer> basePositions
    • locations

      protected com.google.common.cache.LoadingCache<V,Point2D> locations
    • alreadyDone

      protected transient Set<V> alreadyDone
    • DEFAULT_DISTX

      public static int DEFAULT_DISTX
      The default horizontal vertex spacing. Initialized to 50.
    • DEFAULT_DISTY

      public static int DEFAULT_DISTY
      The default vertical vertex spacing. Initialized to 50.
    • distX

      protected int distX
      The horizontal vertex spacing. Defaults to DEFAULT_XDIST.
    • distY

      protected int distY
      The vertical vertex spacing. Defaults to DEFAULT_YDIST.
    • m_currentPoint

      protected transient Point m_currentPoint
  • Constructor Details

    • TreeLayout

      public TreeLayout(Forest<V,E> g)
      Creates an instance for the specified graph with default X and Y distances.
      Parameters:
      g - the graph on which the layout algorithm is to operate
    • TreeLayout

      public TreeLayout(Forest<V,E> g, int distx)
      Creates an instance for the specified graph and X distance with default Y distance.
      Parameters:
      g - the graph on which the layout algorithm is to operate
      distx - the horizontal spacing between adjacent siblings
    • TreeLayout

      public TreeLayout(Forest<V,E> g, int distx, int disty)
      Creates an instance for the specified graph, X distance, and Y distance.
      Parameters:
      g - the graph on which the layout algorithm is to operate
      distx - the horizontal spacing between adjacent siblings
      disty - the vertical spacing between adjacent siblings
  • Method Details

    • buildTree

      protected void buildTree()
    • buildTree

      protected void buildTree(V v, int x)
    • calculateDimensionX

      private int calculateDimensionX(V v)
    • calculateDimensionX

      private int calculateDimensionX(Collection<V> roots)
    • setSize

      public void setSize(Dimension size)
      This method is not supported by this class. The size of the layout is determined by the topology of the tree, and by the horizontal and vertical spacing (optionally set by the constructor).
      Specified by:
      setSize in interface Layout<V,E>
      Parameters:
      size - the space to use to lay out this graph
    • setCurrentPositionFor

      protected void setCurrentPositionFor(V vertex)
    • getGraph

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

      public 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 being queried
      Returns:
      true if the position of vertex v is locked
    • 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>
      Parameters:
      v - the vertex to lock/unlock
      state - true to lock the vertex, false to unlock it
    • 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,Point2D> initializer)
      Specified by:
      setInitializer in interface Layout<V,E>
      Parameters:
      initializer - a function that specifies initial locations for all vertices
    • getCenter

      public Point2D getCenter()
      Returns:
      the center of this layout's area.
    • setLocation

      public void setLocation(V v, 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
    • apply

      public Point2D apply(V v)
      Specified by:
      apply in interface com.google.common.base.Function<V,E>
      Specified by:
      apply in interface Function<V,E>