edu.uci.ics.jung.visualization.contrib
Class DAGLayout

java.lang.Object
  extended byedu.uci.ics.jung.visualization.AbstractLayout
      extended byedu.uci.ics.jung.visualization.SpringLayout
          extended byedu.uci.ics.jung.visualization.contrib.DAGLayout
All Implemented Interfaces:
Layout, LayoutMutable

public class DAGLayout
extends SpringLayout

Author:
John Yesberg DAGLayout is a layout algorithm which is 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. Note: had to make minor access changes to SpringLayout to make this work. FORCE_CONSTANT, LengthFunction, SpringVertexData, and SpringEdgeData were all made "protected".

Nested Class Summary
 
Nested classes inherited from class edu.uci.ics.jung.visualization.SpringLayout
SpringLayout.LengthFunction, SpringLayout.SpringDimensionChecker, SpringLayout.UnitLengthFunction
 
Field Summary
 
Fields inherited from class edu.uci.ics.jung.visualization.SpringLayout
UNITLENGTHFUNCTION
 
Constructor Summary
DAGLayout(Graph g)
           
 
Method Summary
 void forceMove(Vertex picked, int x, int y)
          Override forceMove so that if someone moves a node, we can re-layout everything.
 boolean incrementsAreDone()
          Override incrementsAreDone so that we can eventually stop.
static void propagateMinimumLevel(Vertex v)
          A recursive method for allocating the level for each vertex.
static void setRoot(Graph g)
          setRoot calculates the level of each vertex in the graph.
static void setRoot(Vertex v)
          Set vertex v to be level 0.
 
Methods inherited from class edu.uci.ics.jung.visualization.SpringLayout
advancePositions, getForceMultiplier, getLength, getRepulsionRange, getSpringData, getSpringData, getSpringKey, getStatus, getStretch, isIncremental, setForceMultiplier, setRepulsionRange, setStretch, update
 
Methods inherited from class edu.uci.ics.jung.visualization.AbstractLayout
applyFilter, dontMove, getBaseKey, getCoordinates, getCurrentSize, getEdge, getEdge, getGraph, getVertex, getVertex, getVisibleEdges, getVisibleVertices, getX, getY, initialize, lockVertex, resize, restart, unlockVertex
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.uci.ics.jung.visualization.Layout
applyFilter, getCurrentSize, getGraph, getVertex, getVertex, getVisibleEdges, getVisibleVertices, getX, getY, initialize, lockVertex, resize, restart, unlockVertex
 

Constructor Detail

DAGLayout

public DAGLayout(Graph g)
Method Detail

setRoot

public static void setRoot(Graph 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 static void setRoot(Vertex v)
Set vertex v to be level 0.


propagateMinimumLevel

public static void propagateMinimumLevel(Vertex 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 -

incrementsAreDone

public boolean incrementsAreDone()
Override incrementsAreDone so that we can eventually stop.

Specified by:
incrementsAreDone in interface Layout
Overrides:
incrementsAreDone in class SpringLayout

forceMove

public void forceMove(Vertex picked,
                      int x,
                      int y)
Override forceMove so that if someone moves a node, we can re-layout everything.

Specified by:
forceMove in interface Layout
Overrides:
forceMove in class AbstractLayout