com.mindfusion.diagramming
Class LayeredLayout

java.lang.Object
  extended by com.mindfusion.diagramming.AbstractLayout
      extended by com.mindfusion.diagramming.LayeredLayout

public class LayeredLayout
extends AbstractLayout

Implements a layered graph layout algorithm. This algorithm assigns diagram nodes to distinct horizontal or vertical layers. While arranging the layers, the layout routine seeks to meet the following criteria:


Constructor Summary
LayeredLayout()
          Initializes a new instance of the LayeredLayout class.
LayeredLayout(int orientation, float layerDistance, float nodeDistance, float xGap, float yGap)
          Initializes a new instance of the LayeredLayout class.
 
Method Summary
 boolean arrange(Diagram diagram, DiagramItemList items)
          Arranges the specified flowchart.
 int getDirection()
          Gets a value indicating in what direction the arrows in the arranged diagram should go.
 boolean getEnableCustomLayers()
          Gets a value indicating whether to indicating whether the layered layout will honor the LayeredLayoutTraits.Layer flags.
 DiagramNode getEndNode()
          Gets the node that should be placed in the last layer of the arranged graph.
 boolean getEnforceLinkFlow()
          Gets a value indicating whether to attempt to force all links to go in the same direction.
 boolean getIgnoreNodeSize()
          Gets a value indicating whether the distance between adjacent nodes in the final layout should be independent of the nodes' size.
 boolean getKeepGroupLayout()
          Gets a value specifying whether the relative position of nodes within groups should be kept intact.
 float getLayerDistance()
          Gets the desired distance between adjacent layers.
 float getLinksCompactFactor()
          Gets a value indicating how much to compact the outermost arrows.
 int getLinkType()
          Gets the appearance of the links in the final layout.
 float getNodeDistance()
          Gets the desired distance between adjacent nodes on the same layer.
 int getOrientation()
          Gets a value indicating what the overall orientation of the arranged diagram should be.
 boolean getSplitLayers()
          Gets a value indicating whether layers that are much wider than the other layers should be split.
 DiagramNode getStartNode()
          Gets the node that should be placed in the first layer of the arranged graph.
 LayeredLayoutStatistics getStatistics()
          Gets layout-specific information about the nodes and links participating in the layout.
 boolean getStraightenLongLinks()
           
 long getTimeLimit()
          Gets the time-out value set for the path-finding part of the layered layout algorithm.
 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 setDirection(int value)
          Sets a value indicating in what direction the arrows in the arranged diagram should go.
 void setEnableCustomLayers(boolean value)
          Sets a value indicating whether to indicating whether the layered layout will honor the LayeredLayoutTraits.Layer flags.
 void setEndNode(DiagramNode value)
          Sets the node that should be placed in the last layer of the arranged graph.
 void setEnforceLinkFlow(boolean value)
          Sets a value indicating whether to attempt to force all links to go in the same direction.
 void setIgnoreNodeSize(boolean value)
          Sets a value indicating whether the distance between adjacent nodes in the final layout should be independent of the nodes' size.
 void setKeepGroupLayout(boolean value)
          Sets a value specifying whether the relative position of nodes within groups should be kept intact.
 void setLayerDistance(float value)
          Sets the desired distance between adjacent layers.
 void setLinksCompactFactor(float value)
          Sets a value indicating how much to compact the outermost arrows.
 void setLinkType(int value)
          Sets the appearance of the links in the final layout.
 void setNodeDistance(float value)
          Sets the desired distance between adjacent nodes on the same layer.
 void setOrientation(int value)
          Sets a value indicating what the overall orientation of the arranged diagram should be.
 void setSplitLayers(boolean value)
          Sets a value indicating whether layers that are much wider than the other layers should be split.
 void setStartNode(DiagramNode value)
          Sets the node that should be placed in the first layer of the arranged graph.
 void setStraightenLongLinks(boolean value)
           
 void setTimeLimit(long value)
          Sets a time-out value for the path-finding part of the layered layout algorithm.
 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 com.mindfusion.diagramming.AbstractLayout
arrange, getAnchoring, getLayoutLink, getLayoutNode, getMargins, getMultipleGraphsPlacement, getProgress, removeMidleSegmentPoint, setAnchoring, setLayoutLink, setLayoutNode, setMargins, setMultipleGraphsPlacement, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayeredLayout

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


LayeredLayout

public LayeredLayout(int orientation,
                     float layerDistance,
                     float nodeDistance,
                     float xGap,
                     float yGap)
Initializes a new instance of the LayeredLayout class.

Parameters:
orientation - One of the Orientation constants.
layerDistance - A float value specifying the desired distance between adjacent layers.
nodeDistance - A float value specifying the desired distance between adjacent nodes.
xGap - A float value specifying the horizontal offset from the left document bound.
yGap - A float value specifying the vertical offset from the top document bound.
Method Detail

arrange

public boolean arrange(Diagram diagram,
                       DiagramItemList items)
Arranges the specified flowchart.

