Search this API

y.layout.hierarchic
Class HierarchicGroupLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.hierarchic.HierarchicLayouter
          extended by y.layout.hierarchic.HierarchicGroupLayouter
All Implemented Interfaces:
Layouter, PortConstraintKeys

public class HierarchicGroupLayouter
extends HierarchicLayouter

This layout algorithm arranges grouped graphs in a hierarchic fashion. This class is an extended variant of HierarchicLayouter that is able to handle groups.

More precisely, this layout algorithm is capable of laying out nested groups of nodes as well as the group nodes themselves.

The grouping information is provided through DataProvider instances, which are registered with the graph instance using keys GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY.

Layout Style

The nodes are distributed into layers such that most of the edges point to the main layout direction. The order of the nodes within the layers ensures that the number of edge crossings is as small as possible. There are different edge routing styles available. Edges can be orthogonal or polyline.

Hierarchical diagrams are commonly used for the visualization of hierarchical data, since they facilitate the identification of dependencies and relationships among the nodes of the graph. Possible application domains are the following: workflow visualization, call graph visualization, entity-relationship diagrams, biochemical pathways and network management.


Hierarchic group layout obtained with default settings

Concept

The layout is being calculated recursively for each group. The size of the group nodes is determined by the area occupied by the children of the group node.

For more details about how each group is being laid out, refer to superclass HierarchicLayouter.

Features

HierarchicGroupLayouter supports all the features of superclass HierarchicLayouter. In addition, it can be specified whether or not strong port constraints at group nodes should be scaled to the same amount as the sizes of the group nodes are modified by using setStrongPortsScalingActive(boolean). Also, a GroupBoundsCalculator that controls the sizes of the group nodes can be specified using setGroupBoundsCalculator(GroupBoundsCalculator).

 
Your browser does not support SVG content.

Field Summary
 
Fields inherited from class y.layout.hierarchic.HierarchicLayouter
LAYERING_BFS, LAYERING_FROM_SKETCH, LAYERING_HIERARCHICAL_DOWNSHIFT, LAYERING_HIERARCHICAL_OPTIMAL, LAYERING_HIERARCHICAL_TIGHT_TREE, LAYERING_HIERARCHICAL_TOPMOST, LAYERING_STRATEGY_UNKNOWN, LAYERING_USER_DEFINED, LINEAR_SEGMENTS, MEDIAN_SIMPLEX, PENDULUM, POLYLINE, ROUTE_ORTHOGONAL, ROUTE_POLYLINE, SIMPLEX, TREE
 
Fields inherited from interface y.layout.PortConstraintKeys
SOURCE_GROUPID_KEY, SOURCE_PORT_CONSTRAINT_KEY, SOURCE_PORT_GROUP_ID_DPKEY, TARGET_GROUPID_KEY, TARGET_PORT_CONSTRAINT_KEY, TARGET_PORT_GROUP_ID_DPKEY
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
HierarchicGroupLayouter()
          Creates an instance of HierarchicGroupLayouter with default settings.
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Accepts general graphs without exceptions.
 void doLayout(LayoutGraph graph)
          Calculates a hierarchic layout for the given graph.
 void doLayoutCore(LayoutGraph graph)
          Arranges the graph in a hierarchic fashion.
 Drawer getDrawer()
          Returns the Drawer instance responsible for assigning the coordinates to the nodes (third phase of the layout algorithm).
 GroupBoundsCalculator getGroupBoundsCalculator()
          Returns the GroupBoundsCalculator instance.
protected  Grouping getGrouping()
          Returns the associated Grouping instance.
 Layerer getLayerer()
          Returns the Layerer instance responsible for generating the layer assignment (first phase of the layout algorithm).
protected  NodeList[] getLayerSequence(LayoutGraph graph, NodeMap layerID, int maxLayer)
          Determines the order of the nodes within their layers.
 LayerSequencer getLayerSequencer()
          Returns the LayerSequencer instance responsible for calculating the sequence of nodes within each layer (second phase of the layout algorithm).
 boolean isGlobalSequencingActive()
          Returns whether or not a global sequencing heuristic should be applied.
 boolean isStrongPortsScalingActive()
          Returns whether or not strong port constraints at group nodes should be interpreted as coordinates that should be scaled to the same amount as the sizes of the group nodes are modified.
