Search this API

y.layout.grouping
Class RecursiveGroupLayouter

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.grouping.RecursiveGroupLayouter
All Implemented Interfaces:
Layouter, LayoutStage

public class RecursiveGroupLayouter
extends AbstractLayoutStage

Recursively traverses a hierarchically organized graph in a bottom-up fashion and applies the given layout algorithm (i.e. the core layouter) to the contents of each group node. The size of the group nodes can be further determined by setting a customized GroupBoundsCalculator implementation.

Note that this class can be run without a core layouter instance. In this case no layout is calculated, instead the group node bounds are merely adjusted to fit their respective contents. There are two alternatives for applying different layout styles to the contents of group nodes: 1. Map each group node to the corresponding layouter using data provider key GROUP_NODE_LAYOUTER_DPKEY. The content of the hierarchy root is laid out with the core layouter. 2. Alternatively you can use a LayoutMultiplexer as core layouter.


Field Summary
static Object GROUP_NODE_LAYOUTER_DPKEY
          DataProvider key used to retrieve a Layouter instance for each group node.
static Layouter NULL_LAYOUTER
          A constant that represents a layouter implementation that does nothing.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
RecursiveGroupLayouter()
          Creates a new instance of RecursiveGroupLayouter.
RecursiveGroupLayouter(Layouter core)
          Creates a new instance of RecursiveGroupLayouter using the given layout algorithm.
