edu.uci.ics.jung.algorithms.layout
Class DAGLayout<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
      extended by edu.uci.ics.jung.algorithms.layout.SpringLayout<V,E>
          extended by edu.uci.ics.jung.algorithms.layout.DAGLayout<V,E>
All Implemented Interfaces:
Layout<V,E>, IterativeContext

public class DAGLayout<V,E>
extends SpringLayout<V,E>

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/interfaces inherited from class edu.uci.ics.jung.algorithms.layout.SpringLayout
SpringLayout.LengthFunction<E>, SpringLayout.SpringDimensionChecker, SpringLayout.SpringEdgeData<E>, SpringLayout.SpringVertexData, SpringLayout.UnitLengthFunction<E>
 
Field Summary
 
Fields inherited from class edu.uci.ics.jung.algorithms.layout.SpringLayout
force_multiplier, lengthFunction, repulsion_range, stretch, UNITLENGTHFUNCTION
 
Fields inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
initialized, locations
 
Constructor Summary
DAGLayout(Graph<V,E> g)
           
 
Method Summary
 boolean done()
          Override incrementsAreDone so that we can eventually stop.
 void initialize()
          Had to override this one as well, to ensure that setRoot() is called.
protected  void moveNodes()
          Override the moveNodes() method from SpringLayout.
 void propagateMinimumLevel(V v)
          A recursive method for allocating the level for each vertex.
protected  void relaxEdges()
          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(Graph<V,E> g)
          setRoot calculates the level of each vertex in the graph.
 void setRoot(V v)
          Set vertex v to be level 0.
 void setSize(Dimension size)
          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
calcEdgeLength, calculateRepulsion, getAVertex, getForceMultiplier, getLength, getRepulsionRange, getSpringEdgeData, getSpringVertexData, getStretch, isIncremental, reset, setForceMultiplier, setRepulsionRange, setStretch, step
 
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
getGraph, getSize, getVertices, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DAGLayout

public DAGLayout(Graph<V,E> g)
Method Detail

setRoot

public void setRoot(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(Dimension size)
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.

Specified by:
setSize in interface Layout<V,E>
Overrides:
setSize in class SpringLayout<V,E>

initialize

public void initialize()
Had to override this one as well, to ensure that setRoot() is called.

Specified by:
initialize in interface Layout<V,E>
Overrides:
initialize in class SpringLayout<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 class SpringLayout<V,E>

done

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

Specified by:
done in interface IterativeContext
Overrides:
done in class SpringLayout<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:
setLocation in class AbstractLayout<V,E>

setLocation

public void setLocation(V picked,
                        Point2D p)
Override forceMove so that if someone moves a node, we can re-layout everything.

Specified by:
setLocation in interface Layout<V,E>
Overrides:
setLocation in class AbstractLayout<V,E>

relaxEdges

protected void relaxEdges()
Overridden relaxEdges. This one reduces the effect of edges between greatly different levels.

Overrides:
relaxEdges in class SpringLayout<V,E>


Copyright © 2008 null. All Rights Reserved.