protected  java.awt.geom.Rectangle2D layoutLevel(Node root, NodeList levelNodes, boolean buildGraphsOnly)
          Calculates the layout of the children of a given root recursively.
 void setDrawer(Drawer drawer)
          Specifies the Drawer instance responsible for assigning the coordinates to the nodes (third phase of the layout algorithm).
 void setGlobalSequencingActive(boolean globalSequencingActive)
          Determines whether or not a global sequencing heuristic should be applied.
 void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
          Specifies the GroupBoundsCalculator instance.
 void setLayerer(Layerer layerer)
          Specifies the Layerer instance responsible for generating the layer assignment (first phase of the layout algorithm).
 void setLayeringStrategy(byte strategy)
          Specifies the layering strategy of this layout algorithm.
 void setLayerSequencer(LayerSequencer sequencer)
          Specifies the LayerSequencer instance responsible for calculating the sequence of nodes within each layer (second phase of the layout algorithm).
 void setLayoutStyle(byte style)
          Specifies the layout style of this layout algorithm.
 void setStrongPortsScalingActive(boolean strongPortsScalingActive)
          Specifies whether or not strong port constraints at group nodes should be interpreted as coordinates that should be scaled to the same amount as the sizes of the group nodes are modified.
 
Methods inherited from class y.layout.hierarchic.HierarchicLayouter
disposeMementoSupport, getBendReductionThreshold, getLayeringStrategy, getLayoutStyle, getMaximalDuration, getMementoSupport, getMinimalEdgeDistance, getMinimalFirstSegmentLength, getMinimalLayerDistance, getMinimalNodeDistance, getRemoveFalseCrossings, getRoutingStyle, isPortConstraintOptimizationEnabled, isSameLayerEdgeRoutingOptimizationEnabled, setBendReductionThreshold, setMaximalDuration, setMinimalEdgeDistance, setMinimalFirstSegmentLength, setMinimalLayerDistance, setMinimalNodeDistance, setPortConstraintOptimizationEnabled, setRemoveFalseCrossings, setRoutingStyle, setSameLayerEdgeRoutingOptimizationEnabled
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, 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
 

Constructor Detail

HierarchicGroupLayouter

public HierarchicGroupLayouter()
Creates an instance of HierarchicGroupLayouter with default settings.

Method Detail

getGrouping

protected Grouping getGrouping()
Returns the associated Grouping instance.

Returns:
the associated Grouping instance

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Accepts general graphs without exceptions.

Overrides:
canLayoutCore in class HierarchicLayouter
Parameters:
graph - the input graph
Returns:
true for all input graphs

doLayoutCore

public void doLayoutCore(LayoutGraph graph)
Arranges the graph in a hierarchic fashion.

Overrides:
doLayoutCore in class HierarchicLayouter
 
The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph.
Parameters:
graph - the input graph

layoutLevel

protected java.awt.geom.Rectangle2D layoutLevel(Node root,
                                                NodeList levelNodes,
                                                boolean buildGraphsOnly)
Calculates the layout of the children of a given root recursively.

Parameters:
root - the current root node (parent, invisible during layout)
levelNodes - the NodeList containing the nodes that will be laid out
buildGraphsOnly - For internal use only
Returns:
the bounding box of the layout

doLayout

public void doLayout(LayoutGraph graph)
Calculates a hierarchic layout for the given graph.

Specified by:
doLayout in interface Layouter
Overrides:
doLayout in class CanonicMultiStageLayouter
 
The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph.
 
This method is not side effect free in the sense that the order of edges or nodes in the input graph may change during the layout process.
Parameters:
graph - the input graph
See Also:
CanonicMultiStageLayouter.appendStage(LayoutStage), CanonicMultiStageLayouter.prependStage(LayoutStage), CanonicMultiStageLayouter.doLayoutCore(LayoutGraph)

setLayerSequencer

public void setLayerSequencer(LayerSequencer sequencer)
Description copied from class: HierarchicLayouter
Specifies the LayerSequencer instance responsible for calculating the sequence of nodes within each layer (second phase of the layout algorithm).

Overrides:
setLayerSequencer in class HierarchicLayouter
Parameters:
sequencer - the given LayerSequencer instance

setLayerer

public void setLayerer(Layerer layerer)
Description copied from class: HierarchicLayouter
Specifies the Layerer instance responsible for generating the layer assignment (first phase of the layout algorithm).

Overrides:
setLayerer in class HierarchicLayouter
Parameters:
layerer - the given Layerer instance

getLayerer

public Layerer getLayerer()
Description copied from class: HierarchicLayouter
Returns the Layerer instance responsible for generating the layer assignment (first phase of the layout algorithm).

Overrides:
getLayerer in class HierarchicLayouter
Returns:
the current Layerer instance
See Also:
HierarchicLayouter.setLayerer(Layerer)

getLayerSequencer

public LayerSequencer getLayerSequencer()
Description copied from class: HierarchicLayouter
Returns the LayerSequencer instance responsible for calculating the sequence of nodes within each layer (second phase of the layout algorithm).

Overrides:
getLayerSequencer in class HierarchicLayouter
Returns:
the current LayerSequencer instance
See Also:
HierarchicLayouter.setLayerSequencer(LayerSequencer)

