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:
com.google.common.base.Function<V,
,Point2D> Layout<V,
,E> IterativeContext
,Function<V,
Point2D>
An implementation of
Layout
suitable 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
FieldsModifier and TypeFieldDescription(package private) final int
(package private) static int
(package private) int
(package private) final double
(package private) double
Each vertex has a minimumLevel.(package private) final double
A bunch of parameters to help work out when to stop quivering.(package private) static int
(package private) final double
(package private) boolean
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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
done()
Override incrementsAreDone so that we can eventually stop.void
Had to override this one as well, to ensure that setRoot() is called.private void
initializeLocation
(V v, Point2D coord, Dimension d) Sets a random location for a vertex within the dimensions of the space.protected void
Override the moveNodes() method from SpringLayout.void
A recursive method for allocating the level for each vertex.protected void
Overridden relaxEdges.void
setLocation
(V picked, double x, double y) Override forceMove so that if someone moves a node, we can re-layout everything.void
setLocation
(V picked, Point2D p) Override forceMove so that if someone moves a node, we can re-layout everything.void
setRoot()
Calculates the level of each vertex in the graph.void
Set vertex v to be level 0.void
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.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
apply, getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.common.base.Function
equals
-
Field Details
-
minLevels
Each vertex has a minimumLevel. Any vertex with no successors has minimumLevel of zero. The minimumLevel of any vertex must be strictly greater than the minimumLevel of its parents. (Vertex A is a parent of Vertex B iff there is an edge from B to A.) Typically, a vertex will have a minimumLevel which is one greater than the minimumLevel of its parent's. However, if the vertex has two parents, its minimumLevel will be one greater than the maximum of the parents'. We need to calculate the minimumLevel for each vertex. When we layout the graph, vertices cannot be drawn any higher than the minimumLevel. The graphHeight of a graph is the greatest minimumLevel that is used. We will modify the SpringLayout calculations so that nodes cannot move above their assigned minimumLevel. -
graphHeight
static int graphHeight -
numRoots
static int numRoots -
SPACEFACTOR
final double SPACEFACTOR- See Also:
-
LEVELATTRACTIONRATE
final double LEVELATTRACTIONRATE- See Also:
-
MSV_THRESHOLD
final double MSV_THRESHOLDA bunch of parameters to help work out when to stop quivering. If the MeanSquareVel(ocity) ever gets below the MSV_THRESHOLD, then we will start a final cool-down phase of COOL_DOWN_INCREMENT increments. If the MeanSquareVel ever exceeds the threshold, we will exit the cool down phase, and continue looking for another opportunity.- See Also:
-
meanSquareVel
double meanSquareVel -
stoppingIncrements
boolean stoppingIncrements -
incrementsLeft
int incrementsLeft -
COOL_DOWN_INCREMENTS
final int COOL_DOWN_INCREMENTS- See Also:
-
-
Constructor Details
-
DAGLayout
-
-
Method Details
-
setRoot
public void setRoot()Calculates the level of each vertex in the graph. Level 0 is allocated to each vertex with no successors. Level n+1 is allocated to any vertex whose successors' maximum level is n. -
setRoot
Set vertex v to be level 0.- Parameters:
v
- the vertex to set as root
-
propagateMinimumLevel
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
- the vertex whose minimum level is to be calculated
-
initializeLocation
Sets a random location for a vertex within the dimensions of the space.- Parameters:
v
- the vertex whose position is to be setcoord
- the coordinates of the vertex once the position has been setd
- the dimensions of the space
-
setSize
Description copied from class:AbstractLayout
When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local. -
initialize
public void initialize()Had to override this one as well, to ensure that setRoot() is called.- Specified by:
initialize
in interfaceLayout<V,
E> - Overrides:
initialize
in 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:
moveNodes
in classSpringLayout<V,
E>
-
done
public boolean done()Override incrementsAreDone so that we can eventually stop.- Specified by:
done
in interfaceIterativeContext
- Overrides:
done
in classSpringLayout<V,
E> - Returns:
- false
-
setLocation
Override forceMove so that if someone moves a node, we can re-layout everything.- Overrides:
setLocation
in classAbstractLayout<V,
E> - Parameters:
picked
- the vertex whose location is to be setx
- the x coordinate of the location to sety
- the y coordinate of the location to set
-
setLocation
Override forceMove so that if someone moves a node, we can re-layout everything.- Specified by:
setLocation
in interfaceLayout<V,
E> - Overrides:
setLocation
in classAbstractLayout<V,
E> - Parameters:
picked
- the vertex whose location is to be setp
- the location to set
-
relaxEdges
protected void relaxEdges()Overridden relaxEdges. This one reduces the effect of edges between greatly different levels.- Overrides:
relaxEdges
in classSpringLayout<V,
E>
-