Search this API

y.view.hierarchy
Class DefaultGenericAutoBoundsFeature

java.lang.Object
  extended by y.view.hierarchy.DefaultGenericAutoBoundsFeature
All Implemented Interfaces:
GenericNodeRealizer.GenericSizeConstraintProvider, GenericNodeRealizer.LabelBoundsChangedHandler, GenericGroupNodeRealizer.GenericAutoBoundsFeature

public class DefaultGenericAutoBoundsFeature
extends java.lang.Object
implements GenericGroupNodeRealizer.GenericAutoBoundsFeature, GenericNodeRealizer.LabelBoundsChangedHandler, GenericNodeRealizer.GenericSizeConstraintProvider

This class is an implementation of interface GenericGroupNodeRealizer.GenericAutoBoundsFeature and is responsible for assigning node bounds for node realizers whose bounds may be determined by other factors then explicit bound assignment. For example for GenericGroupNodeRealizer which will adjust its bounds at open and close operations.

Method setConsiderNodeLabelSize(boolean) can be used to determine whether the state label and the first (text) label shall be taken into account when calculating the minimum node bounds. By default this option is set to false. Note: when activating this feature, some layout algorithms need to be given an custom implementation of GroupBoundsCalculator, so that they will also take the correct node dimensions into account when laying out the graph.

 

Constructor Summary
DefaultGenericAutoBoundsFeature()
           
DefaultGenericAutoBoundsFeature(boolean considerNodeLabel)
           
 
Method Summary
protected  java.awt.geom.Rectangle2D calcMinimumBounds(NodeRealizer context)
          Calculates the minimum bounds of this realizer when the group is open.
 java.awt.geom.Rectangle2D calcMinimumGroupBounds(NodeRealizer context)
          Calculates the minimal bounding box for the graph elements contained within the associated group node.
 java.awt.geom.Rectangle2D calcMinimumInsetBounds(NodeRealizer context)
          Calculates the minimum insets bounds of the open group node.
protected  java.awt.geom.Dimension2D calculateMinimalLabelSize(NodeRealizer context)
          Calculates the union of the first (text) label and the state label.
protected  void calcUnionRect(Graph2D graph, Node node, java.awt.geom.Rectangle2D r)
          Enlarges the given rectangle such that it will contain the bounding box of the specified node, all the bounding boxes of the node's labels, and all the bounding boxes of the node's ports.
 YInsets getAutoBoundsInsets(NodeRealizer context)
          Returns the currently set auto bounds insets of a group realizer.
protected  HierarchyManager getHierarchyManager(NodeRealizer context)
          Returns the hierarchy manager responsibly for managing the node represented by this realizer.
 YInsets getInsets(NodeRealizer context)
           
 YDimension getMaximumSize(NodeRealizer context)
          Returns the maximum size the realizer can have.
 YDimension getMinimumSize(NodeRealizer context)
          Returns the minimum size the realizer must have.
 boolean isConsiderNodeLabelSize()
          Returns whether label sizes will be taken into account when calculating the minimal node bounds.
 void labelBoundsChanged(NodeRealizer context, NodeLabel label)
          Called when the bounds of a label of the given NodeRealizer have been changed.
 void recalculateBounds(NodeRealizer context)
          Recalculates the bounds of a group realizer.
 void setConsiderNodeLabelSize(boolean considerNodeLabelSize)
          Whether label sizes shall be taken into account when calculating the minimal node bounds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGenericAutoBoundsFeature

public DefaultGenericAutoBoundsFeature()

DefaultGenericAutoBoundsFeature

public DefaultGenericAutoBoundsFeature(boolean considerNodeLabel)
Method Detail

isConsiderNodeLabelSize

public boolean isConsiderNodeLabelSize()
Returns whether label sizes will be taken into account when calculating the minimal node bounds. Method calculateMinimalLabelSize(y.view.NodeRealizer) determines which labels are taken into account. By default this is the first text label and the state label.

By default this option is set to false.

Returns:
whether node label sizes shall be considered when recalculating the group node's bounds. By default this is set to false.

setConsiderNodeLabelSize

public void setConsiderNodeLabelSize(boolean considerNodeLabelSize)
Whether label sizes shall be taken into account when calculating the minimal node bounds. Method calculateMinimalLabelSize(y.view.NodeRealizer) determines which labels are taken into account. By default this is the first text label and the state label.

By default this option is set to false.

