com.mindfusion.diagramming
Class TreeLayout

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

public class TreeLayout
extends java.lang.Object
implements Layout

This class can be used to arrange tree-like graphs automatically. It support three layout modes - cascading, centered and radial - which can be enabled via the setType(int) method.


Constructor Summary
TreeLayout()
          Initializes a new instance of the TreeLayout class.
TreeLayout(DiagramNode root)
          Initializes a new instance of the TreeLayout class, specifying which node to use as a tree root.
TreeLayout(DiagramNode root, int type)
          Initializes a new instance of the TreeLayout class, specifying the root node and layout mode.
TreeLayout(DiagramNode root, int type, boolean reversedArrows, int arrowStyle, int direction, float levelDistance, float nodeDistance, boolean keepRootPosition, float xGap, float yGap)
          Initializes a new instance of the TreeLayout class.
TreeLayout(DiagramNode root, int type, boolean reversedArrows, int arrowStyle, int direction, float levelDistance, float nodeDistance, boolean keepRootPosition, float xGap, float yGap, boolean keepGroupLayout)
          Initializes a new instance of the TreeLayout class.
TreeLayout(int type)
          Initializes a new instance of the TreeLayout class, specifying the layout mode.
 
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 getCompactAssistants()
          Gets a value indicating whether the "assistant" nodes on the same side of a single parent are arranged as close enough to each other as possible.
 int getDirection()
          Gets a value indicating in what direction child nodes should be placed relatively to their parent nodes.
 boolean getEnableAssistants()
          Gets a value indicating whether the "assistant" trait is regarded when performing the layout.
 boolean getIgnoreLinkDirection()
          Gets a value indicating whether the direction of arrows should be ignored.
 boolean getKeepGroupLayout()
          Gets a value indicating whether groups of diagram nodes should be treated as integral nodes in the tree that will be laid out.
 boolean getKeepRootPosition()
          Gets a value indicating whether the root node should be kept at its original position.
 float getLevelDistance()
          Gets the desired distance between tree levels.
 int getLinkStyle()
          Gets what style is assigned to the arrows processed by the TreeLayout.
 float getNodeDistance()
          Gets the desired distance between nodes on the same level.
 boolean getReversedLinks()
          Gets a value indicating which direction of arrows should be considered the parent-to-child one.
 DiagramNode getRoot()
          Gets the node which will be used as root of the tree.
 float getStretchFactor()
          Gets a value defining the elliptic factor used with radial layouts.
 int getType()
          Gets the layout mode.
 float getXGap()
          Gets a value indicating how much horizontal space to leave between the document boundaries and the tree.
 float getYGap()
          Gets a value indicating how much vertical space to leave between the document boundaries and the tree.
 void setAnchoring(int value)
          Sets a value indicating how arrows should be aligned to the anchor points of tree nodes.
 void setCompactAssistants(boolean value)
          Sets a value indicating whether the "assistant" nodes on the same side of a single parent are arranged as close enough to each other as possible.
 void setDirection(int value)
          Sets a value indicating in what direction child nodes should be placed relatively to their parent nodes.
 void setEnableAssistants(boolean value)
          Sets a value indicating whether the "assistant" trait is regarded when performing the layout.
 void setIgnoreLinkDirection(boolean value)
          Sets a value indicating whether the direction of arrows should be ignored.
 void setKeepGroupLayout(boolean value)
          Sets a value indicating whether groups of diagram nodes should be treated as integral nodes in the tree that will be laid out.
 void setKeepRootPosition(boolean value)
          Sets a value indicating whether the root node should be kept at its original position.
 void setLevelDistance(float value)
          Sets the desired distance between tree levels.
 void setLinkStyle(int value)
          Sets what style should be assigned to the arrows processed by the layout algorithm.
 void setNodeDistance(float value)
          Sets the desired distance between nodes on the same level.
 void setReversedLinks(boolean value)
          Sets a value indicating which direction of arrows should be considered the parent-to-child one.
 void setRoot(DiagramNode value)
          Sets the object which will be used as root of the tree.
 void setStretchFactor(float value)
          Sets a value defining the elliptic factor used with radial layouts.
 void setType(int value)
          Sets the layout mode.
 void setXGap(float value)
          Sets a value indicating how much horizontal space to leave between the document boundaries and the tree.
 void setYGap(float value)
          Sets a value indicating how much vertical space to leave between the document boundaries and the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeLayout

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