RecursiveGroupLayouter(Layouter core, GroupBoundsCalculator gbc)
          Creates a new instance of RecursiveGroupLayouter using the given layout algorithm and GroupBoundsCalculator implementation.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true iff the given graph can be laid out by this algorithm.
 void doLayout(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
 GroupBoundsCalculator getGroupBoundsCalculator()
          Returns the currently installed GroupBoundsCalculator instance.
 boolean isAutoAssignPortCandidatesEnabled()
          Returns whether or not temporary port candidates should be inserted.
 boolean isConsiderEmptyGroupsEnabled()
          Returns whether or not group nodes without children are handled the same way as group nodes with children.
 boolean isConsiderSketchEnabled()
          Whether or not to consider the initial coordinates of the graph elements.
protected  void routeInterEdges(LayoutGraph graph, EdgeList interEdges)
          This method is called after calculating the overall layout and reroutes the inter-edges, i.e., edges which traverse the boundary of a group node.
 void setAutoAssignPortCandidatesEnabled(boolean autoAssignPortCandidatesEnabled)
          Whether or not temporary port candidates should be inserted.
 void setConsiderEmptyGroupsEnabled(boolean enabled)
          Specifies whether or not group nodes without children are handled the same way as group nodes with children.
 void setConsiderSketchEnabled(boolean considerSketchEnabled)
          Sets whether or not to consider the initial coordinates of the graph elements.
 void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
          Sets a new GroupBoundsCalculator instance that applies to all encountered group nodes.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_NODE_LAYOUTER_DPKEY

public static final Object GROUP_NODE_LAYOUTER_DPKEY
DataProvider key used to retrieve a Layouter instance for each group node. The specified layouter instance is applied to the content of the group node. For the top level elements the core layouter is used. If the data provider returns "null" the corresponding group node is handled non-recursive, i.e., the group node and its content is laid out with the Layouter instance specified by the nearest predecessor of the group node (with respect to the grouping hierarchy) which is associated with a layouter. If the content of a group node should not be changed, the group node can be associated with a "null" layouter, e.g., constant NULL_LAYOUTER.


NULL_LAYOUTER

public static final Layouter NULL_LAYOUTER
A constant that represents a layouter implementation that does nothing.

Constructor Detail

RecursiveGroupLayouter

public RecursiveGroupLayouter()
Creates a new instance of RecursiveGroupLayouter.


RecursiveGroupLayouter

public RecursiveGroupLayouter(Layouter core)
Creates a new instance of RecursiveGroupLayouter using the given layout algorithm.


RecursiveGroupLayouter

public RecursiveGroupLayouter(Layouter core,
                              GroupBoundsCalculator gbc)
Creates a new instance of RecursiveGroupLayouter using the given layout algorithm and GroupBoundsCalculator implementation.

Method Detail

isConsiderSketchEnabled

public boolean isConsiderSketchEnabled()
Whether or not to consider the initial coordinates of the graph elements.

See Also:
setConsiderSketchEnabled(boolean)

setConsiderSketchEnabled

public void setConsiderSketchEnabled(boolean considerSketchEnabled)
Sets whether or not to consider the initial coordinates of the graph elements. This option should be enabled if the recursive group layouter uses a layouter that runs in "from sketch mode". If it is enabled, the recursive group layouter sets the coordinates of the node elements to their initial position before the corresponding layouter is called. By default this option is disabled.

Parameters:
considerSketchEnabled - whether to consider the initial coordinates of the graph elements.

isAutoAssignPortCandidatesEnabled

public boolean isAutoAssignPortCandidatesEnabled()
Returns whether or not temporary port candidates should be inserted. If this option is enabled the recursive group layouter specifies fixed port candidates for inter-edges (edges which traverse the boundary of a group node) at their source and target node. Without these port candidates the route of inter-edges always ends at the border/center of the corresponding group node. Hence, enabling this option may produce more suitable edge routes if the layout algorithm applied to the content of a group node can handle port candidates. Note: predefined port candidates are always satisfied, even if this option is disabled (only if the applied layouter supports them).

See Also:
setAutoAssignPortCandidatesEnabled(boolean), routeInterEdges(y.layout.LayoutGraph, y.base.EdgeList)

setAutoAssignPortCandidatesEnabled

public void setAutoAssignPortCandidatesEnabled(boolean autoAssignPortCandidatesEnabled)
Whether or not temporary port candidates should be inserted. If this option is enabled the recursive group layouter specifies fixed port candidates for inter-edges (edges which traverse the boundary of a group node) at their source and target node. Without these port candidates the route of inter-edges always ends at the border/center of the corresponding group node. Hence, enabling this option may produce more suitable edge routes if the layout algorithm applied to the content of a group node can handle port candidates. Note: predefined port candidates are always satisfied, even if this option is disabled (only if the applied layouter supports them).

Parameters:
autoAssignPortCandidatesEnabled - whether or not temporary port candidates should be inserted.
See Also:
routeInterEdges(y.layout.LayoutGraph, y.base.EdgeList)

isConsiderEmptyGroupsEnabled

public boolean isConsiderEmptyGroupsEnabled()
Returns whether or not group nodes without children are handled the same way as group nodes with children. Defaults to true.

Returns:
true if group nodes without children are handled the same way as group nodes with children; false if group nodes without children are handled the same way as normal (non-group) nodes.
See Also:
setConsiderEmptyGroupsEnabled(boolean), routeInterEdges(y.layout.LayoutGraph, y.base.EdgeList)

setConsiderEmptyGroupsEnabled

public void setConsiderEmptyGroupsEnabled(boolean enabled)
Specifies whether or not group nodes without children are handled the same way as group nodes with children. Defaults to true.

Parameters:
enabled - if true group nodes without children are handled the same way as group nodes with children; if false group nodes without children are handled the same way as normal (non-group) nodes.
See Also:
isConsiderEmptyGroupsEnabled(), routeInterEdges(y.layout.LayoutGraph, y.base.EdgeList)

canLayout

public boolean canLayout(LayoutGraph graph)
Description copied from interface: Layouter
Returns true iff the given graph can be laid out by this algorithm. Calling doLayout with the given graph as its argument will only success if this method returns true.


doLayout

public void doLayout(LayoutGraph graph)
Description copied from interface: Layouter
Main layout routine that assigns new layout information to the given graph.


routeInterEdges

protected void routeInterEdges(LayoutGraph graph,
                               EdgeList interEdges)
This method is called after calculating the overall layout and reroutes the inter-edges, i.e., edges which traverse the boundary of a group node. More precisely, if those edges do not have port candidates/constraints or the applied layout algorithm does not support this kind of constraints (see setAutoAssignPortCandidatesEnabled(boolean)), the route of inter-edges always ends at the border/center of the corresponding group node. This method identifies such edges and routes them straight-line.

Parameters:
graph - the input graph.
interEdges - the edges which traverse the boundary of a group node.
See Also:
setAutoAssignPortCandidatesEnabled(boolean)

getGroupBoundsCalculator

public GroupBoundsCalculator getGroupBoundsCalculator()
Returns the currently installed GroupBoundsCalculator instance.

Returns:
The GroupBoundsCalculator instance.

setGroupBoundsCalculator

public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Sets a new GroupBoundsCalculator instance that applies to all encountered group nodes.

Parameters:
groupBoundsCalculator - New GroupBoundsCalculator instance.

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