getGroupBoundsCalculator

public GroupBoundsCalculator getGroupBoundsCalculator()
Returns the GroupBoundsCalculator instance.

By specifying an instance of the GroupBoundsCalculator interface, one can control the sizes of the group nodes. For every group of nodes which is in its open state, the instance will be asked to calculate the bounds for the given child nodes. The resulting size will be used during the ongoing layout.

Returns:
the GroupBoundsCalculator instance
See Also:
setGroupBoundsCalculator(GroupBoundsCalculator)

setGroupBoundsCalculator

public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Specifies the GroupBoundsCalculator instance.

By specifying an instance of the GroupBoundsCalculator interface, one can control the sizes of the group nodes. For every group of nodes which is in its open state, the instance will be asked to calculate the bounds for the given child nodes. The resulting size will be used during the ongoing layout.

Parameters:
groupBoundsCalculator - the GroupBoundsCalculator instance

setDrawer

public void setDrawer(Drawer drawer)
Specifies the Drawer instance responsible for assigning the coordinates to the nodes (third phase of the layout algorithm).

The Drawer is responsible for the layout style of this layout algorithm.

Overrides:
setDrawer in class HierarchicLayouter
Parameters:
drawer - the given Drawer instance

getDrawer

public Drawer getDrawer()
Returns the Drawer instance responsible for assigning the coordinates to the nodes (third phase of the layout algorithm).

The Drawer is responsible for the layout style of this layout algorithm.

Overrides:
getDrawer in class HierarchicLayouter
Returns:
the current Drawer instance
See Also:
setDrawer(Drawer)

setLayoutStyle

public void setLayoutStyle(byte style)
Specifies the layout style of this layout algorithm.

Overrides:
setLayoutStyle in class HierarchicLayouter
Default Value:
The default value is HierarchicLayouter.LINEAR_SEGMENTS. Edges will be drawn with at most two bends per edge.
Parameters:
style - one of the predefined layout styles
Throws:
java.lang.IllegalArgumentException - if an unknown layout style is used

setLayeringStrategy

public void setLayeringStrategy(byte strategy)
Specifies the layering strategy of this layout algorithm.

Overrides:
setLayeringStrategy in class HierarchicLayouter
Default Value:
The default value is HierarchicLayouter.LAYERING_HIERARCHICAL_TIGHT_TREE
Parameters:
strategy - one of the predefined layering strategies
Throws:
java.lang.IllegalArgumentException - if an unknown strategy is used

isStrongPortsScalingActive

public boolean isStrongPortsScalingActive()
Returns whether or not strong port constraints at group nodes should be interpreted as coordinates that should be scaled to the same amount as the sizes of the group nodes are modified.

Returns:
true if strong port constraints should be scaled, false otherwise
See Also:
setStrongPortsScalingActive(boolean)

setStrongPortsScalingActive

public void setStrongPortsScalingActive(boolean strongPortsScalingActive)
Specifies whether or not strong port constraints at group nodes should be interpreted as coordinates that should be scaled to the same amount as the sizes of the group nodes are modified.

Default Value:
The default value is true. Strong port constraints should be scaled.
Parameters:
strongPortsScalingActive - true if strong port constraints should be scaled, false otherwise

getLayerSequence

protected NodeList[] getLayerSequence(LayoutGraph graph,
                                      NodeMap layerID,
                                      int maxLayer)
Determines the order of the nodes within their layers.

This method is called in doLayoutCore(LayoutGraph) in order to assign the sizes of the group nodes after the layering has been completed. At the end, the layer sequence will be calculated by the superclass. It may be overridden to get a hook into the layout algorithm.

Overrides:
getLayerSequence in class HierarchicLayouter
Parameters:
graph - the input graph
layerID - the NodeMap that returns the zero-based index of the layer to which each node belongs
maxLayer - the number of layers
Returns:
an array of NodeLists containing nodes that belong to the same layer; the order of the nodes within each such list represents the sequence of the nodes within their layer

isGlobalSequencingActive

public boolean isGlobalSequencingActive()
Returns whether or not a global sequencing heuristic should be applied.

If this heuristic is disabled, the sequence of the nodes in each group will be considered independently, while if it is enabled the sequencing will be performed by taking into consideration all groups.

Returns:
true if a global sequencing heuristic should be applied, false otherwise
See Also:
setGlobalSequencingActive(boolean)

setGlobalSequencingActive

public void setGlobalSequencingActive(boolean globalSequencingActive)
Determines whether or not a global sequencing heuristic should be applied.

If this heuristic is disabled, the sequence of the nodes in each group will be considered independently, while if it is enabled the sequencing will be performed by taking into consideration all groups.

Parameters:
globalSequencingActive - true if a global sequencing heuristic should be applied, false otherwise
Sample Graphs:

false

true

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