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

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
      extended by edu.uci.ics.jung.algorithms.layout.FRLayout<V,E>
All Implemented Interfaces:
Layout<V,E>, IterativeContext, org.apache.commons.collections15.Transformer<V,Point2D>

public class FRLayout<V,E>
extends AbstractLayout<V,E>
implements IterativeContext

Implements the Fruchterman-Reingold force-directed algorithm for node layout.

Behavior is determined by the following settable parameters:

Each of the first two defaults to 0.75; the maximum number of iterations defaults to 700.

Author:
Scott White, Yan-Biao Boey, Danyel Fisher
See Also:
"Fruchterman and Reingold, 'Graph Drawing by Force-directed Placement'", "http://i11www.ilkd.uni-karlsruhe.de/teaching/SS_04/visualisierung/papers/fruchterman91graph.pdf"

Nested Class Summary
protected static class FRLayout.FRVertexData
           
 
Field Summary
 
Fields inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
graph, initialized, locations, size
 
Constructor Summary
FRLayout(Graph<V,E> g)
          Creates an instance for the specified graph.
FRLayout(Graph<V,E> g, Dimension d)
          Creates an instance of size d for the specified graph.
 
Method Summary
protected  void calcAttraction(E e)
           
protected  void calcPositions(V v)
           
protected  void calcRepulsion(V v1)
           
 boolean done()
          Returns true once the current iteration has passed the maximum count, MAX_ITERATIONS.
protected  FRLayout.FRVertexData getFRData(V v)
           
 void initialize()
          Initializes fields in the node that may not have been set during the constructor.
 boolean isIncremental()
          This one is an incremental visualization.
 void reset()
           
 void setAttractionMultiplier(double attraction)
          Sets the attraction multiplier.
 void setMaxIterations(int maxIterations)
          Sets the maximum number of iterations.
 void setRepulsionMultiplier(double repulsion)
          Sets the repulsion multiplier.
 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.
 void step()
          Moves the iteration forward one notch, calculation attraction and repulsion between vertices and edges and cooling the temperature.
 
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, setLocation, setLocation, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FRLayout

public FRLayout(Graph<V,E> g)
Creates an instance for the specified graph.


FRLayout

public FRLayout(Graph<V,E> g,
                Dimension d)
Creates an instance of size d for the specified graph.

Method Detail

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 AbstractLayout<V,E>

setAttractionMultiplier

public void setAttractionMultiplier(double attraction)
Sets the attraction multiplier.


setRepulsionMultiplier

public void setRepulsionMultiplier(double repulsion)
Sets the repulsion multiplier.


reset

public void reset()
Specified by:
reset in interface Layout<V,E>

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 interface Layout<V,E>

step

public void step()
Moves the iteration forward one notch, calculation attraction and repulsion between vertices and edges and cooling the temperature.

Specified by:
step in interface IterativeContext

calcPositions

protected void calcPositions(V v)

calcAttraction

protected void calcAttraction(E e)

calcRepulsion

protected void calcRepulsion(V v1)

setMaxIterations

public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations.


getFRData

protected FRLayout.FRVertexData getFRData(V v)

isIncremental

public boolean isIncremental()
This one is an incremental visualization.


done

public boolean done()
Returns true once the current iteration has passed the maximum count, MAX_ITERATIONS.

Specified by:
done in interface IterativeContext


Copyright © 2009. All Rights Reserved.