Specified by:
arrange in class AbstractLayout
Parameters:
diagram - The Diagram to arrange.
items - A collection of nodes and links from diagram that define the subgraph to arrange.
Returns:
true

getKeepGroupLayout

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

Overrides:
getKeepGroupLayout in class AbstractLayout
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.

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

getOrientation

public int getOrientation()
Gets a value indicating what the overall orientation of the arranged diagram should be.

Returns:
One of the Orientation constants.

setOrientation

public void setOrientation(int value)
Sets a value indicating what the overall orientation of the arranged diagram should be.

Parameters:
value - One of the Orientation constants.

getDirection

public int getDirection()
Gets a value indicating in what direction the arrows in the arranged diagram should go.

Returns:
One of the Direction constants.

setDirection

public void setDirection(int value)
Sets a value indicating in what direction the arrows in the arranged diagram should go.

Parameters:
value - One of the Direction constants.

getLayerDistance

public float getLayerDistance()
Gets the desired distance between adjacent layers.

Returns:
A float value specifying the distance between adjacent layers.

setLayerDistance

public void setLayerDistance(float value)
Sets the desired distance between adjacent layers.

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

getNodeDistance

public float getNodeDistance()
Gets the desired distance between adjacent nodes on the same layer.

Returns:
A float value specifying the distance between adjacent nodes.

setNodeDistance

public void setNodeDistance(float value)
Sets the desired distance between adjacent nodes on the same layer.

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

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.

getSplitLayers

public boolean getSplitLayers()
Gets a value indicating whether layers that are much wider than the other layers should be split.

Returns:
true if long layers will be split, otherwise false.

setSplitLayers

public void setSplitLayers(boolean value)
Sets a value indicating whether layers that are much wider than the other layers should be split.

Parameters:
value - true if long layers should be split, otherwise false.

getLinksCompactFactor

public float getLinksCompactFactor()
Gets a value indicating how much to compact the outermost arrows.

Returns:
A float multiplier applied to the distance between outermost arrows.

setLinksCompactFactor

public void setLinksCompactFactor(float value)
Sets a value indicating how much to compact the outermost arrows.

Parameters:
value - A float multiplier applied to the distance between outermost arrows.

getTimeLimit

public long getTimeLimit()
Gets the time-out value set for the path-finding part of the layered layout algorithm.

Returns:
An integer value specifying the maximum time in milliseconds the path-finding algorithm can run.

setTimeLimit

public void setTimeLimit(long value)
Sets a time-out value for the path-finding part of the layered layout algorithm.

Parameters:
value - An integer value specifying the maximum time in milliseconds the path-finding algorithm can run.

getIgnoreNodeSize

public boolean getIgnoreNodeSize()
Gets a value indicating whether the distance between adjacent nodes in the final layout should be independent of the nodes' size.


setIgnoreNodeSize

public void setIgnoreNodeSize(boolean value)
Sets a value indicating whether the distance between adjacent nodes in the final layout should be independent of the nodes' size.


getEnableCustomLayers

public boolean getEnableCustomLayers()
Gets a value indicating whether to indicating whether the layered layout will honor the LayeredLayoutTraits.Layer flags.


setEnableCustomLayers

public void setEnableCustomLayers(boolean value)
Sets a value indicating whether to indicating whether the layered layout will honor the LayeredLayoutTraits.Layer flags.


getLinkType

public int getLinkType()
Gets the appearance of the links in the final layout.

Returns:
One of the LayeredLayoutLinkType constants.

setLinkType

public void setLinkType(int value)
Sets the appearance of the links in the final layout.

Parameters:
value - One of the LayeredLayoutLinkType constants.

getStatistics

public LayeredLayoutStatistics getStatistics()
Gets layout-specific information about the nodes and links participating in the layout.


getEnforceLinkFlow

public boolean getEnforceLinkFlow()
Gets a value indicating whether to attempt to force all links to go in the same direction. If the graph being arrange has cycles, some of the links will still go backward. EnableCustomLayers and SplitLayers are ignored if this property is set to true.


setEnforceLinkFlow

public void setEnforceLinkFlow(boolean value)
Sets a value indicating whether to attempt to force all links to go in the same direction. If the graph being arrange has cycles, some of the links will still go backward. EnableCustomLayers and SplitLayers are ignored if this property is set to true.


getStraightenLongLinks

public boolean getStraightenLongLinks()

setStraightenLongLinks

public void setStraightenLongLinks(boolean value)

getStartNode

public DiagramNode getStartNode()
Gets the node that should be placed in the first layer of the arranged graph.

Returns:
Reference to the start DiagramNode.

setStartNode

public void setStartNode(DiagramNode value)
Sets the node that should be placed in the first layer of the arranged graph.

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

getEndNode

public DiagramNode getEndNode()
Gets the node that should be placed in the last layer of the arranged graph.

Returns:
Reference to the end DiagramNode.

setEndNode

public void setEndNode(DiagramNode value)
Sets the node that should be placed in the last layer of the arranged graph. This value is honored only if a start node is specified too.

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