|
JGraphAddons |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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 String |
SPRING_EMBEDDED_DISP
Key for an attribute. |
static String |
SPRING_EMBEDDED_POS
Key for an attribute. |
Fields inherited from class org.jgraph.layout.JGraphLayoutAlgorithm |
LAYOUT_ATTRIBUTES |
Constructor Summary | |
SpringEmbeddedLayoutAlgorithm()
|
|
SpringEmbeddedLayoutAlgorithm(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(Rectangle p)
Calculates the euklidische Norm for the point p. |
void |
run(JGraph jgraph,
Object[] cells,
int step)
The implementation of the layout algorithm. |
void |
setFrame(Rectangle frame)
|
void |
setMaxIterations(int maxIterations)
|
String |
toString()
Returns the name of this algorithm in human readable form. |
Methods inherited from class org.jgraph.layout.JGraphLayoutAlgorithm |
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 String SPRING_EMBEDDED_DISP
public static final String SPRING_EMBEDDED_POS
Constructor Detail |
public SpringEmbeddedLayoutAlgorithm()
public SpringEmbeddedLayoutAlgorithm(Rectangle frame, int maxIterations)
Method Detail |
public void setFrame(Rectangle frame)
public String toString()
toString
in class Object
public void setMaxIterations(int maxIterations)
public void run(JGraph jgraph, Object[] cells, int step)
run
in class JGraphLayoutAlgorithm
LayoutAlgorithm
protected double fa(double x, double k)
protected double fr(double x, double k)
protected double norm(Rectangle p)
|
JGraphAddons |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |