com.mindfusion.diagramming
Class GridLayout

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

public class GridLayout
extends java.lang.Object
implements Layout

Implements a grid graph layout algorithm. GridLayout arranges diagram nodes in a grid, keeping connected nodes close together. The algorithm strives to achieve a small number of arrow crossings. It is based on an iterative process whose initial steps shuffle the grid nodes randomly. That can lead to very different results each time the algorithm is run.


Constructor Summary
GridLayout()
          Initializes a new instance of the GridLayout 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.
 DiagramNode getEndNode()
          Gets the node that should be placed at the bottom right corner of the grid.
 float getGridSize()
          Gets the desired distance between adjacent grid points.
 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.
 int getRandomSeed()
          Gets the randomization seed used for generating random node positions.
 DiagramNode getStartNode()
          Gets the node that should be placed at the upper left corner of the grid.
 float getXGap()
          Gets a value indicating how much horizontal space should be left between the document boundaries and the graph.
 float getYGap()
          Gets a value indicating how much vertical space should be left between the document boundaries and the graph.
 void setAnchoring(int value)
          Sets a value indicating how arrows should be aligned to the anchor points of tree nodes.
 void setEndNode(DiagramNode value)
          Sets the node that should be placed at the bottom right corner of the grid.
 void setGridSize(float value)
          Sets the desired distance between adjacent grid points.
 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 setRandomSeed(int value)
          Sets the randomization seed used for generating random node positions.
 void setStartNode(DiagramNode value)
          Sets the node that should be placed at the upper left corner of the grid.
 void setXGap(float value)
          Sets a value indicating how much horizontal space should be left between the document boundaries and the graph.
 void setYGap(float value)
          Sets a value indicating how much vertical space should be left between the document boundaries and the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridLayout

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

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

getStartNode

public DiagramNode getStartNode()
Gets the node that should be placed at the upper left corner of the grid.

Returns:
Reference to the start DiagramNode.

setStartNode

public void setStartNode(DiagramNode value)
Sets the node that should be placed at the upper left corner of the grid. If you set the start node, you should also call the setEndNode(com.mindfusion.diagramming.DiagramNode) method to specify the end node. GridLayout usually produces better layouts if you do not specify start and end nodes; in such a case the algorithm automatically selects suitable nodes.

Parameters:
value - A DiagramNode object representing the grid start node.

getEndNode

public DiagramNode getEndNode()
Gets the node that should be placed at the bottom right corner of the grid.

Returns:
Reference to the end DiagramNode.

setEndNode

public void setEndNode(DiagramNode value)
Sets the node that should be placed at the bottom right corner of the grid. If you set the end node, you should also call the setStartNode(com.mindfusion.diagramming.DiagramNode) method to specify the start node. GridLayout usually produces better layouts if you do not specify start and end nodes; in such a case the algorithm automatically selects suitable nodes.

Parameters:
value - A DiagramNode object representing the grid end node.

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.

getGridSize

public float getGridSize()
Gets the desired distance between adjacent grid points.

Returns:
A float value specifying the distance between adjacent grid points.

setGridSize

public void setGridSize(float value)
Sets the desired distance between adjacent grid points.

Parameters:
value - A float value specifying the distance between adjacent grid points.

getXGap

public float getXGap()
Gets a value indicating how much horizontal space should be left between the document boundaries and the graph.

Returns:
A float value specifying the horizontal offset from the left document bound.

setXGap

public void setXGap(float value)
Sets a value indicating how much horizontal space should be left between the document boundaries and the graph.

Parameters:
value - A float value specifying the horizontal offset from the left document bound.

getYGap

public float getYGap()
Gets a value indicating how much vertical space should be left between the document boundaries and the graph.

Returns:
A float value specifying the vertical offset from the top document bound.

setYGap

public void setYGap(float value)
Sets a value indicating how much vertical space should be left between the document boundaries and the graph.

Parameters:
value - A float value specifying the vertical offset from the top document bound.

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 used for generating random node positions.

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

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.

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.