|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgraph.layout.JGraphLayoutAlgorithm
org.jgraph.layout.SpringEmbeddedLayoutAlgorithm
Arranges the nodes with the Spring Embedded Layout Algorithm.
The algorithm takes O(|V|^2 * |E|) time.
Jeremy Jedynak NetCentric Technology Inc www.NetCentricInc.com
This layout algorithm is derived from the one written by Sven Luzar. It fixes
a bug in how the "u" and "v" vectors were stored and retrieved, which
frequently caused IllegalArgumentExceptions and NullPointerExceptions,
depending upon your luck.
Also, the original run method has been broken into several methods. Two new
constructors and methods were added to support two constraints: the graph
rendering frame and maxIterations. Most variable names have been modified for
readability.
It now properly lays out the graph according to the algorithm. Work still
needs to be done to better space vertices so that they do not overlap and so
that edges do not pass through vertices. The new "step" parameter of the run
method is currently not used. All that being said, this is a good starting
point to understand the algorithm and make those changes.
Field Summary | |
static java.lang.String |
SPRING_EMBEDDED_DISP
Key for an attribute. |
static java.lang.String |
SPRING_EMBEDDED_POS
Key for an attribute. |
Fields inherited from class org.jgraph.layout.JGraphLayoutAlgorithm |
LAYOUT_ATTRIBUTES |
Constructor Summary | |
SpringEmbeddedLayoutAlgorithm()
|
|
SpringEmbeddedLayoutAlgorithm(java.awt.Rectangle frame,
int maxIterations)
|
Method Summary | |
protected double |
fa(double x,
double k)
calculates the attractive forces |
protected double |
fr(double x,
double k)
calculates the repulsive forces |
protected double |
norm(java.awt.geom.Rectangle2D p)
Calculates the euklidische Norm for the point p. |
void |
run(JGraph graph,
java.lang.Object[] dynamic_cells,
java.lang.Object[] static_cells)
The implementation of the layout algorithm. |
void |
setFrame(java.awt.Rectangle frame)
|
void |
setMaxIterations(int maxIterations)
|
java.lang.String |
toString()
Returns the name of this algorithm in human readable form. |
Methods inherited from class org.jgraph.layout.JGraphLayoutAlgorithm |
applyLayout, applyLayout, createDialog, createDialog, createSettings, getHint, getMaximumProgress, getProgress, isAllowedToRun, populateDialog, run, setAllowedToRun, setMaximumProgress, setProgress |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String SPRING_EMBEDDED_DISP
public static final java.lang.String SPRING_EMBEDDED_POS
Constructor Detail |
public SpringEmbeddedLayoutAlgorithm()
public SpringEmbeddedLayoutAlgorithm(java.awt.Rectangle frame, int maxIterations)
Method Detail |
public void setFrame(java.awt.Rectangle frame)
public java.lang.String toString()
public void setMaxIterations(int maxIterations)
public void run(JGraph graph, java.lang.Object[] dynamic_cells, java.lang.Object[] static_cells)
run
in class JGraphLayoutAlgorithm
graph
- :
JGraph instancedynamic_cells
- :
List of all nodes the layout should movestatic_cells
- :
List of node the layout should not move but allow forLayoutAlgorithm
protected double fa(double x, double k)
protected double fr(double x, double k)
protected double norm(java.awt.geom.Rectangle2D p)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |