|
JGraph |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgraph.layout.organic.JGraphFastOrganicLayout
public class JGraphFastOrganicLayout
This layout is an implementation of "Graph Drawing by Force-Directed
Placement" by Fruchterman and Reingold (1991). FR layouts are a variation on
the basic Eades et al Spring Embedded layout. The paper states that
"distributing vertices evenly, making edge lengths uniform, and reflecting
symmetry" are its target aims. The variation from the basic embedded is that
the attractive force is proportional to the square of the spring length, the
natural spring length being zero and the repulsive force is linear with the
distance between the nodes. FR layouts are better suited to well connected
graphs.
The computational effort per iteration is quadratic, O(|N|^2+|E|). This is
due to the way all nodes calculate repulsion from all others. The three user
variables are forceConstant
,initialTemp
and
maxIteration
.forceConstant
is the constant k
in the paper and affects the radius around each node around which other nodes
would be in equilibrium. initialTemp
sets the start
temperature of the layout, lower values limit the displacement of each node
on each iteration. maxIteration
sets the total number of
iterations of the layout that occur.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.jgraph.layout.JGraphLayout |
---|
JGraphLayout.Stoppable |
Field Summary | |
---|---|
protected double[][] |
cellLocation
An array of locally stored co-ordinate positions for the vertices |
protected double[] |
dispX
An array of locally stored X co-ordinate displacements for the vertices |
protected double[] |
dispY
An array of locally stored Y co-ordinate displacements for the vertices |
protected double |
forceConstant
The force constant by which the attractive forces are divided and the replusive forces are multiple by the square of. |
protected double |
forceConstantSquared
Cache of forceConstant ^2 for performance |
protected double |
initialTemp
Start value of temperature |
protected boolean[] |
isMoveable
Local copy of isMoveable |
protected int |
iteration
Current iteration count |
protected int |
maxIterations
Total number of iterations to run the layout though |
protected double |
minDistanceLimit
prevents from dividing with zero |
protected double |
minDistanceLimitSquared
cached version of minDistanceLimit squared |
protected int[][] |
neighbours
Local copy of cell neighbours |
protected JGraphLayoutProgress |
progress
An object to monitor and control progress. |
protected double[] |
radius
The approximate radius of each cell, nodes only |
protected double[] |
radiusSquared
The approximate radius squared of each cell, nodes only |
protected double |
temperature
Temperature to limit displacement at later stages of layout |
protected Object[] |
vertexArray
An array of all vertices to be laid out |
Fields inherited from interface com.jgraph.layout.JGraphLayout |
---|
VERSION |
Constructor Summary | |
---|---|
JGraphFastOrganicLayout()
|
Method Summary | |
---|---|
void |
calcAttraction()
Calculates the attractive forces between all laid out nodes linked by edges |
void |
calcPositions()
Takes the displacements calculated for each cell and applies them to the local cache of cell positions. |
void |
calcRepulsion()
Calculates the repulsive forces between all laid out nodes |
double |
getForceConstant()
|
double |
getInitialTemp()
|
int |
getMaxIterations()
|
JGraphLayoutProgress |
getProgress()
Returns the progress object that represents the progress of the current layout run. |
void |
run(JGraphFacade graph)
Executes the Fruchterman-Reingold layout using the graph description from the specified facade |
void |
setForceConstant(double forceConstant)
|
void |
setInitialTemp(double initialTemp)
|
void |
setMaxIterations(int maxIterations)
|
String |
toString()
Returns Fast Organic , the name of this algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double forceConstant
protected double forceConstantSquared
forceConstant
^2 for performance
protected double temperature
protected double initialTemp
protected int iteration
protected int maxIterations
protected Object[] vertexArray
protected double[] dispX
protected double[] dispY
protected double[][] cellLocation
protected double[] radius
protected double[] radiusSquared
protected boolean[] isMoveable
protected int[][] neighbours
protected JGraphLayoutProgress progress
protected double minDistanceLimit
protected double minDistanceLimitSquared
minDistanceLimit
squared
Constructor Detail |
---|
public JGraphFastOrganicLayout()
Method Detail |
---|
public JGraphLayoutProgress getProgress()
JGraphLayout.Stoppable
By convention, the layout must check the isStopped method in its
inner-most loops and return immediately if the method returns
true
.
getProgress
in interface JGraphLayout.Stoppable
public void run(JGraphFacade graph)
run
in interface JGraphLayout
graph
- the facade describing the graph to be acted uponpublic void calcPositions()
public void calcAttraction()
public void calcRepulsion()
public double getForceConstant()
public void setForceConstant(double forceConstant)
forceConstant
- The forceConstant to set.public int getMaxIterations()
public void setMaxIterations(int maxIterations)
maxIterations
- The maxIterations to set.public double getInitialTemp()
public void setInitialTemp(double initialTemp)
initialTemp
- The initialTemp to set.public String toString()
Fast Organic
, the name of this algorithm.
toString
in class Object
|
JGraph |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |