Class TreeLayout<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.layout.TreeLayout<V,E>
-
- All Implemented Interfaces:
Layout<V,E>,org.apache.commons.collections4.Transformer<V,java.awt.geom.Point2D>
- Direct Known Subclasses:
BalloonLayout,RadialTreeLayout
public class TreeLayout<V,E> extends java.lang.Object implements Layout<V,E>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<V>alreadyDoneprotected java.util.Map<V,java.lang.Integer>basePositionsstatic intDEFAULT_DISTXThe default horizontal vertex spacing.static intDEFAULT_DISTYThe default vertical vertex spacing.protected intdistXThe horizontal vertex spacing.protected intdistYThe vertical vertex spacing.protected edu.uci.ics.jung.graph.Forest<V,E>graphprotected java.util.Map<V,java.awt.geom.Point2D>locationsprotected java.awt.Pointm_currentPointprotected java.awt.Dimensionsize
-
Constructor Summary
Constructors Constructor Description TreeLayout(edu.uci.ics.jung.graph.Forest<V,E> g)Creates an instance for the specified graph with default X and Y distances.TreeLayout(edu.uci.ics.jung.graph.Forest<V,E> g, int distx)Creates an instance for the specified graph and X distance with default Y distance.TreeLayout(edu.uci.ics.jung.graph.Forest<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 protected voidbuildTree()protected voidbuildTree(V v, int x)java.awt.geom.Point2DgetCenter()Returns the center of this layout's area.edu.uci.ics.jung.graph.Graph<V,E>getGraph()Returns the full graph (the one that was passed in at construction time) that this Layout refers to.java.awt.DimensiongetSize()Returns the current size of the visualization's space.voidinitialize()Initializes fields in the node that may not have been set during the constructor.booleanisLocked(V v)Returnstrueif the position of vertexvis locked.voidlock(V v, boolean state)Sets a flag which fixes this vertex in place.voidreset()protected voidsetCurrentPositionFor(V vertex)voidsetGraph(edu.uci.ics.jung.graph.Graph<V,E> graph)setter for graphvoidsetInitializer(org.apache.commons.collections4.Transformer<V,java.awt.geom.Point2D> initializer)provides initial locations for all vertices.voidsetLocation(V v, java.awt.geom.Point2D location)set the location of a vertexvoidsetSize(java.awt.Dimension size)This method is not supported by this class.java.awt.geom.Point2Dtransform(V v)
-
-
-
Field Detail
-
size
protected java.awt.Dimension size
-
basePositions
protected java.util.Map<V,java.lang.Integer> basePositions
-
locations
protected java.util.Map<V,java.awt.geom.Point2D> locations
-
alreadyDone
protected transient java.util.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 toDEFAULT_XDIST.
-
distY
protected int distY
The vertical vertex spacing. Defaults toDEFAULT_YDIST.
-
m_currentPoint
protected transient java.awt.Point m_currentPoint
-
-
Constructor Detail
-
TreeLayout
public TreeLayout(edu.uci.ics.jung.graph.Forest<V,E> g)
Creates an instance for the specified graph with default X and Y distances.
-
TreeLayout
public TreeLayout(edu.uci.ics.jung.graph.Forest<V,E> g, int distx)
Creates an instance for the specified graph and X distance with default Y distance.
-
-
Method Detail
-
buildTree
protected void buildTree()
-
buildTree
protected void buildTree(V v, int x)
-
setSize
public void setSize(java.awt.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).
-
setCurrentPositionFor
protected void setCurrentPositionFor(V vertex)
-
getGraph
public edu.uci.ics.jung.graph.Graph<V,E> getGraph()
Description copied from interface:LayoutReturns the full graph (the one that was passed in at construction time) that this Layout refers to.
-
getSize
public java.awt.Dimension getSize()
Description copied from interface:LayoutReturns the current size of the visualization's space.
-
initialize
public void initialize()
Description copied from interface:LayoutInitializes fields in the node that may not have been set during the constructor. Must be called before the iterations begin.- Specified by:
initializein interfaceLayout<V,E>
-
isLocked
public boolean isLocked(V v)
Description copied from interface:LayoutReturnstrueif the position of vertexvis locked.
-
lock
public void lock(V v, boolean state)
Description copied from interface:LayoutSets a flag which fixes this vertex in place.
-
setGraph
public void setGraph(edu.uci.ics.jung.graph.Graph<V,E> graph)
Description copied from interface:Layoutsetter for graph
-
setInitializer
public void setInitializer(org.apache.commons.collections4.Transformer<V,java.awt.geom.Point2D> initializer)
Description copied from interface:Layoutprovides initial locations for all vertices.- Specified by:
setInitializerin interfaceLayout<V,E>
-
getCenter
public java.awt.geom.Point2D getCenter()
Returns the center of this layout's area.
-
setLocation
public void setLocation(V v, java.awt.geom.Point2D location)
Description copied from interface:Layoutset the location of a vertex- Specified by:
setLocationin interfaceLayout<V,E>
-
-