com.mindfusion.diagramming
Class SpringLayout

java.lang.Object
  extended by com.mindfusion.diagramming.SpringLayout
All Implemented Interfaces:
Layout

public class SpringLayout
extends java.lang.Object
implements Layout

Implements the Spring-Embedder graph layout algorithm. Spring-Embedder produces layouts having uniform distribution of nodes by simulating a physical system in which nodes repulse each other and the links between them act as confining springs. Nodes are moved around in an iterative process. The forces that act on a node are calculated, taking in account the positions of surrounding nodes and links from the previous iteration.


Constructor Summary
SpringLayout()
          Initializes a new instance of the SpringLayout class.
SpringLayout(int iterationCount, float nodeDistance, boolean minimizeCrossings)
          Initializes a new instance of the SpringLayout class.
SpringLayout(int iterationCount, float nodeDistance, boolean minimizeCrossings, boolean keepGroupLayout)
          Initializes a new instance of the SpringLayout class.
 
Method Summary
 boolean arrange(Diagram chart)
          Arranges the specified flowchart.
 int getAnchoring()
          Gets a value indicating how arrows will be aligned to the anchor points of tree nodes.
 boolean getEnableClusters()
          Gets a value indicating whether the layout algorithm should place nodes into distinct clusters.
 int getIterations()
          Gets the number of iterations that the layout algorithm should run.
 boolean getKeepGroupLayout()
          Gets a value specifying whether the relative position of nodes within groups should be kept intact.
 boolean getMinimizeCrossings()
          Gets a value indicating whether the algorithm should try to minimize the number of arrow crossings.
 float getNodeDistance()
          Gets how much space should be left between adjacent nodes.
 int getRandomSeed()
          Gets the randomization seed used for generating random node positions.
 double getRepulsionFactor()
          Gets a multiplier value applied to the repulsive force between nodes.
 void setAnchoring(int value)
          Sets a value indicating how arrows should be aligned to the anchor points of tree nodes.
 void setEnableClusters(boolean value)
          Sets a value indicating whether the layout algorithm should place nodes into distinct clusters.
 void setIterations(int value)
          Sets the number of iterations that the layout algorithm should run.
 void setKeepGroupLayout(boolean value)
          Sets a value specifying whether the relative position of nodes within groups should be kept intact.
 void setMinimizeCrossings(boolean value)
          Sets a value indicating whether the algorithm should try to minimize the number of arrow crossings.
 void setNodeDistance(float value)
          Sets how much space should be left between adjacent nodes.
 void setRandomSeed(int value)
          Sets the randomization seed that should be used for generating random node positions.
 void setRepulsionFactor(double value)
          Sets a multiplier value applied to the repulsive force between nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringLayout

public SpringLayout()
Initializes a new instance of the SpringLayout class.


SpringLayout

public SpringLayout(int iterationCount,
                    float nodeDistance,
                    boolean minimizeCrossings)
Initializes a new instance of the SpringLayout class.

Parameters:
iterationCount - The number of iterations that the layout algorithm should run.
nodeDistance - The desired distance between nodes.
minimizeCrossings - true to minimize arrow crossings, otherwise false.

SpringLayout

public SpringLayout(int iterationCount,
                    float nodeDistance,
                    boolean minimizeCrossings,
                    boolean keepGroupLayout)
Initializes a new instance of the SpringLayout class.

Parameters:
iterationCount - The number of iterations that the layout algorithm should run.
nodeDistance - The desired distance between nodes.
minimizeCrossings - true to minimize arrow crossings, otherwise false.
keepGroupLayout - true if the relative position of nodes within groups should be preserved, otherwise false.
Method Detail

arrange

public boolean arrange(Diagram chart)
Arranges the specified flowchart.

Specified by:
arrange in interface Layout
Parameters:
chart - The Diagram to arrange.
Returns:
true

getKeepGroupLayout

public boolean getKeepGroupLayout()
Gets a value specifying whether the relative position of nodes within groups should be kept intact.

Returns:
true if the relative position of nodes within groups should be preserved, otherwise false.

setKeepGroupLayout

public void setKeepGroupLayout(boolean value)
Sets a value specifying whether the relative position of nodes within groups should be kept intact.

Parameters:
value - true if the relative position of nodes within groups should be preserved, otherwise false.

getIterations

public int getIterations()
Gets the number of iterations that the layout algorithm should run.

Returns:
An integer value specifying the number of iterations.

setIterations

public void setIterations(int value)
Sets the number of iterations that the layout algorithm should run.

Parameters:
value - An integer value specifying the number of iterations.

getNodeDistance

public float getNodeDistance()
Gets how much space should be left between adjacent nodes.

Returns:
A float value specifying the desired node distance.

setNodeDistance

public void setNodeDistance(float value)
Sets how much space should be left between adjacent nodes.

Parameters:
value - A float value specifying the desired node distance.

getMinimizeCrossings

public boolean getMinimizeCrossings()
Gets a value indicating whether the algorithm should try to minimize the number of arrow crossings.

Returns:
true if the layout routine will try to minimize the number of arrow crossings, otherwise false.

setMinimizeCrossings

public void setMinimizeCrossings(boolean value)
Sets a value indicating whether the algorithm should try to minimize the number of arrow crossings.

Parameters:
value - true if the layout routine should try to minimize the number of arrow crossings, otherwise false.

getEnableClusters

public boolean getEnableClusters()
Gets a value indicating whether the layout algorithm should place nodes into distinct clusters.

Returns:
true if nodes will be placed in clusters when possible, otherwise false.

setEnableClusters

public void setEnableClusters(boolean value)
Sets a value indicating whether the layout algorithm should place nodes into distinct clusters.

Parameters:
value - true if nodes should be placed in clusters when possible, otherwise false.

getRepulsionFactor

public double getRepulsionFactor()
Gets a multiplier value applied to the repulsive force between nodes.

Returns:
A float value by which the repulsive force between nodes is multiplied.

setRepulsionFactor

public void setRepulsionFactor(double value)
Sets a multiplier value applied to the repulsive force between nodes.

Parameters:
value - A float value by which the repulsive force between nodes is multiplied.

getRandomSeed

public int getRandomSeed()
Gets the randomization seed used for generating random node positions.

Returns:
An integer value specifying the randomization seed.

setRandomSeed

public void setRandomSeed(int value)
Sets the randomization seed that should be used for generating random node positions.

Parameters:
value - An integer value specifying the randomization seed.

getAnchoring

public int getAnchoring()
Gets a value indicating how arrows will be aligned to the anchor points of tree nodes.

Returns:
One of the Anchoring constants.

setAnchoring

public void setAnchoring(int value)
Sets a value indicating how arrows should be aligned to the anchor points of tree nodes.

Parameters:
value - One of the Anchoring constants.