Class JGraphSpringLayout

java.lang.Object
com.jgraph.layout.graph.JGraphSpringLayout
All Implemented Interfaces:
JGraphLayout, JGraphLayout.Stoppable

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 together
  • Nested Class Summary

    Nested classes/interfaces inherited from interface JGraphLayout

    JGraphLayout.Stoppable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double[]
    Deprecated.
    An array of locally stored X co-ordinate positions for the vertices
    protected double[]
    Deprecated.
    An array of locally stored Y co-ordinate positions for the vertices
    protected Map
    Deprecated.
    Stores the temporary positions of each cell during the layout
    protected double[]
    Deprecated.
    An array of locally stored X co-ordinate displacements for the vertices
    protected double[]
    Deprecated.
    An array of locally stored Y co-ordinate displacements for the vertices
    protected boolean[]
    Deprecated.
    Local copy of isMoveable
    protected int
    Deprecated.
    current iteration number
    protected int
    Deprecated.
    total number of iterations to step through when running
    protected int[][]
    Deprecated.
    Local copy of cell neighbours
    Deprecated.
    An object to monitor and control progress.
    protected double
    Deprecated.
    The multiple by which the force replusive each pair of nodes scaled by Increase to make nodes force further apart
    protected double
    Deprecated.
    The multiple of force applied to the attraction of springs
    protected double
    Deprecated.
    The natural length of the spring (edge) whereby it imparts no force on either connected node
    protected Object[]
    Deprecated.
    An array of all vertices to be laid out

    Fields inherited from interface JGraphLayout

    VERSION
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Creates a new layout of 50 iterations
    JGraphSpringLayout(int iterations)
    Deprecated.
    Creates a new spring layout to be executed over the specified number of iterations
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Deprecated.
    Calculates an attractive force between the cells connected by the specified edge
    int
    Deprecated.
     
    Deprecated.
    Returns the progress object that represents the progress of the current layout run.
    double
    Deprecated.
     
    double
    Deprecated.
     
    double
    Deprecated.
     
    protected void
    Deprecated.
    repositions the specified cells using the positioning data obtained through repulse and attract phases
    protected void
    Deprecated.
    Calculates a repulsion force between the specified cells and stores the cumulative displacement applied to each cell
    void
    Deprecated.
    Executes the spring layout of the specified facade data
    void
    setMaxIterations(int iterations)
    Deprecated.
     
    void
    setReplusiveForce(double replusiveForce)
    Deprecated.
     
    void
    setSpringForce(double springForce)
    Deprecated.
     
    void
    setSpringLength(double springLength)
    Deprecated.
     
    Deprecated.
    Returns Spring, the name of this algorithm.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • displacement

      protected transient Map displacement
      Deprecated.
      Stores the temporary positions of each cell during the layout
    • replusiveForce

      protected double replusiveForce
      Deprecated.
      The multiple by which the force replusive each pair of nodes scaled by Increase to make nodes force further apart
    • springForce

      protected double springForce
      Deprecated.
      The multiple of force applied to the attraction of springs
    • springLength

      protected double springLength
      Deprecated.
      The natural length of the spring (edge) whereby it imparts no force on either connected node
    • iteration

      protected int iteration
      Deprecated.
      current iteration number
    • maxIterations

      protected int maxIterations
      Deprecated.
      total number of iterations to step through when running
    • vertexArray

      protected Object[] vertexArray
      Deprecated.
      An array of all vertices to be laid out
    • dispX

      protected double[] dispX
      Deprecated.
      An array of locally stored X co-ordinate displacements for the vertices
    • dispY

      protected double[] dispY
      Deprecated.
      An array of locally stored Y co-ordinate displacements for the vertices
    • cellLocationX

      protected double[] cellLocationX
      Deprecated.
      An array of locally stored X co-ordinate positions for the vertices
    • cellLocationY

      protected double[] cellLocationY
      Deprecated.
      An array of locally stored Y co-ordinate positions for the vertices
    • isMoveable

      protected boolean[] isMoveable
      Deprecated.
      Local copy of isMoveable
    • neighbours

      protected int[][] neighbours
      Deprecated.
      Local copy of cell neighbours
    • progress

      protected JGraphLayoutProgress progress
      Deprecated.
      An object to monitor and control progress.
  • Constructor Details

    • JGraphSpringLayout

      public JGraphSpringLayout()
      Deprecated.
      Creates a new layout of 50 iterations
    • JGraphSpringLayout

      public JGraphSpringLayout(int iterations)
      Deprecated.
      Creates a new spring layout to be executed over the specified number of iterations
      Parameters:
      iterations - the number of layout iterations to execute
  • Method Details

    • getProgress

      public JGraphLayoutProgress getProgress()
      Deprecated.
      Description copied from interface: JGraphLayout.Stoppable
      Returns the progress object that represents the progress of the current layout run. Once created, this instance should not be replaced during a layout run. For new runs you should use the reset method on the progress. Consequently, the max progress is only valid after the run method has been invoked, which means you should use a listener if you spawn a new thread.

      By convention, the layout must check the isStopped method in its inner-most loops and return immediately if the method returns true.

      Specified by:
      getProgress in interface JGraphLayout.Stoppable
      Returns:
      Returns the progress.
    • run

      public void run(JGraphFacade graph)
      Deprecated.
      Executes the spring layout of the specified facade data
      Specified by:
      run in interface JGraphLayout
      Parameters:
      graph - the description of the graph to be acted upon
    • repulse

      protected void repulse()
      Deprecated.
      Calculates a repulsion force between the specified cells and stores the cumulative displacement applied to each cell
    • attract

      protected void attract()
      Deprecated.
      Calculates an attractive force between the cells connected by the specified edge
    • reposition

      protected void reposition(JGraphFacade graph)
      Deprecated.
      repositions the specified cells using the positioning data obtained through repulse and attract phases
      Parameters:
      graph - the description of the graph to be laid out
    • setMaxIterations

      public void setMaxIterations(int iterations)
      Deprecated.
      Parameters:
      iterations - the value to set maxIterations to
    • getMaxIterations

      public int getMaxIterations()
      Deprecated.
      Returns:
      Returns the total number of iterations.
    • getSpringLength

      public double getSpringLength()
      Deprecated.
      Returns:
      Returns the springLength.
    • setSpringLength

      public void setSpringLength(double springLength)
      Deprecated.
      Parameters:
      springLength - The springLength to set.
    • getSpringForce

      public double getSpringForce()
      Deprecated.
      Returns:
      Returns the springForce.
    • setSpringForce

      public void setSpringForce(double springForce)
      Deprecated.
      Parameters:
      springForce - The springForce to set.
    • getReplusiveForce

      public double getReplusiveForce()
      Deprecated.
      Returns:
      Returns the replusiveForce.
    • setReplusiveForce

      public void setReplusiveForce(double replusiveForce)
      Deprecated.
      Parameters:
      replusiveForce - The replusiveForce to set.
    • toString

      public String toString()
      Deprecated.
      Returns Spring, the name of this algorithm.
      Overrides:
      toString in class Object