TreeLayout

public TreeLayout(DiagramNode root)
Initializes a new instance of the TreeLayout class, specifying which node to use as a tree root.

Parameters:
root - A DiagramNode -derived object representing the tree root node.

TreeLayout

public TreeLayout(int type)
Initializes a new instance of the TreeLayout class, specifying the layout mode.

Parameters:
type - One of the TreeLayoutType constants.

TreeLayout

public TreeLayout(DiagramNode root,
                  int type)
Initializes a new instance of the TreeLayout class, specifying the root node and layout mode.

Parameters:
root - A DiagramNode -derived object representing the tree root node.
type - One of the TreeLayoutType constants.

TreeLayout

public TreeLayout(DiagramNode root,
                  int type,
                  boolean reversedArrows,
                  int arrowStyle,
                  int direction,
                  float levelDistance,
                  float nodeDistance,
                  boolean keepRootPosition,
                  float xGap,
                  float yGap)
Initializes a new instance of the TreeLayout class.

Parameters:
root - A DiagramNode -derived object representing the tree root node.
type - One of the TreeLayoutType constants.
reversedArrows - true if the parent-to-child direction in the tree is considered to be the one from arrows destination nodes to arrows origin nodes, otherwise false.
arrowStyle - One of the TreeLayoutLinkType constants.
direction - One of the TreeLayoutDirection constants.
levelDistance - A float value specifying the distance between tree levels.
nodeDistance - A float value specifying the distance between sibling nodes.
keepRootPosition - true if the root position should be preserved, otherwise false.
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.

TreeLayout

public TreeLayout(DiagramNode root,
                  int type,
                  boolean reversedArrows,
                  int arrowStyle,
                  int direction,
                  float levelDistance,
                  float nodeDistance,
                  boolean keepRootPosition,
                  float xGap,
                  float yGap,
                  boolean keepGroupLayout)
Initializes a new instance of the TreeLayout class.

Parameters:
root - A DiagramNode -derived object representing the tree root node.
type - One of the TreeLayoutType constants.
reversedArrows - true if the parent-to-child direction in the tree is considered to be the one from arrows destination nodes to arrows origin nodes, otherwise false.
arrowStyle - One of the TreeLayoutLinkType constants.
direction - One of the TreeLayoutDirection constants.
levelDistance - A float value specifying the distance between tree levels.
nodeDistance - A float value specifying the distance between sibling nodes.
keepRootPosition - true if the root position should be preserved, otherwise false.
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.
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 if the tree is arranged successfully, or false if JDiagram cannot find the tree root, e.g. when the IgnoreArrowDirection attribute is enabled and the tree root is not specified by the application.

getRoot

public DiagramNode getRoot()
Gets the node which will be used as root of the tree.

Returns:
A DiagramNode -derived object representing the tree root node.

setRoot

public void setRoot(DiagramNode value)
Sets the object which will be used as root of the tree.

Parameters:
value - A DiagramNode -derived object representing the tree root node.

getType

public int getType()
Gets the layout mode.

Returns:
One of the TreeLayoutType constants.

setType

public void setType(int value)
Sets the layout mode.

Parameters:
value - One of the TreeLayoutType constants.

getLinkStyle

public int getLinkStyle()
Gets what style is assigned to the arrows processed by the TreeLayout.

Returns:
One of the TreeLayoutLinkType constants.

setLinkStyle

public void setLinkStyle(int value)
Sets what style should be assigned to the arrows processed by the layout algorithm.

Parameters:
value - One of the TreeLayoutLinkType constants.

