Search this API

y.layout.tree
Class TreeLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.tree.TreeLayouter
All Implemented Interfaces:
Layouter

public class TreeLayouter
extends CanonicMultiStageLayouter

Implementation of a layout algorithm for trees.

Here is an sample output of the layouter using left to right orientation and ORTHOGONAL_STYLE layout style.


Field Summary
static int BORDER_CENTER_PORTS
          Port style constant.
static int BORDER_DISTRIBUTED_PORTS
          Port style constant.
static byte CHILD_PLACEMENT_POLICY_ALL_LEAVES_ON_SAME_LAYER
          Symbolic child placement policy specifier.
static byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED
          Symbolic child placement policy specifier.
static byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT
          Symbolic child placement policy specifier.
static byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT_AND_RIGHT
          Symbolic child placement policy specifier.
static byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED_RIGHT
          Symbolic child placement policy specifier.
static byte CHILD_PLACEMENT_POLICY_SIBLINGS_ON_SAME_LAYER
          Symbolic child placement policy specifier.
static int NODE_CENTER_PORTS
          Port style constant.
static int ORTHOGONAL_STYLE
          Layout style constant.
static int PLAIN_STYLE
          Layout style constant.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
TreeLayouter()
          Creates a new instance of TreeLayouter.
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Returns true iff the core layouter can layout the given graph structure.
 void doLayoutCore(LayoutGraph graph)
          Starts the tree layout process
 double getBusAlignment()
          Returns the actual set bus alignment.
 byte getChildPlacementPolicy()
          Returns the layout policy for leaf nodes.
 Comparator getComparator()
          Returns the comparator for outgoing edges at a node This comparator defines the relative order of the child nodes in the layout to be calculated.
 int getLayoutStyle()
          Returns the layout style of this layouter.
 double getMinimalLayerDistance()
          Returns the minimal distance between adjacent layers for the layout.
 double getMinimalNodeDistance()
          Returns the minimum horizontal distance between adjacent nodes for this layouter.
 AbstractRotatableNodePlacer.Matrix getModificationMatrix()
          Return the modification matrix that is used to rotate / mirror the tree layout.
 int getPortStyle()
          Gets the port assignment style.
 double getVerticalAlignment()
          Returns the relative vertical alignment of nodes within their respective layers.
 boolean isEnforceGlobalLayering()
          Returns whether or not global layering is enforced.
 boolean isGroupingSupported()
          Returns true if grouping support is enabled.
 boolean isIntegratedEdgeLabelingEnabled()
          Returns whether integrated edge labeling is enabled.
 boolean isIntegratedNodeLabelingEnabled()
          Returns whether integrated node labeling is enabled.
 void setBusAlignment(double busAlignment)
          Sets the vertical alignment of the bus
 void setChildPlacementPolicy(byte policy)
          Sets the layout policy for leaf nodes.
 void setComparator(Comparator c)
          Sets the comparator for outgoing edges at a node This comparator defines the relative order of the child nodes in the layout to be calculated.
 void setEnforceGlobalLayering(boolean enabled)
          Specifies whether or not global layering is enforced.
 void setGroupingSupported(boolean groupingSupported)
          Whether or not grouping support should be enabled.
 void setIntegratedEdgeLabelingEnabled(boolean integratedEdgeLabelingEnabled)
          Sets whether integrated edge labeling is enabled
 void setIntegratedNodeLabelingEnabled(boolean integratedNodeLabelingEnabled)
          Sets whether integrated node labeling is enabled
 void setLayoutStyle(int style)
          Sets the layout style of this layouter.
 void setMinimalLayerDistance(double dist)
          Sets the minimal distance between adjacent layers for the layout.
 void setMinimalNodeDistance(double dist)
          Sets the minimum distance between adjacent nodes within a layer.
 void setModificationMatrix(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Sets the modification matrix that is used to rotate / mirror the tree layout.
 void setPortStyle(int style)
          Sets the port assignment style.
 void setVerticalAlignment(double verticalAlignment)
          Sets the relative vertical alignment of nodes within their respective layers.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODE_CENTER_PORTS

public static final int NODE_CENTER_PORTS
Port style constant. Uses (0,0) as port offset.

See Also:
setPortStyle(int), Constant Field Values

BORDER_CENTER_PORTS

public static final int BORDER_CENTER_PORTS
Port style constant. Ports will lie at the center of a node border.

See Also:
setPortStyle(int), Constant Field Values

BORDER_DISTRIBUTED_PORTS

public static final int BORDER_DISTRIBUTED_PORTS
Port style constant. Ports will be distributed evenly on the side of a node.

See Also:
setPortStyle(int), Constant Field Values

PLAIN_STYLE

public static final int PLAIN_STYLE
Layout style constant. Draw edges as straight lines.

See Also:
getLayoutStyle(), setLayoutStyle(int), Constant Field Values

ORTHOGONAL_STYLE

public static final int ORTHOGONAL_STYLE
Layout style constant. Draw edges orthogonally in a bus-like fashion.

See Also:
getLayoutStyle(), setLayoutStyle(int), Constant Field Values

CHILD_PLACEMENT_POLICY_LEAVES_STACKED

public static final byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED
Symbolic child placement policy specifier. This setting configures the algorithm for a stacked style of leaf nodes. In this context, stacked means that leaf nodes that connect to the same root node are placed one upon the other. This results in horizontally compact layouts. Additionally, this policy tries to balance stack heights. I.e. for each subtree that consists of leaf nodes only, CHILD_PLACEMENT_POLICY_LEAVES_STACKED_RIGHT or CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT_AND_RIGHT will be used depending on the number of leaves in the subtree.

See Also:
getChildPlacementPolicy(), setChildPlacementPolicy(byte), Constant Field Values

CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT

public static final byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT
Symbolic child placement policy specifier. This setting configures the algorithm for a stacked style of leaf nodes. In this context, stacked means that leaf nodes that connect to the same root node are placed one upon the other. This results in horizontally compact layouts. Moreover, the stack of leaf nodes is on the left.

See Also:
getChildPlacementPolicy(), setChildPlacementPolicy(byte), Constant Field Values

CHILD_PLACEMENT_POLICY_LEAVES_STACKED_RIGHT

public static final byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED_RIGHT
Symbolic child placement policy specifier. This setting configures the algorithm for a stacked style of leaf nodes. In this context, stacked means that leaf nodes that connect to the same root node are placed one upon the other. This results in horizontally compact layouts. Moreover, the stack of leaf nodes is on the right.

See Also:
getChildPlacementPolicy(), setChildPlacementPolicy(byte), Constant Field Values

CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT_AND_RIGHT

public static final byte CHILD_PLACEMENT_POLICY_LEAVES_STACKED_LEFT_AND_RIGHT
Symbolic child placement policy specifier. This setting configures the algorithm for a stacked style of leaf nodes. In this context, stacked means that leaf nodes that connect to the same root node are placed one upon the other. This results in horizontally compact layouts. Moreover, leaf nodes are distributed among two stacks, one on the left and one on the right.

See Also:
getChildPlacementPolicy(), setChildPlacementPolicy(byte), Constant Field Values

CHILD_PLACEMENT_POLICY_ALL_LEAVES_ON_SAME_LAYER

public static final byte CHILD_PLACEMENT_POLICY_ALL_LEAVES_ON_SAME_LAYER
Symbolic child placement policy specifier. This results in a Dendrogram-style layout with all leaf nodes being placed in one layer (i.e. all leaves are being placed on one horizontal line in a top to bottom or bottom to top layout). A Dendrogram layout is often applied in computational biology in order to show clustering of genes.

See Also:
getChildPlacementPolicy(), setChildPlacementPolicy(byte), Constant Field Values

CHILD_PLACEMENT_POLICY_SIBLINGS_ON_SAME_LAYER

public static final byte CHILD_PLACEMENT_POLICY_SIBLINGS_ON_SAME_LAYER
Symbolic child placement policy specifier. This setting configures the algorithm to place siblings (leaf nodes with the same parent node) in the same layer (i.e. siblings are being placed on one horizontal line in a top to bottom or bottom to top layout).

See Also:
getChildPlacementPolicy(), setChildPlacementPolicy(byte), Constant Field Values
Constructor Detail

TreeLayouter

public TreeLayouter()
Creates a new instance of TreeLayouter.

Method Detail

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Returns true iff the core layouter can layout the given graph structure. This is the case iff the graph is a tree.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter

isEnforceGlobalLayering

public boolean isEnforceGlobalLayering()
Returns whether or not global layering is enforced. If this feature is enabled, the algorithm ensures that nodes never span more than one layer. Otherwise, a large node might span two, three, etc layers of smaller nodes to produce a more compact layout.

Disabling this feature to generate more compact layouts will usually result in the algorithm ignoring the specified relative vertical alignment for nodes.

By default, this feature is enabled.

Returns:
true if global layering is enforced and false otherwise.
See Also:
setEnforceGlobalLayering(boolean)

setEnforceGlobalLayering

public void setEnforceGlobalLayering(boolean enabled)
Specifies whether or not global layering is enforced. If this feature is enabled, the algorithm ensures that nodes never span more than one layer. Otherwise, a large node might span two, three, etc layers of smaller nodes to produce a more compact layout.

Disabling this feature to generate more compact layouts will usually result in the algorithm ignoring the specified relative vertical alignment for nodes.

By default, this feature is enabled.

Parameters:
enabled - if true global layering is enforced.
See Also:
isEnforceGlobalLayering(), getVerticalAlignment(), setVerticalAlignment(double)

getChildPlacementPolicy

public byte getChildPlacementPolicy()
Returns the layout policy for leaf nodes.

Defaults to CHILD_PLACEMENT_POLICY_SIBLINGS_ON_SAME_LAYER.

Returns:
one of
See Also:
setChildPlacementPolicy(byte)

setChildPlacementPolicy

public void setChildPlacementPolicy(byte policy)
Sets the layout policy for leaf nodes.

Defaults to CHILD_PLACEMENT_POLICY_SIBLINGS_ON_SAME_LAYER.

Throws:
IllegalArgumentException - if the specified policy does not match one of the leaf layout policy constants.
Parameters:
policy - one of
See Also:
getChildPlacementPolicy()

isGroupingSupported

public boolean isGroupingSupported()
Returns true if grouping support is enabled. Note that the grouping only works correctly, if each group represents a complete subtree. This means that for each group there is a node v such that the group contains exactly v and all its descendants.


setGroupingSupported

public void setGroupingSupported(boolean groupingSupported)
Whether or not grouping support should be enabled. Note that the grouping only works correctly, if each group represents a complete subtree. This means that for each group there is a node v such that the group contains exactly v and all its descendants.

Parameters:
groupingSupported - if true, grouping support is enabled.

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Starts the tree layout process

Specified by:
doLayoutCore in class CanonicMultiStageLayouter

setComparator

public void setComparator(Comparator c)
Sets the comparator for outgoing edges at a node This comparator defines the relative order of the child nodes in the layout to be calculated. By default XCoordComparator is set.


getComparator

public Comparator getComparator()
Returns the comparator for outgoing edges at a node This comparator defines the relative order of the child nodes in the layout to be calculated.


setPortStyle

public void setPortStyle(int style)
Sets the port assignment style.

Parameters:
style - one of the constants NODE_CENTER_PORTS, BORDER_CENTER_PORTS, or BORDER_DISTRIBUTED_PORTS.

getPortStyle

public int getPortStyle()
Gets the port assignment style.

See Also:
setPortStyle(int)

setLayoutStyle

public void setLayoutStyle(int style)
Sets the layout style of this layouter.

See Also:
PLAIN_STYLE, ORTHOGONAL_STYLE

getLayoutStyle

public int getLayoutStyle()
Returns the layout style of this layouter.


setMinimalNodeDistance

public void setMinimalNodeDistance(double dist)
Sets the minimum distance between adjacent nodes within a layer. Default value is 20.0.


getMinimalNodeDistance

public double getMinimalNodeDistance()
Returns the minimum horizontal distance between adjacent nodes for this layouter.


setMinimalLayerDistance

public void setMinimalLayerDistance(double dist)
Sets the minimal distance between adjacent layers for the layout. Default value is 40.0.


getMinimalLayerDistance

public double getMinimalLayerDistance()
Returns the minimal distance between adjacent layers for the layout.


isIntegratedNodeLabelingEnabled

public boolean isIntegratedNodeLabelingEnabled()
Returns whether integrated node labeling is enabled.

Returns:
whether integrated node labeling is enabled.

setIntegratedNodeLabelingEnabled

public void setIntegratedNodeLabelingEnabled(boolean integratedNodeLabelingEnabled)
Sets whether integrated node labeling is enabled


isIntegratedEdgeLabelingEnabled

public boolean isIntegratedEdgeLabelingEnabled()
Returns whether integrated edge labeling is enabled.

Returns:
whether integrated edge labeling is enabled.

setIntegratedEdgeLabelingEnabled

public void setIntegratedEdgeLabelingEnabled(boolean integratedEdgeLabelingEnabled)
Sets whether integrated edge labeling is enabled


getBusAlignment

public double getBusAlignment()
Returns the actual set bus alignment. The bus alignment represents the position of the "bus" within the spacing between the layers (getMinimalLayerDistance()). 0: the bus is a the top of the space between the layers 0.5: the bus is exactly in the middle 1: the bus is at the bottom

Returns:
the bus alignment (0.0 - 1.0)

setBusAlignment

public void setBusAlignment(double busAlignment)
Sets the vertical alignment of the bus

Parameters:
busAlignment - (between 0 and 1). Default is 0.3.

getVerticalAlignment

public double getVerticalAlignment()
Returns the relative vertical alignment of nodes within their respective layers. A value of 0 means nodes are top aligned; a value of 1 means nodes are bottom aligned.

If global layering is not enforced, the value of this property is usually ignored.

Defaults to 0.5, i.e. nodes are center aligned.

Returns:
the relative vertical alignment of nodes within their respective layers.
See Also:
setVerticalAlignment(double), isEnforceGlobalLayering(), setEnforceGlobalLayering(boolean)

setVerticalAlignment

public void setVerticalAlignment(double verticalAlignment)
Sets the relative vertical alignment of nodes within their respective layers. A value of 0 means nodes are top aligned; a value of 1 means nodes are bottom aligned.

If global layering is not enforced, the value of this property is usually ignored.

Defaults to 0.5, i.e. nodes are center aligned.

Parameters:
verticalAlignment - a value in [0, 1].
See Also:
getVerticalAlignment(), isEnforceGlobalLayering(), setEnforceGlobalLayering(boolean)

setModificationMatrix

public void setModificationMatrix(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Sets the modification matrix that is used to rotate / mirror the tree layout.


getModificationMatrix

public AbstractRotatableNodePlacer.Matrix getModificationMatrix()
Return the modification matrix that is used to rotate / mirror the tree layout.


© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.