Search this API

y.layout.grouping
Class MinimumSizeGroupBoundsCalculator

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

public class MinimumSizeGroupBoundsCalculator
extends InsetsGroupBoundsCalculator

This GroupBoundsCalculator allows custom insets for group nodes and guarantees that their provided minimum sizes will be maintained.

As a subclass of InsetsGroupBoundsCalculator, this class supports custom insets for each group node. Furthermore, it guarantees that a desired minimum size is maintained. The minimum sizes are provided by a DataProvider registered with the graph using the specified minimum node size key.

 
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
MinimumSizeGroupBoundsCalculator()
          Creates a new instance of MinimumSizeGroupBoundsCalculator with default settings.
MinimumSizeGroupBoundsCalculator(java.lang.Object minSizeDataProviderKey)
          Creates a new instance of MinimumSizeGroupBoundsCalculator with the given key as minimum node size key.
 
Method Summary
 java.awt.geom.Rectangle2D calculateBounds(LayoutGraph graph, Node groupNode, NodeList children)
          Calculates the bounds of the given group node, enlarges the bounds by the insets associated with the group node and makes sure that the size of the group node obeys the associated minimum size.
 YDimension getDefaultMinimumNodeSize()
          Returns the default minimum size (width and height) for group nodes.
 java.lang.Object getMinimumNodeSizeDPKey()
          Returns the key to register a DataProvider that is used to access the minimum sizes for the group nodes.
 double getXAlignment()
          Returns how the nodes are resized horizontally if the calculated width is smaller than the preferred minimum width of a group node.
 double getYAlignment()
          Returns how the nodes are resized vertically if the calculated height is smaller than the preferred minimum height of a group node.
 void setDefaultMinimumNodeSize(YDimension minSize)
          Specifies the default minimum size (width and height) for group nodes.
 void setMinimumNodeSizeDPKey(java.lang.Object minimumNodeSizeDPKey)
          Specifies the key to register a DataProvider that is used to access the minimum sizes for the group nodes.
 void setXAlignment(double xAlignment)
          Specifies how the nodes are resized horizontally if the calculated width is smaller than the preferred minimum width of a group node.
 void setYAlignment(double yAlignment)
          Specifies how the nodes are resized vertically if the calculated height is smaller than the preferred minimum height of a group node.
 
Methods inherited from class y.layout.grouping.InsetsGroupBoundsCalculator
createEnlargedBounds, getDefaultInsets, getGroupNodeInsetsDPKey, getNodeBounds, isConsiderEdgeLabelsEnabled, isConsiderNodeHalosEnabled, isConsiderNodeLabelsEnabled, setConsiderEdgeLabelsEnabled, setConsiderNodeHalosEnabled, setConsiderNodeLabelsEnabled, setDefaultInsets, setGroupNodeInsetsDPKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MinimumSizeGroupBoundsCalculator

public MinimumSizeGroupBoundsCalculator()
Creates a new instance of MinimumSizeGroupBoundsCalculator with default settings.


MinimumSizeGroupBoundsCalculator

public MinimumSizeGroupBoundsCalculator(java.lang.Object minSizeDataProviderKey)
Creates a new instance of MinimumSizeGroupBoundsCalculator with the given key as minimum node size key.

Parameters:
minSizeDataProviderKey - the DataProvider key to use as minimum size key
Method Detail

calculateBounds

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

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

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

Specified by:
calculateBounds in interface GroupBoundsCalculator
Overrides:
calculateBounds in class InsetsGroupBoundsCalculator
 
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

getXAlignment

public double getXAlignment()
Returns how the nodes are resized horizontally if the calculated width is smaller than the preferred minimum width of a group node.

The alignment is defined to be a value between 0 and 1, such that:

Returns:
a horizontal alignment value from the interval [0,1]
See Also:
setXAlignment(double)

setXAlignment

public void setXAlignment(double xAlignment)
Specifies how the nodes are resized horizontally if the calculated width is smaller than the preferred minimum width of a group node.

The alignment is defined to be a value between 0 and 1, such that:

Default Value:
The default value is 0.5. Nodes grow equally to the left and to the right, while the center remains unchanged.
Parameters:
xAlignment - a horizontal alignment value from the interval [0,1]
Throws:
java.lang.IllegalArgumentException - if the given value does not lie within [0,1]
Sample Graphs:

X-alignment 0 when minimum group node size is 200 x 200

X-alignment 0.5 when minimum group node size is 200 x 200

X-alignment 1.0 when minimum group node size is 200 x 200

getYAlignment

public double getYAlignment()
Returns how the nodes are resized vertically if the calculated height is smaller than the preferred minimum height of a group node.

The alignment is defined to be a value between 0 and 1, such that:

Returns:
a vertical alignment value from the interval [0,1]
See Also:
setYAlignment(double)

setYAlignment

public void setYAlignment(double yAlignment)
Specifies how the nodes are resized vertically if the calculated height is smaller than the preferred minimum height of a group node.

The alignment is defined to be a value between 0 and 1, such that:

Default Value:
The default value is 0.5. Nodes grow equally upwards and downwards, while the center remains unchanged.
Parameters:
yAlignment - a vertical alignment value from the interval [0,1]
Throws:
java.lang.IllegalArgumentException - if the given value does not lie within [0,1]
Sample Graphs:

Y-alignment 0 when minimum group node size is 200 x 200

Y-alignment 0.5 when minimum group node size is 200 x 200

Y-alignment 1.0 when minimum group node size is 200 x 200

getMinimumNodeSizeDPKey

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

The DataProvider registered with this key must provide a mapping from each group node to a YDimension object defining the minimum width and height of the group node. If no provider is registered, the key is null or if the provider yields no value for a group node, then the default minimum size is applied.

Returns:
the DataProvider key for minimum node sizes
See Also:
setMinimumNodeSizeDPKey(Object), setDefaultMinimumNodeSize(YDimension)

setMinimumNodeSizeDPKey

public void setMinimumNodeSizeDPKey(java.lang.Object minimumNodeSizeDPKey)
Specifies the key to register a DataProvider that is used to access the minimum sizes for the group nodes.

The DataProvider registered with this key must provide a mapping from each group node to a YDimension object defining the minimum width and height of the group node. If no provider is registered, the key is null or if the provider yields no value for a group node, then the default minimum size is applied.

Default Value:
The default value is GroupingKeys.MINIMUM_NODE_SIZE_DPKEY
Parameters:
minimumNodeSizeDPKey - the DataProvider key for minimum node sizes
See Also:
setDefaultMinimumNodeSize(YDimension)

setDefaultMinimumNodeSize

public void setDefaultMinimumNodeSize(YDimension minSize)
Specifies the default minimum size (width and height) for group nodes.

The default minimum size is used if the DataProvider registered with the minimum size key does not contain a mapping for a group node.

Default Value:
The default value is YDimension(0,0). A YDimension object with width and height set to 0.
Parameters:
minSize - a YDimension instance representing the default minimum width and height
Throws:
java.lang.IllegalArgumentException - if the given YDimension is null
See Also:
setMinimumNodeSizeDPKey(Object)
Sample Graphs:

Minimum group node size 50 x 50

Minimum group node size 200 x 200

getDefaultMinimumNodeSize

public YDimension getDefaultMinimumNodeSize()
Returns the default minimum size (width and height) for group nodes.

The default minimum size is used if the DataProvider registered with the minimum size key does not contain a mapping for a group node.

Returns:
a YDimension instance representing the default minimum width and height
See Also:
setDefaultMinimumNodeSize(YDimension), setMinimumNodeSizeDPKey(Object)

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