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 subclass of InsetsGroupBoundsCalculator does not only allow custom insets for each group node, but also makes sure to keep provided minimum sizes registered for each node that are provided through a DataProvider which must be registered with the graph prior to the invocation of the layout algorithm. By default GroupingKeys.MINIMUM_NODE_SIZE_DPKEY is used as the data provider key, but one can also determine another using the according constructor or method setMinimumNodeSizeDPKey( Object).


Constructor Summary
MinimumSizeGroupBoundsCalculator()
          Constructs an instance that uses the minimum size provided through the data provider registered at the input graph with the public key GroupingKeys.MINIMUM_NODE_SIZE_DPKEY.
MinimumSizeGroupBoundsCalculator(Object minSizeDataProviderKey)
          Constructs an instance using the given DataProvider key.
 
Method Summary
 Rectangle2D calculateBounds(LayoutGraph graph, Node groupNode, NodeList children)
          This method is called during the layout process.
 YDimension getDefaultMinimumNodeSize()
          Returns the default minimum size for nodes.
 Object getMinimumNodeSizeDPKey()
          Returns the DataProvider key that is used to get the minimum sizes for the nodes.
 double getXAlignment()
          Returns a value that describes how the node will be resized horizontally if the calculated width of InsetsGroupBoundsCalculator is smaller than the minimal width that is provided for the node.
 double getYAlignment()
          Returns a value that describes how the node will be resized vertically if the calculated height of InsetsGroupBoundsCalculator is smaller than the minimal height that is provided for the node.
 void setDefaultMinimumNodeSize(YDimension minSize)
          Sets the default minimum size for nodes.
 void setMinimumNodeSizeDPKey(Object minimumNodeSizeDPKey)
          Sets the DataProvider key that is used to get the minimum sizes for the nodes.
 void setXAlignment(double xAlignment)
          Defines how the node shall be resized horizontally if the calculated width of InsetsGroupBoundsCalculator is smaller than the minimal width that is provided for the node.
 void setYAlignment(double yAlignment)
          Defines how the node shall be resized vertically if the calculated height of InsetsGroupBoundsCalculator is smaller than the minimal height that is provided for the node.
 
Methods inherited from class y.layout.grouping.InsetsGroupBoundsCalculator
createEnlargedBounds, getDefaultInsets, getGroupNodeInsetsDPKey, getNodeBounds, isConsiderNodeLabelsEnabled, 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()
Constructs an instance that uses the minimum size provided through the data provider registered at the input graph with the public key GroupingKeys.MINIMUM_NODE_SIZE_DPKEY.


MinimumSizeGroupBoundsCalculator

public MinimumSizeGroupBoundsCalculator(Object minSizeDataProviderKey)
Constructs an instance using the given DataProvider key.

Parameters:
minSizeDataProviderKey - a DataProvider key that is used to get the minimum sizes for the nodes.
Method Detail

calculateBounds

public Rectangle2D calculateBounds(LayoutGraph graph,
                                   Node groupNode,
                                   NodeList children)
Description copied from interface: GroupBoundsCalculator
This method is called during the layout process. It calculates the bounds for the given groupNode instance that contains the children.

Specified by:
calculateBounds in interface GroupBoundsCalculator
Overrides:
calculateBounds in class InsetsGroupBoundsCalculator
Parameters:
graph - the graph instance for which the bounds will be calculated
groupNode - the group node whose bounds will be calculated
children - a list of nodes which reside inside the group node
Returns:
a Rectangle2D instance that describes the bounds of the group node.

getXAlignment

public double getXAlignment()
Returns a value that describes how the node will be resized horizontally if the calculated width of InsetsGroupBoundsCalculator is smaller than the minimal width that is provided for the node. The default value is 0.5, which means the node will grow equally to the left and to the right, while the center stays put.

Returns:
  • 0 - if the node will grow to the right so that the left border will stay put
  • 1 - if the node will grow to the left so that the right border will stay put
  • values in between 0 and 1 for other alignments.

setXAlignment

public void setXAlignment(double xAlignment)
Defines how the node shall be resized horizontally if the calculated width of InsetsGroupBoundsCalculator is smaller than the minimal width that is provided for the node. The default value is 0.5, which means the node will grow equally to the left and to the right, while the center stays put.

Parameters:
xAlignment -
  • 0 - if the node shall grow to the right so that the left border will stay put
  • 1 - if the node shall grow to the left so that the right border will stay put
  • values in between 0 and 1 for other alignments.

getYAlignment

public double getYAlignment()
Returns a value that describes how the node will be resized vertically if the calculated height of InsetsGroupBoundsCalculator is smaller than the minimal height that is provided for the node. The default value is 0.5, which means the node will grow equally upwards and downwards, while the center stays put.

Returns:
  • 0 - if the node shall grow downwards so that the upper border will stay put
  • 1 - if the node shall grow upwards so that the lower border will stay put
  • values in between 0 and 1 for other alignments.

setYAlignment

public void setYAlignment(double yAlignment)
Defines how the node shall be resized vertically if the calculated height of InsetsGroupBoundsCalculator is smaller than the minimal height that is provided for the node. The default value is 0.5, which means the node will grow equally upwards and downwards, while the center stays put.

Parameters:
yAlignment -
  • 0 - if the node shall grow downwards so that the upper border will stay put
  • 1 - if the node shall grow upwards so that the lower border will stay put
  • values in between 0 and 1 for other alignments.

getMinimumNodeSizeDPKey

public Object getMinimumNodeSizeDPKey()
Returns the DataProvider key that is used to get the minimum sizes for the nodes.

Returns:
the DataProvider key that is used to get the minimum sizes for the nodes.

setMinimumNodeSizeDPKey

public void setMinimumNodeSizeDPKey(Object minimumNodeSizeDPKey)
Sets the DataProvider key that is used to get the minimum sizes for the nodes.

Parameters:
minimumNodeSizeDPKey - the DataProvider key that is used to get the minimum sizes for the nodes.

setDefaultMinimumNodeSize

public void setDefaultMinimumNodeSize(YDimension minSize)
Sets the default minimum size for nodes.

By default this is a YDimension with length 0 and width 0.

Parameters:
minSize - will be used as the default minimum size if the data provider contains no minimum size information for a specific node.

getDefaultMinimumNodeSize

public YDimension getDefaultMinimumNodeSize()
Returns the default minimum size for nodes.

By default this is a YDimension with length 0 and width 0.

Returns:
the minimum size, that will be used as the default minimum size if the data provider contains no minimum size information for a specific node.

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