Search this API

y.layout.grouping
Class InsetsGroupBoundsCalculator

java.lang.Object
  extended by y.layout.grouping.InsetsGroupBoundsCalculator
All Implemented Interfaces:
GroupBoundsCalculator
Direct Known Subclasses:
MinimumSizeGroupBoundsCalculator

public class InsetsGroupBoundsCalculator
extends java.lang.Object
implements GroupBoundsCalculator

This GroupBoundsCalculator calculates the bounds of group nodes and allows to specify custom insets for each group node.

Insets are provided by a DataProvider that must have been registered with the graph using the specified insets key prior to the invocation of the layout algorithm.

 
This implementation is intended to be used with class RecursiveGroupLayouter and assumes that the graph given to method calculateBounds(LayoutGraph, Node, NodeList) only contains the content of the specified group (which is always true if it is called within the RecursiveGroupLayouter).
 

Constructor Summary
InsetsGroupBoundsCalculator()
          Constructs an instance of InsetsGroupBoundsCalculator with default settings.
InsetsGroupBoundsCalculator(java.awt.Insets insets)
          Constructs an instance of InsetsGroupBoundsCalculator with the given insets as default insets.
InsetsGroupBoundsCalculator(java.lang.Object insetsDataProviderKey)
          Constructs an instance of InsetsGroupBoundsCalculator with the given DataProvider key as group node insets key.
InsetsGroupBoundsCalculator(java.lang.Object insetsDataProviderKey, java.awt.Insets defaultInsets)
          Constructs an instance of InsetsGroupBoundsCalculator using the given DataProvider key as group node insets key and the given insets as default insets.
 
Method Summary
 java.awt.geom.Rectangle2D calculateBounds(LayoutGraph graph, Node groupNode, NodeList children)
          Calculates the bounds of the given group node and enlarges the bounds by the insets associated with the group node.
protected  java.awt.geom.Rectangle2D createEnlargedBounds(LayoutGraph graph, Node groupNode, NodeList children, java.awt.geom.Rectangle2D bounds)
          Enlarges the given graph bounds by the insets associated with the given group node.
 java.awt.Insets getDefaultInsets()
          Returns the default insets that will be used if the DataProvider registered with the insets key does not contain a mapping for a specific node.
 java.lang.Object getGroupNodeInsetsDPKey()
          Returns the key to register a DataProvider that is used to access the insets for the group nodes.
protected  java.awt.geom.Rectangle2D getNodeBounds(LayoutGraph graph, NodeList nodes)
          Calculates the united bounds of the nodes of a given NodeList without considering labels or adjacent edges.
 boolean isConsiderEdgeLabelsEnabled()
          Returns whether or not the labels of edges contained in a group are considered while calculating the bounds of the group node.
 boolean isConsiderNodeHalosEnabled()
          Returns whether or not the calculation of the bounds of a group node considers the NodeHalos associated with the group's child nodes.
 boolean isConsiderNodeLabelsEnabled()
          Returns whether or not the labels of nodes contained in a group are considered while calculating the bounds of the group node.
 void setConsiderEdgeLabelsEnabled(boolean enabled)
          Specifies whether or not the labels of edges contained in a group are considered while calculating the bounds of the group node.
 void setConsiderNodeHalosEnabled(boolean enabled)
          Specifies whether or not the calculation of the bounds of a group node considers the NodeHalos associated with the group's child nodes.
 void setConsiderNodeLabelsEnabled(boolean enabled)
          Specifies whether or not the labels of nodes contained in a group are considered while calculating the bounds of the group node.
 void setDefaultInsets(java.awt.Insets insets)
          Specifies the default insets that will be used if the DataProvider registered with the insets key does not contain a mapping for a specific node.
 void setGroupNodeInsetsDPKey(java.lang.Object dpkey)
          Specifies the key to register a DataProvider that is used to access the insets for the group nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator()
Constructs an instance of InsetsGroupBoundsCalculator with default settings.


InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator(java.awt.Insets insets)
Constructs an instance of InsetsGroupBoundsCalculator with the given insets as default insets.

Parameters:
insets - the insets to use as default insets

InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator(java.lang.Object insetsDataProviderKey)
Constructs an instance of InsetsGroupBoundsCalculator with the given DataProvider key as group node insets key.

Parameters:
insetsDataProviderKey - the DataProvider key to use as insets key

InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator(java.lang.Object insetsDataProviderKey,
                                   java.awt.Insets defaultInsets)
Constructs an instance of InsetsGroupBoundsCalculator using the given DataProvider key as group node insets key and the given insets as default insets.

Parameters:
insetsDataProviderKey - the DataProvider key to use as insets key
defaultInsets - the insets to use as default insets
Method Detail

isConsiderNodeLabelsEnabled

public boolean isConsiderNodeLabelsEnabled()
Returns whether or not the labels of nodes contained in a group are considered while calculating the bounds of the group node.

Returns:
true if the labels of the nodes are considered when calculating the bounds of the node's parent group, false otherwise
See Also:
setConsiderNodeLabelsEnabled(boolean)

setConsiderNodeLabelsEnabled

public void setConsiderNodeLabelsEnabled(boolean enabled)
Specifies whether or not the labels of nodes contained in a group are considered while calculating the bounds of the group node.

