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,java.awt.geom.Point2D>
,Layout<V,E>
,java.util.function.Function<V,java.awt.geom.Point2D>
- Direct Known Subclasses:
BalloonLayout
,RadialTreeLayout
public class TreeLayout<V,E> extends java.lang.Object implements Layout<V,E>
- Author:
- Karlheinz Toni, Tom Nelson - converted to jung2
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<V>
alreadyDone
protected java.util.Map<V,java.lang.Integer>
basePositions
static int
DEFAULT_DISTX
The default horizontal vertex spacing.static int
DEFAULT_DISTY
The default vertical vertex spacing.protected int
distX
The horizontal vertex spacing.protected int
distY
The vertical vertex spacing.protected Forest<V,E>
graph
protected com.google.common.cache.LoadingCache<V,java.awt.geom.Point2D>
locations
protected java.awt.Point
m_currentPoint
protected java.awt.Dimension
size
-
Constructor Summary
Constructors Constructor Description TreeLayout(Forest<V,E> g)
Creates an instance for the specified graph with default X and Y distances.TreeLayout(Forest<V,E> g, int distx)
Creates an instance for the specified graph and X distance with default Y distance.TreeLayout(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 java.awt.geom.Point2D
apply(V v)
protected void
buildTree()
protected void
buildTree(V v, int x)
java.awt.geom.Point2D
getCenter()
Graph<V,E>
getGraph()
java.awt.Dimension
getSize()
void
initialize()
Initializes fields in the node that may not have been set during the constructor.boolean
isLocked(V v)
void
lock(V v, boolean state)
Locks or unlocks the specified vertex.void
reset()
protected void
setCurrentPositionFor(V vertex)
void
setGraph(Graph<V,E> graph)
void
setInitializer(com.google.common.base.Function<V,java.awt.geom.Point2D> initializer)
void
setLocation(V v, java.awt.geom.Point2D location)
Changes the layout coordinates ofv
tolocation
.void
setSize(java.awt.Dimension size)
This method is not supported by this class.
-
-
-
Field Detail
-
size
protected java.awt.Dimension size
-
basePositions
protected java.util.Map<V,java.lang.Integer> basePositions
-
locations
protected com.google.common.cache.LoadingCache<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(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 operatedistx
- 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 operatedistx
- the horizontal spacing between adjacent siblingsdisty
- the vertical spacing between adjacent siblings
-
-
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)
-
getSize
public java.awt.Dimension getSize()
-
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 interfaceLayout<V,E>
-
isLocked
public boolean isLocked(V v)
-
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.
-
setInitializer
public void setInitializer(com.google.common.base.Function<V,java.awt.geom.Point2D> initializer)
- Specified by:
setInitializer
in interfaceLayout<V,E>
- Parameters:
initializer
- a function that specifies initial locations for all vertices
-
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:Layout
Changes the layout coordinates ofv
tolocation
.- Specified by:
setLocation
in interfaceLayout<V,E>
- Parameters:
v
- the vertex whose location is to be specifiedlocation
- the coordinates of the specified location
-
-