com.jgraph.layout.graph
public class JGraphSpringLayout extends Object implements JGraphLayout, JGraphLayout.Stoppable
Deprecated: use JGraphFastOrganicLayout instead
A basic Spring Embedded Layout Algorithm. Edges on the graph represent spring. All the springs have a natural length, measured in the same units as the screen co-ordination system, which they attempt to achieve constantly. If the spring is shorter than its natural length it extends, pushing the nodes are either end of the edge apart. If the spring is longer than its natural length it contracts, pulling the nodes at either end of the edge together. The force exerted by the spring is proportional to different between its current length and its natural length. A force multiple is also applied indicating the "strength" of the spring. In addition, all nodes repel each other with a force inversely proportional to the distance between each other. The repelling force is mutliplied by a replusive force factor. The whole affect is to cause nodes to space out fairly evenly but for nodes linked by edges ( springs ) to cluster togetherField Summary | |
---|---|
protected double[] | cellLocationX
An array of locally stored X co-ordinate positions for the vertices |
protected double[] | cellLocationY
An array of locally stored Y co-ordinate positions for the vertices |
protected Map | displacement
Stores the temporary positions of each cell during the layout |
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 boolean[] | isMoveable
Local copy of isMoveable |
protected int | iteration
current iteration number |
protected int | maxIterations
total number of iterations to step through when running |
protected int[][] | neighbours
Local copy of cell neighbours |
protected JGraphLayoutProgress | progress
An object to monitor and control progress. |
protected double | replusiveForce
The multiple by which the force replusive each pair of nodes scaled by
Increase to make nodes force further apart |
protected double | springForce
The multiple of force applied to the attraction of springs |
protected double | springLength
The natural length of the spring (edge) whereby it imparts no force
on either connected node |
protected Object[] | vertexArray
An array of all vertices to be laid out |
Constructor Summary | |
---|---|
JGraphSpringLayout()
Creates a new layout of 50 iterations
| |
JGraphSpringLayout(int iterations)
Creates a new spring layout to be executed over the specified number
of iterations |
Method Summary | |
---|---|
protected void | attract()
Calculates an attractive force between the cells connected by the
specified edge |
int | getMaxIterations() |
JGraphLayoutProgress | getProgress() |
double | getReplusiveForce() |
double | getSpringForce() |
double | getSpringLength() |
protected void | reposition(JGraphFacade graph)
repositions the specified cells using the positioning
data obtained through repulse and attract phases |
protected void | repulse()
Calculates a repulsion force between the specified cells
and stores the cumulative displacement applied to each cell |
void | run(JGraphFacade graph)
Executes the spring layout of the specified facade data
|
void | setMaxIterations(int iterations) |
void | setReplusiveForce(double replusiveForce) |
void | setSpringForce(double springForce) |
void | setSpringLength(double springLength) |
String | toString()
Returns Spring , the name of this algorithm. |
Parameters: iterations the number of layout iterations to execute
Returns: Returns the total number of iterations.
Returns: Returns the progress.
Returns: Returns the replusiveForce.
Returns: Returns the springForce.
Returns: Returns the springLength.
Parameters: graph the description of the graph to be laid out
Parameters: graph the description of the graph to be acted upon
Parameters: iterations the value to set maxIterations
to
Parameters: replusiveForce The replusiveForce to set.
Parameters: springForce The springForce to set.
Parameters: springLength The springLength to set.
Spring
, the name of this algorithm.