Default Value:
The default value is false. Node labels are not considered during the group bounds calculation.
Parameters:
enabled - true if the labels of the nodes should be considered when calculating the bounds of the node's parent group, false otherwise
Sample Graphs:

false

true

isConsiderEdgeLabelsEnabled

public boolean isConsiderEdgeLabelsEnabled()
Returns whether or not the labels of edges contained in a group are considered while calculating the bounds of the group node.

Returns:
true if the labels of the edges are considered when calculating the bounds of group nodes, false otherwise
See Also:
setConsiderEdgeLabelsEnabled(boolean)

setConsiderEdgeLabelsEnabled

public void setConsiderEdgeLabelsEnabled(boolean enabled)
Specifies whether or not the labels of edges contained in a group are considered while calculating the bounds of the group node.

Default Value:
The default value is false. Edge labels are not considered during the group bounds calculation.
Parameters:
enabled - true if the labels of the edges should be considered when calculating the bounds of group nodes, false otherwise
Sample Graphs:

false

true

isConsiderNodeHalosEnabled

public boolean isConsiderNodeHalosEnabled()
Returns whether or not the calculation of the bounds of a group node considers the NodeHalos associated with the group's child nodes.

Returns:
true if NodeHalos associated with nodes should be considered, false otherwise
See Also:
setConsiderNodeHalosEnabled(boolean)

setConsiderNodeHalosEnabled

public void setConsiderNodeHalosEnabled(boolean enabled)
Specifies whether or not the calculation of the bounds of a group node considers the NodeHalos associated with the group's child nodes.

Default Value:
The default value is true. NodeHalos are considered during the group bounds calculation.
Parameters:
enabled - true if NodeHalos associated with nodes should be considered, false otherwise
Sample Graphs:

false

true

calculateBounds

public java.awt.geom.Rectangle2D calculateBounds(LayoutGraph graph,
                                                 Node groupNode,
                                                 NodeList children)
Calculates the bounds of the given group node and enlarges the bounds by the insets associated with the group node.

The insets associated with the group node will be retrieved from a DataProvider registered with the graph with the current insets key.

Specified by:
calculateBounds in interface GroupBoundsCalculator
 
This implementation is intended to be used with class RecursiveGroupLayouter and assumes that the graph given to method calculateBounds(LayoutGraph, Node, NodeList) only contains the content of the specified group (which is always true if it is called within the RecursiveGroupLayouter).
Parameters:
graph - the input graph
groupNode - the group node whose bounds will be calculated
children - a NodeList containing the nodes that reside inside the group node
Returns:
a Rectangle2D instance that describes the bounds of the group node

createEnlargedBounds

protected java.awt.geom.Rectangle2D createEnlargedBounds(LayoutGraph graph,
                                                         Node groupNode,
                                                         NodeList children,
                                                         java.awt.geom.Rectangle2D bounds)
Enlarges the given graph bounds by the insets associated with the given group node.

The insets associated with the group node will be retrieved from a DataProvider registered with the graph with the current insets key.

This method is called while calculating the group bounds to realize the support for custom insets. It may be overridden to change the way specific insets influence the group node bounds.

Parameters:
graph - the input graph
groupNode - the group node whose bounds should be enlarged
children - the list of nodes that the given group node contains
bounds - a Rectangle2D instance representing the bounds of the given group node
Returns:
a Rectangle2D instance representing the enlarged bounds of the given group node

getNodeBounds

protected java.awt.geom.Rectangle2D getNodeBounds(LayoutGraph graph,
                                                  NodeList nodes)
Calculates the united bounds of the nodes of a given NodeList without considering labels or adjacent edges.

Parameters:
graph - the input graph
nodes - a list of nodes to be contained in the bounds
Returns:
a Rectangle2D representing the united bounds of the given nodes

setDefaultInsets

public void setDefaultInsets(java.awt.Insets insets)
Specifies the default insets that will be used if the DataProvider registered with the insets key does not contain a mapping for a specific node.

Default Value:
The default value is Insets(15,15,15,15). The insets from the top, left, bottom and right are set to 15.
Parameters:
insets - the default insets used for group nodes without specific insets

getDefaultInsets

public java.awt.Insets getDefaultInsets()
Returns the default insets that will be used if the DataProvider registered with the insets key does not contain a mapping for a specific node.

Returns:
the default insets used for group nodes without specific insets
See Also:
setDefaultInsets(Insets)

setGroupNodeInsetsDPKey

public void setGroupNodeInsetsDPKey(java.lang.Object dpkey)
Specifies the key to register a DataProvider that is used to access the insets for the group nodes.

The DataProvider registered with this key must provide a mapping from each group node to a YInsets (or Insets) instance.

Default Value:
The default value is GroupingKeys.GROUP_NODE_INSETS_DPKEY
Parameters:
dpkey - the DataProvider key

getGroupNodeInsetsDPKey

public java.lang.Object getGroupNodeInsetsDPKey()
Returns the key to register a DataProvider that is used to access the insets for the group nodes.

The DataProvider registered with this key must provide a mapping from each group node to a YInsets (or Insets) instance.

Returns:
the DataProvider key
See Also:
setGroupNodeInsetsDPKey(Object)

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