y.layout.hierarchic
Class HierarchicGroupLayouter

java.lang.Object
  |
  +--y.layout.CanonicMultiStageLayouter
        |
        +--y.layout.hierarchic.HierarchicLayouter
              |
              +--y.layout.hierarchic.HierarchicGroupLayouter
All Implemented Interfaces:
Layouter, PortConstraintKeys

public class HierarchicGroupLayouter
extends HierarchicLayouter

This class is an extended variant of the HierarchicLayouter class. It is capable of layouting nested groups of nodes as well as the group nodes themselves. The grouping information is provided through DataProvider instances, which are registered with the LayoutGraph instance. The layout is being calculated recursively. The size of the group nodes is determined by the area occupied by the children of the group node.

Here is a sample output of the algorithm.


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_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, TARGET_GROUPID_KEY, TARGET_PORT_CONSTRAINT_KEY
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
HierarchicGroupLayouter()
          Creates a new instance of HierarchicGroupLayouter
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Always returns true.
 void doLayout(LayoutGraph graph)
          Calculates a layout for the given graph.
 void doLayoutCore(LayoutGraph g)
          Layout the given graph.
 Drawer getDrawer()
          Returns the drawer which is responsible for the third phase of the algorithm
 GroupBoundsCalculator getGroupBoundsCalculator()
          Gets the current GroupBoundsCalculator instance.
protected  Grouping getGrouping()
          Getter for property grouping.
 Layerer getLayerer()
          Returns the currently set Layerer, which is responsible for the first phase of the algorithm.
protected  NodeList[] getLayerSequence(LayoutGraph g, NodeMap LAYER_KEY, int maxLayer)
          Determines the order of the nodes within their layers.
 LayerSequencer getLayerSequencer()
          Returns the currently set LayerSequencer, which is responsible for the second phase of the algorithm.
 boolean isGlobalSequencingActive()
          Returns the current strategy for the node sequencing.
 boolean isStrongPortsScalingActive()
          Gets the property strongPortsScalingActive.
protected  Rectangle2D layoutLevel(Node root, NodeList levelNodes, boolean buildGraphsOnly)
          Layouts the children of root recursively.
 void setDrawer(Drawer drawer)
          Sets the drawer which is responsible for the third phase of the algorithm.
 void setGlobalSequencingActive(boolean globalSequencingActive)
          Determines whether a global sequencing heuristic should be used.
 void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
          Sets the GroupBoundsCalculator instance.
 void setLayerer(Layerer layerer)
          Sets the Layerer, which is responsible for the first phase of the algorithm.
 void setLayeringStrategy(byte strategy)
          Sets a predefined layering strategy.
 void setLayerSequencer(LayerSequencer sequencer)
          Sets the LayerSequencer, which is responsible for the second phase of the algorithm.
 void setLayoutStyle(byte style)
          Sets the layout style for this layouter.
 void setStrongPortsScalingActive(boolean strongPortsScalingActive)
          Sets the property strongPortsScalingActive.
 
Methods inherited from class y.layout.hierarchic.HierarchicLayouter
disposeMementoSupport, getBendReductionThreshold, getLayeringStrategy, getLayoutStyle, getMaximalDuration, getMementoSupport, getMinimalEdgeDistance, getMinimalFirstSegmentLength, getMinimalLayerDistance, getMinimalNodeDistance, getRemoveFalseCrossings, getRoutingStyle, setBendReductionThreshold, setMaximalDuration, setMinimalEdgeDistance, setMinimalFirstSegmentLength, setMinimalLayerDistance, setMinimalNodeDistance, setRemoveFalseCrossings, setRoutingStyle
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, 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 a new instance of HierarchicGroupLayouter

Method Detail

getGrouping

protected Grouping getGrouping()
Getter for property grouping.

Returns:
Value of property grouping.

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Always returns true.

Overrides:
canLayoutCore in class HierarchicLayouter

doLayoutCore

public void doLayoutCore(LayoutGraph g)
Layout the given graph.

Overrides:
doLayoutCore in class HierarchicLayouter

layoutLevel

protected Rectangle2D layoutLevel(Node root,
                                  NodeList levelNodes,
                                  boolean buildGraphsOnly)
Layouts the children of root recursively.

Parameters:
root - The current root node (parent, invisible during layout)
levelNodes - The nodes to be laid out
Returns:
the bounding box of the layout

doLayout

public void doLayout(LayoutGraph graph)
Description copied from class: CanonicMultiStageLayouter
Calculates a layout for the given graph. The given graph will not be copied during the layout process and the layout will be immediatelly 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.

Specified by:
doLayout in interface Layouter
Overrides:
doLayout in class CanonicMultiStageLayouter