Parameters:
considerNodeLabelSize - whether node label sizes shall be considered when recalculating the group node's bounds. By default this is set to false.

recalculateBounds

public void recalculateBounds(NodeRealizer context)
Description copied from interface: GenericGroupNodeRealizer.GenericAutoBoundsFeature
Recalculates the bounds of a group realizer.

Specified by:
recalculateBounds in interface GenericGroupNodeRealizer.GenericAutoBoundsFeature
Parameters:
context - the group realizer

calcMinimumBounds

protected java.awt.geom.Rectangle2D calcMinimumBounds(NodeRealizer context)
Calculates the minimum bounds of this realizer when the group is open.

Parameters:
context - the realizer this feature is associated with.
Returns:
the minimum bounds of for the given context.

calculateMinimalLabelSize

protected java.awt.geom.Dimension2D calculateMinimalLabelSize(NodeRealizer context)
Calculates the union of the first (text) label and the state label. This method can simply be overwritten if more labels shall be taken into account.

Parameters:
context - the realizer this feature is associated with.
Returns:
the maximum label dimension the first text label and the state label do need.

calcMinimumInsetBounds

public java.awt.geom.Rectangle2D calcMinimumInsetBounds(NodeRealizer context)
Calculates the minimum insets bounds of the open group node. The minimum insets bounds are composed of the minimum group bounds plus additional insets.

Specified by:
calcMinimumInsetBounds in interface GenericGroupNodeRealizer.GenericAutoBoundsFeature
Parameters:
context - the group realizer
Returns:
the calculated minimum inset bounds of a group realizer.

calcMinimumGroupBounds

public java.awt.geom.Rectangle2D calcMinimumGroupBounds(NodeRealizer context)
Calculates the minimal bounding box for the graph elements contained within the associated group node.

Parameters:
context - the realizer this feature is associated with.
Returns:
the minimal group bounds for the given context.

calcUnionRect

protected void calcUnionRect(Graph2D graph,
                             Node node,
                             java.awt.geom.Rectangle2D r)
Enlarges the given rectangle such that it will contain the bounding box of the specified node, all the bounding boxes of the node's labels, and all the bounding boxes of the node's ports.

Called from calcMinimumGroupBounds(y.view.NodeRealizer).

Parameters:
graph - the graph containing the given node.
node - the node whose bounds have to be added to the given rectangle.
r - the rectangle to update.
See Also:
NodeRealizer.calcUnionRect(java.awt.geom.Rectangle2D)

getAutoBoundsInsets

public YInsets getAutoBoundsInsets(NodeRealizer context)
Description copied from interface: GenericGroupNodeRealizer.GenericAutoBoundsFeature
Returns the currently set auto bounds insets of a group realizer.

Specified by:
getAutoBoundsInsets in interface GenericGroupNodeRealizer.GenericAutoBoundsFeature
Parameters:
context - the group realizer
Returns:
the currently set auto bounds insets of a group realizer.

getInsets

public YInsets getInsets(NodeRealizer context)

getHierarchyManager

protected HierarchyManager getHierarchyManager(NodeRealizer context)
Returns the hierarchy manager responsibly for managing the node represented by this realizer.

Parameters:
context - the realizer this feature is associated with.
Returns:
the hierarchy manager responsibly for managing the node represented by this realizer.

labelBoundsChanged

public void labelBoundsChanged(NodeRealizer context,
                               NodeLabel label)
Description copied from interface: GenericNodeRealizer.LabelBoundsChangedHandler
Called when the bounds of a label of the given NodeRealizer have been changed.

Specified by:
labelBoundsChanged in interface GenericNodeRealizer.LabelBoundsChangedHandler
Parameters:
context - the NodeRealizer whose labels' bounds have changed.
label - the label whose bounds have changed

getMinimumSize

public YDimension getMinimumSize(NodeRealizer context)
Description copied from interface: GenericNodeRealizer.GenericSizeConstraintProvider
Returns the minimum size the realizer must have.

Specified by:
getMinimumSize in interface GenericNodeRealizer.GenericSizeConstraintProvider
Returns:
the minimum size the realizer must have.

getMaximumSize

public YDimension getMaximumSize(NodeRealizer context)
Description copied from interface: GenericNodeRealizer.GenericSizeConstraintProvider
Returns the maximum size the realizer can have.

Specified by:
getMaximumSize in interface GenericNodeRealizer.GenericSizeConstraintProvider
Returns:
the maximum size the realizer can have.

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