getLevelDistance

public float getLevelDistance()
Gets the desired distance between tree levels.

Returns:
A float value specifying the distance between tree levels.

setLevelDistance

public void setLevelDistance(float value)
Sets the desired distance between tree levels.

Parameters:
value - A float value specifying the distance between tree levels.

getNodeDistance

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

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

setNodeDistance

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

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

getKeepRootPosition

public boolean getKeepRootPosition()
Gets a value indicating whether the root node should be kept at its original position.

Returns:
true if the root position will be preserved, otherwise false.

setKeepRootPosition

public void setKeepRootPosition(boolean value)
Sets a value indicating whether the root node should be kept at its original position.

Parameters:
value - true if the root position should be preserved, otherwise false.

getXGap

public float getXGap()
Gets a value indicating how much horizontal space to leave between the document boundaries and the tree.

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 to leave between the document boundaries and the tree.

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 to leave between the document boundaries and the tree.

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 to leave between the document boundaries and the tree.

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

getStretchFactor

public float getStretchFactor()
Gets a value defining the elliptic factor used with radial layouts.

Returns:
A float multiplier that is applied to the horizontal distance between nodes in a radial layout.

setStretchFactor

public void setStretchFactor(float value)
Sets a value defining the elliptic factor used with radial layouts.

Parameters:
value - A float multiplier that is applied to the horizontal distance between nodes in a radial layout.

getDirection

public int getDirection()
Gets a value indicating in what direction child nodes should be placed relatively to their parent nodes.

Returns:
One of the TreeLayoutDirection constants.

setDirection

public void setDirection(int value)
Sets a value indicating in what direction child nodes should be placed relatively to their parent nodes.

Parameters:
value - One of the TreeLayoutDirection constants.

getReversedLinks

public boolean getReversedLinks()
Gets a value indicating which direction of arrows should be considered the parent-to-child one.

Returns:
true if the parent-to-child direction in the tree is considered to be the one from arrows destination nodes to arrows origin nodes, otherwise false.

setReversedLinks

public void setReversedLinks(boolean value)
Sets a value indicating which direction of arrows should be considered the parent-to-child one.

Parameters:
value - true if the parent-to-child direction in the tree is considered to be the one from arrows destination nodes to arrows origin nodes, otherwise false.

getKeepGroupLayout

public boolean getKeepGroupLayout()
Gets a value indicating whether groups of diagram nodes should be treated as integral nodes in the tree that will be laid out.

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

setKeepGroupLayout

public void setKeepGroupLayout(boolean value)
Sets a value indicating whether groups of diagram nodes should be treated as integral nodes in the tree that will be laid out.

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

getIgnoreLinkDirection

public boolean getIgnoreLinkDirection()
Gets a value indicating whether the direction of arrows should be ignored.

Returns:
true if the direction of arrows will be ignored when arranging a tree, otherwise false.

setIgnoreLinkDirection

public void setIgnoreLinkDirection(boolean value)
Sets a value indicating whether the direction of arrows should be ignored.

Parameters:
value - true if the direction of arrows should be ignored when arranging a tree, 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.

getEnableAssistants

public boolean getEnableAssistants()
Gets a value indicating whether the "assistant" trait is regarded when performing the layout.


setEnableAssistants

public void setEnableAssistants(boolean value)
Sets a value indicating whether the "assistant" trait is regarded when performing the layout.


getCompactAssistants

public boolean getCompactAssistants()
Gets a value indicating whether the "assistant" nodes on the same side of a single parent are arranged as close enough to each other as possible. Turning this off will force the nodes on one side to be aligned with their counterparts in the other and occasionally leaving space between adjacent branches.


setCompactAssistants

public void setCompactAssistants(boolean value)
Sets a value indicating whether the "assistant" nodes on the same side of a single parent are arranged as close enough to each other as possible. Turning this off will force the nodes on one side to be aligned with their counterparts in the other and occasionally leaving space between adjacent branches.