setLayerSequencer

public void setLayerSequencer(LayerSequencer sequencer)
Description copied from class: HierarchicLayouter
Sets the LayerSequencer, which is responsible for the second phase of the algorithm.

Overrides:
setLayerSequencer in class HierarchicLayouter

setLayerer

public void setLayerer(Layerer layerer)
Description copied from class: HierarchicLayouter
Sets the Layerer, which is responsible for the first phase of the algorithm.

Overrides:
setLayerer in class HierarchicLayouter

getLayerer

public Layerer getLayerer()
Description copied from class: HierarchicLayouter
Returns the currently set Layerer, which is responsible for the first phase of the algorithm.

Overrides:
getLayerer in class HierarchicLayouter

getLayerSequencer

public LayerSequencer getLayerSequencer()
Description copied from class: HierarchicLayouter
Returns the currently set LayerSequencer, which is responsible for the second phase of the algorithm.

Overrides:
getLayerSequencer in class HierarchicLayouter

getGroupBoundsCalculator

public GroupBoundsCalculator getGroupBoundsCalculator()
Gets the current GroupBoundsCalculator instance.

Returns:
the current GroupBoundsCalculator.

setGroupBoundsCalculator

public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Sets 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 it's 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 - New GroupBoundsCalculator instance.

setDrawer

public void setDrawer(Drawer drawer)
Sets the drawer which is responsible for the third phase of the algorithm. A drawer is responsible for the layout style of this layouter.

Overrides:
setDrawer in class HierarchicLayouter

getDrawer

public Drawer getDrawer()
Returns the drawer which is responsible for the third phase of the algorithm

Overrides:
getDrawer in class HierarchicLayouter

setLayoutStyle

public void setLayoutStyle(byte style)
Description copied from class: HierarchicLayouter
Sets the layout style for this layouter. Possible values are HierarchicLayouter.POLYLINE, HierarchicLayouter.LINEAR_SEGMENTS, HierarchicLayouter.MEDIAN_SIMPLEX, HierarchicLayouter.SIMPLEX, HierarchicLayouter.PENDULUM, and HierarchicLayouter.TREE. The default is set to HierarchicLayouter.LINEAR_SEGMENTS

Overrides:
setLayoutStyle in class HierarchicLayouter

setLayeringStrategy

public void setLayeringStrategy(byte strategy)
Description copied from class: HierarchicLayouter
Sets a predefined layering strategy. This layouter assigns the nodes to separate layers. The nodes within each layer will be placed on the same horizontal line. The layers will be arranged vertically starting with the small-numbered layers. The rank of a node is the number of the layer it belongs to.

An important layering strategy for the hierarchic layout style is called Hierarchical Layering. A hierarchical layering tries to assign nodes to layers in a way that as much as possible edges of the graph will point to the main layout direction, i.e. the start nodes of the edges will have a smaller rank than the corresponding end nodes. Also, a hierarchical layering will never put two connected nodes in the same layer.

By default the layering strategy HierarchicLayouter.LAYERING_HIERARCHICAL_TIGHT_TREE is set.

Overrides:
setLayeringStrategy in class HierarchicLayouter
Parameters:
strategy - one of HierarchicLayouter.LAYERING_HIERARCHICAL_TOPMOST, HierarchicLayouter.LAYERING_HIERARCHICAL_DOWNSHIFT, HierarchicLayouter.LAYERING_HIERARCHICAL_TIGHT_TREE, HierarchicLayouter.LAYERING_HIERARCHICAL_OPTIMAL, HierarchicLayouter.LAYERING_FROM_SKETCH, HierarchicLayouter.LAYERING_USER_DEFINED or HierarchicLayouter.LAYERING_BFS.

isStrongPortsScalingActive

public boolean isStrongPortsScalingActive()
Gets the property strongPortsScalingActive. This property determines whether 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 vary. The default value is true.

Returns:
whether this feature is active

setStrongPortsScalingActive

public void setStrongPortsScalingActive(boolean strongPortsScalingActive)
Sets the property strongPortsScalingActive. This property determines whether 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 vary. The default value is true.

Parameters:
strongPortsScalingActive - the new value of the property.

getLayerSequence

protected NodeList[] getLayerSequence(LayoutGraph g,
                                      NodeMap LAYER_KEY,
                                      int maxLayer)
Description copied from class: HierarchicLayouter
Determines the order of the nodes within their layers.

Overrides:
getLayerSequence in class HierarchicLayouter

isGlobalSequencingActive

public boolean isGlobalSequencingActive()
Returns the current strategy for the node sequencing.

Returns:
whether the global sequencing strategy is being used

setGlobalSequencingActive

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

Parameters:
globalSequencingActive - the new value.

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

2003