Class DAGLayout<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
-
- edu.uci.ics.jung.algorithms.layout.SpringLayout<V,E>
-
- edu.uci.ics.jung.algorithms.layout.DAGLayout<V,E>
-
- All Implemented Interfaces:
Layout<V,E>,IterativeContext,org.apache.commons.collections4.Transformer<V,java.awt.geom.Point2D>
public class DAGLayout<V,E> extends SpringLayout<V,E>
An implementation ofLayoutsuitable for tree-like directed acyclic graphs. Parts of it will probably not terminate if the graph is cyclic! The layout will result in directed edges pointing generally upwards. Any vertices with no successors are considered to be level 0, and tend towards the top of the layout. Any vertex has a level one greater than the maximum level of all its successors.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.uci.ics.jung.algorithms.layout.SpringLayout
SpringLayout.SpringDimensionChecker, SpringLayout.SpringVertexData
-
-
Field Summary
-
Fields inherited from class edu.uci.ics.jung.algorithms.layout.SpringLayout
force_multiplier, lengthFunction, repulsion_range_sq, springVertexData, stretch
-
Fields inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
graph, initialized, locations, size
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandone()Override incrementsAreDone so that we can eventually stop.voidinitialize()Had to override this one as well, to ensure that setRoot() is called.protected voidmoveNodes()Override the moveNodes() method from SpringLayout.voidpropagateMinimumLevel(V v)A recursive method for allocating the level for each vertex.protected voidrelaxEdges()Overridden relaxEdges.voidsetLocation(V picked, double x, double y)Override forceMove so that if someone moves a node, we can re-layout everything.voidsetLocation(V picked, java.awt.geom.Point2D p)Override forceMove so that if someone moves a node, we can re-layout everything.voidsetRoot(edu.uci.ics.jung.graph.Graph<V,E> g)setRoot calculates the level of each vertex in the graph.voidsetRoot(V v)Set vertex v to be level 0.voidsetSize(java.awt.Dimension size)Sets the dimensions of the available space for layout tosize.-
Methods inherited from class edu.uci.ics.jung.algorithms.layout.SpringLayout
calculateRepulsion, getForceMultiplier, getRepulsionRange, getStretch, isIncremental, reset, setForceMultiplier, setRepulsionRange, setStretch, step
-
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, transform
-
-
-
-
Method Detail
-
setRoot
public void setRoot(edu.uci.ics.jung.graph.Graph<V,E> g)
setRoot calculates the level of each vertex in the graph. Level 0 is allocated to any vertex with no successors. Level n+1 is allocated to any vertex whose successors' maximum level is n.
-
setRoot
public void setRoot(V v)
Set vertex v to be level 0.
-
propagateMinimumLevel
public void propagateMinimumLevel(V v)
A recursive method for allocating the level for each vertex. Ensures that all predecessors of v have a level which is at least one greater than the level of v.- Parameters:
v-
-
setSize
public void setSize(java.awt.Dimension size)
Description copied from class:SpringLayoutSets the dimensions of the available space for layout tosize.
-
initialize
public void initialize()
Had to override this one as well, to ensure that setRoot() is called.- Specified by:
initializein interfaceLayout<V,E>- Overrides:
initializein classSpringLayout<V,E>
-
moveNodes
protected void moveNodes()
Override the moveNodes() method from SpringLayout. The only change we need to make is to make sure that nodes don't float higher than the minY coordinate, as calculated by their minimumLevel.- Overrides:
moveNodesin classSpringLayout<V,E>
-
done
public boolean done()
Override incrementsAreDone so that we can eventually stop.- Specified by:
donein interfaceIterativeContext- Overrides:
donein classSpringLayout<V,E>
-
setLocation
public void setLocation(V picked, double x, double y)
Override forceMove so that if someone moves a node, we can re-layout everything.- Overrides:
setLocationin classAbstractLayout<V,E>
-
setLocation
public void setLocation(V picked, java.awt.geom.Point2D p)
Override forceMove so that if someone moves a node, we can re-layout everything.- Specified by:
setLocationin interfaceLayout<V,E>- Overrides:
setLocationin classAbstractLayout<V,E>
-
relaxEdges
protected void relaxEdges()
Overridden relaxEdges. This one reduces the effect of edges between greatly different levels.- Overrides:
relaxEdgesin classSpringLayout<V,E>
-
-