Search this API

y.layout.grouping
Class GroupNodeHider

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

public class GroupNodeHider
extends AbstractLayoutStage

A layout stage that hides the group nodes of hierarchically grouped graphs.

This stage removes all group nodes and adjacent edges from the graph before passing it to the core layout algorithm. After the core layout algorithm has arranged the graph, the hidden elements will be reinserted.

This stage is used by layout algorithms that cannot handle grouped graphs.

 

Field Summary
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
GroupNodeHider()
          Creates an instance of GroupNodeHider with default settings.
GroupNodeHider(Layouter coreLayouter)
          Creates an instance of GroupNodeHider with a specific core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that are accepted by the core layout algorithm after this stage has finished preparing the graph.
 void doLayout(LayoutGraph graph)
          Calculates the layout based on the given core layout algorithm.
 GroupBoundsCalculator getGroupBoundsCalculator()
          Returns the GroupBoundsCalculator instance for calculating the sizes of group nodes.
 void hideGroupNodes(LayoutGraph graph)
          Hides the group nodes and their incident edges of the input graph.
 boolean isEdgePathResettingEnabled()
          Returns whether or not this stage resets the paths of edges incident to group nodes.
 boolean isHidingEmptyGroupNodes()
          Returns whether or not empty group nodes, i.e., group nodes without children, will be hidden by this stage.
 void setEdgePathResettingEnabled(boolean edgePathResettingEnabled)
          Specifies whether or not this stage resets the paths of edges incident to group nodes.
 void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
          Specifies the GroupBoundsCalculator instance for calculating the sizes of group nodes.
 void setHidingEmptyGroupNodes(boolean hidingEmptyGroupNodes)
          Specifies whether or not empty group nodes, i.e., group nodes without children, will be hidden by this stage.
 void unhideGroupNodes(LayoutGraph graph)
          Un-hides the group nodes and their incident edges of the input graph that were previously hidden using method hideGroupNodes(LayoutGraph).
 
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
 

Constructor Detail

GroupNodeHider

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


GroupNodeHider

public GroupNodeHider(Layouter coreLayouter)
Creates an instance of GroupNodeHider with a specific core layout algorithm.

Parameters:
coreLayouter - the core layout algorithm
Method Detail

isEdgePathResettingEnabled

public boolean isEdgePathResettingEnabled()
Returns whether or not this stage resets the paths of edges incident to group nodes. Resetting an edge path removes all bends and moves the edge's port on a group to the center.

 
Since this stage may change the size of group nodes (see setGroupBoundsCalculator(GroupBoundsCalculator)), keeping the original edge paths often produces weird routes for edges at group nodes.
Returns:
true if this stage resets the path of edges incident to group nodes, false otherwise
See Also:
setEdgePathResettingEnabled(boolean)

setEdgePathResettingEnabled

public void setEdgePathResettingEnabled(boolean edgePathResettingEnabled)
Specifies whether or not this stage resets the paths of edges incident to group nodes. Resetting an edge path removes all bends and moves the edge's port on a group to the center.

 
Since this stage may change the size of group nodes (see setGroupBoundsCalculator(GroupBoundsCalculator)), keeping the original edge paths often produces weird routes for edges at group nodes.
Default Value:
The default value is false. This stage does not reset the path of edges incident to group nodes.
Parameters:
edgePathResettingEnabled - true if this stage resets the path of edges incident to group nodes, false otherwise

isHidingEmptyGroupNodes

public boolean isHidingEmptyGroupNodes()
Returns whether or not empty group nodes, i.e., group nodes without children, will be hidden by this stage.

Returns:
true if all group nodes will be hidden, false if only group nodes with children will be hidden
See Also:
setHidingEmptyGroupNodes(boolean)

setHidingEmptyGroupNodes

public void setHidingEmptyGroupNodes(boolean hidingEmptyGroupNodes)
Specifies whether or not empty group nodes, i.e., group nodes without children, will be hidden by this stage.

Default Value:
The default value is true. All group nodes will be hidden.
Parameters:
hidingEmptyGroupNodes - true if all group nodes should be hidden, false if only group nodes with children should be hidden

hideGroupNodes

public void hideGroupNodes(LayoutGraph graph)
Hides the group nodes and their incident edges of the input graph.

Furthermore, this method removes all grouping-related DataProviders from the input graph.

Parameters:
graph - the input graph
See Also:
GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY, GroupingKeys.GROUP_DPKEY, unhideGroupNodes(LayoutGraph)

unhideGroupNodes

public void unhideGroupNodes(LayoutGraph graph)
Un-hides the group nodes and their incident edges of the input graph that were previously hidden using method hideGroupNodes(LayoutGraph).

Furthermore, this method restores all previously removed grouping related DataProviders on the input graph.

Parameters:
graph - the given graph
See Also:
GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY, GroupingKeys.GROUP_DPKEY, hideGroupNodes(LayoutGraph)

setGroupBoundsCalculator

public void setGroupBoundsCalculator(GroupBoundsCalculator groupBoundsCalculator)
Specifies the GroupBoundsCalculator instance for calculating the sizes of group nodes.

For every group which is in its open state, the GroupBoundsCalculator will be asked to calculate the bounds for the group's child nodes. The resulting size will be used during the ongoing layout calculation.

Default Value:
The default value is MinimumSizeGroupBoundsCalculator
Parameters:
groupBoundsCalculator - the GroupBoundsCalculator instance

getGroupBoundsCalculator

public GroupBoundsCalculator getGroupBoundsCalculator()
Returns the GroupBoundsCalculator instance for calculating the sizes of group nodes.

For every group which is in its open state, the GroupBoundsCalculator will be asked to calculate the bounds for the group's child nodes. The resulting size will be used during the ongoing layout calculation.

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

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that are accepted by the core layout algorithm after this stage has finished preparing the graph.

Parameters:
graph - the input graph
Returns:
true if the core layout algorithm accepts the prepared graph or is null, false otherwise.
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Calculates the layout based on the given core layout algorithm.

Before calling the core layout algorithm, group nodes and their adjacent edges will be hidden. After the layout has been calculated, GroupNodeHider will restore the graph.

 
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
See Also:
Layouter.canLayout(LayoutGraph)

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