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 Object
implements GroupBoundsCalculator

Convenience implementation which allows for custom insets for each group node. Insets are provided through a DataProvider which must be registered with the graph prior to the invocation of the layout algorithm.


Constructor Summary
InsetsGroupBoundsCalculator()
          Constructs an instance that uses insets provided through the data provider registered at the input graph with the public key GroupingKeys.GROUP_NODE_INSETS_DPKEY.
InsetsGroupBoundsCalculator(Insets insets)
          Constructs an instance that uses the specified insets as the default if the data provider contains no insets information for a specific node.
InsetsGroupBoundsCalculator(Object insetsDataProviderKey)
          Constructs an instance using the given DataProvider key.
InsetsGroupBoundsCalculator(Object insetsDataProviderKey, Insets defaultInsets)
          Constructs an instance using the given DataProvider key and default insets.
 
Method Summary
 Rectangle2D calculateBounds(LayoutGraph graph, Node groupNode, NodeList children)
          This method is called during the layout process.
protected  Rectangle2D createEnlargedBounds(LayoutGraph graph, Node groupNode, NodeList children, Rectangle2D bounds)
          This method enlarges the given graph bounds by the insets associated with the given group node.
 Insets getDefaultInsets()
          Returns the default insets.
 Object getGroupNodeInsetsDPKey()
          Returns the DataProvider key that is used to get the insets for the nodes.
protected  Rectangle2D getNodeBounds(LayoutGraph graph, NodeList nodes)
          Calculates and returns the united bounds of the given nodes only, no labels or adjacent edges are considered.
 boolean isConsiderNodeLabelsEnabled()
          Returns whether the bounds calculation for group nodes takes labels of the group's content nodes into account.
 void setConsiderNodeLabelsEnabled(boolean enabled)
          Specifies whether the bounds calculation for group nodes should take labels of the group's content nodes into account.
 void setDefaultInsets(Insets insets)
          Sets the default insets.
 void setGroupNodeInsetsDPKey(Object dpkey)
          Sets the DataProvider key that is used to get the insets for the 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 that uses insets provided through the data provider registered at the input graph with the public key GroupingKeys.GROUP_NODE_INSETS_DPKEY.


InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator(Insets insets)
Constructs an instance that uses the specified insets as the default if the data provider contains no insets information for a specific node.


InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator(Object insetsDataProviderKey)
Constructs an instance using the given DataProvider key.


InsetsGroupBoundsCalculator

public InsetsGroupBoundsCalculator(Object insetsDataProviderKey,
                                   Insets defaultInsets)
Constructs an instance using the given DataProvider key and default insets.

Method Detail

isConsiderNodeLabelsEnabled

public boolean isConsiderNodeLabelsEnabled()
Returns whether the bounds calculation for group nodes takes labels of the group's content nodes into account.

Defaults to false

Returns:
whether the bounds calculation for group nodes takes labels of the group's content nodes into account.

setConsiderNodeLabelsEnabled

public void setConsiderNodeLabelsEnabled(boolean enabled)
Specifies whether the bounds calculation for group nodes should take labels of the group's content nodes into account.

Defaults to false.

Parameters:
enabled - if true a node's labels are taken into account when calculating the bounds of the node's parent group; if false, a node's labels are ignored in said calculation.

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
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.

createEnlargedBounds

protected Rectangle2D createEnlargedBounds(LayoutGraph graph,
                                           Node groupNode,
                                           NodeList children,
                                           Rectangle2D bounds)
This method enlarges the given graph bounds by the insets associated with the given group node.


getNodeBounds

protected Rectangle2D getNodeBounds(LayoutGraph graph,
                                    NodeList nodes)
Calculates and returns the united bounds of the given nodes only, no labels or adjacent edges are considered.


setDefaultInsets

public void setDefaultInsets(Insets insets)
Sets the default insets.

Parameters:
insets - an insets object that will be used as the default if the data provider contains no insets information for a specific node.

getDefaultInsets

public Insets getDefaultInsets()
Returns the default insets.

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

setGroupNodeInsetsDPKey

public void setGroupNodeInsetsDPKey(Object dpkey)
Sets the DataProvider key that is used to get the insets for the nodes.

Parameters:
dpkey - the DataProvider key that is used to get the insets for the nodes.

getGroupNodeInsetsDPKey

public Object getGroupNodeInsetsDPKey()
Returns the DataProvider key that is used to get the insets for the nodes.

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

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