y.view.hierarchy
Class GroupNodeRealizer

java.lang.Object
  extended by y.view.NodeRealizer
      extended by y.view.ShapeNodeRealizer
          extended by y.view.hierarchy.GroupNodeRealizer
All Implemented Interfaces:
NodeLayout, AutoBoundsFeature, GroupFeature, SizeConstraintProvider

public class GroupNodeRealizer
extends ShapeNodeRealizer
implements AutoBoundsFeature, GroupFeature, SizeConstraintProvider

A node realizer that is crafted to represent group and folder nodes within a graph hierarchy. A GroupNodeRealizer has two main states: it can be either open or closed (isGroupClosed()). When being closed, the realizer usually represents a folder node (HierarchyManager.isFolderNode(Node)). When being open, the realizer usually represents a group node (HierarchyManager.isGroupNode(Node)). The size and location of an open realizer will be determined by the bounds of its child nodes within the hierarchy (HierarchyManager.getChildren(Node)).

 
Your browser does not support SVG content.

Nested Class Summary
static class GroupNodeRealizer.StateChangeListener
          This static inner class can be used to automatically adjust the groupClosed property of GroupFeature instances.
 
Nested classes/interfaces inherited from interface y.view.SizeConstraintProvider
SizeConstraintProvider.Default
 
Field Summary
static Icon defaultClosedGroupIcon
          The default icon used by the state label, if the group realizer is closed.
static Icon defaultOpenGroupIcon
          The default icon used by the state label, if the group realizer is open.
 
Fields inherited from class y.view.ShapeNodeRealizer
DIAMOND, ELLIPSE, HEXAGON, OCTAGON, PARALLELOGRAM, RECT, RECT_3D, ROUND_RECT, shape, TRAPEZOID, TRAPEZOID_2, TRIANGLE
 
Fields inherited from class y.view.NodeRealizer
height, HOTSPOT_E, HOTSPOT_N, HOTSPOT_NE, HOTSPOT_NONE, HOTSPOT_NW, HOTSPOT_S, HOTSPOT_SE, HOTSPOT_SW, HOTSPOT_W, width, x, y
 
Constructor Summary
GroupNodeRealizer()
           
GroupNodeRealizer(NodeRealizer arg)
           
 
Method Summary
protected  Rectangle2D calcMinimumBounds()
          Calculates the minimum bounds of this realizer.
protected  Rectangle2D calcMinimumGroupBounds()
          Calculates the minimal bounding box for the graph elements contained within the associated group node.
protected  Rectangle2D calcMinimumInsetBounds()
          Calculates the minimum inset bounds of the open group node.
protected  Dimension2D calculateMinimalLabelSize()
          Calculates the union of the first (text) label and the state label.
 void calcUnionRect(Rectangle2D r)
          Enlarges the given rectangle such that it will contain the bounding box of this realizer and the bounding box of the realizer label and its drop shadow.
 boolean contains(double x, double y)
          Evaluate hit test on the node realizer.
 NodeRealizer createCopy(NodeRealizer arg)
          Creates a copy of this realizer type that will be initialized with the values found in the given realizer.
 boolean findBBIntersection(double ix, double iy, double ox, double oy, Point2D result)
          Returns true iff the coord (ix,iy) is identical with (getCenterX(),getCenterY()) and the coord (ox,oy), lies outside the bounding box of this realizer.
 boolean findIntersection(double ix, double iy, double ox, double oy, Point2D result)
          Special Intersection handling for some types of shape.
 Insets getAutoBoundsInsets()
          Returns the currently set auto bounds insets.
 Insets getBorderInsets()
          Returns the size of the empty border that will be added to the minimal bounds of this realizer.
 Rectangle2D.Double getBoundingBox()
          Return the bounding box of this realizer.
 double getCenterX()
          Get X-Coordinate of the center of the node.
 double getCenterY()
          Get Y-Coordinate of the center of the node.
 double getHeight()
          Returns the height of this realizer.
protected  HierarchyManager getHierarchyManager()
          Returns the hierarchy manager responsibly for managing the node represented by this realizer.
 YDimension getMaximumSize()
          Returns the maximum size the realizer that implements this interface can have.
 Rectangle2D getMinimalAutoBounds()
          Returns the minimal auto bounds of this object.
 Insets getMinimalInsets()
          Returns the minimal insets defined for this realizer.
 YDimension getMinimumSize()
          Returns the minimum size the realizer that implements this interface must have.
 NodeLabel getStateLabel()
          Returns the state label of this realizer.
 double getWidth()
          Returns the width of this realizer.
 double getX()
          Get X-Coordinate of the upper left corner of the node.
 double getY()
          Get Y-Coordinate of the upper left corner of the node.
 boolean intersects(double rx, double ry, double rw, double rh)
          Returns true iff the bounding box of this realizer intersects with the given box.
 boolean isAutoBoundsEnabled()
          Returns true if autobounds have been disabled and the realizer is not closed.
protected  boolean isBoundsDirty()
          Returns whether or not the bounds of a group node need to be recalculated.
 boolean isConsiderNodeLabelSize()
          Returns whether label sizes will be taken into account when calculating the minimal node bounds.
 boolean isGroupClosed()
          Returns true if this group node realizer is closed and false otherwise.
 boolean isGroupDepthFillColorEnabled()
          Whether or not the fill color of this node gets adapted to reflect the local group depth of this node within the graph hierarchy.
 boolean isInnerGraphDisplayEnabled()
          Returns whether or not the inner graph of a folder node should be displayed.
protected  void labelBoundsChanged(NodeLabel label)
          Callback method that should be overwritten by subclasses, that are interested in changes of the realizer label bounds.
protected  void paintInnerGraph(Graphics2D gfx)
          Used to paints the inner graph of a folder node when innerGraphDisplay is enabled.
protected  void paintNode(Graphics2D gfx)
          Paints the node.
protected  void paintShapeNode(Graphics2D gfx)
          Invokes the paintNode method of the ShapeNodeRealizer ancestor of this realizer.
 void paintSloppy(Graphics2D gfx)
          Paints the realizer in a cheap, uniform and sloppy way on g.
 void paintText(Graphics2D gfx)
          Paints the labels that belong to this realizer
 void read(ObjectInputStream in)
          Reads in the serialized form of this realizer.
protected  void recalculateBounds()
          Recalculates the bounds of a group node.
 void setAutoBoundsEnabled(boolean auto)
          Enabled or disables the autobounds feature of this realizer.
 void setAutoBoundsInsets(Insets insets)
          The same as setBorderInsets(Insets).
 void setBorderInsets(Insets inset)
          Sets the size of the empty border that will be added to the minimal bounds of this realizer.
protected  void setBoundsDirty()
          Invalidates the bounds of this realizer.
 void setClosedGroupIcon(Icon icon)
          Sets the icon to be used for the state label when the group is closed.
 void setConsiderNodeLabelSize(boolean considerNodeLabelSize)
          Whether label sizes shall be taken into account when calculating the minimal node bounds.
 void setGroupClosed(boolean closed)
          Opens or closes the group node realizer.
 void setGroupDepthFillColorEnabled(boolean enabled)
          Whether or not the fill color of this node should be adapted to reflect the local group depth of this node within the graph hierarchy.
 void setInnerGraphDisplayEnabled(boolean enabled)
          Sets whether or not the inner graph of a folder node should be displayed.
 void setMinimalInsets(Insets insets)
          Sets the insets that define the minimal distance between the border of the group node and its graph content.
 void setOpenGroupIcon(Icon icon)
          Sets the icon to be used for the state label when the group is open.
 void setSize(double w, double h)
          Sets the size of the realizer.
 void setStateLabel(NodeLabel stateLabel)
          Sets the state label of this realizer.
 void updateAutoSizeBounds()
          Forces recalculation of the autosize bounds.
 void write(ObjectOutputStream out)
          Writes this realizer in a serialized form to the given stream.
 
Methods inherited from class y.view.ShapeNodeRealizer
createSelectionColor, getDropShadowColor, getDropShadowOffsetX, getDropShadowOffsetY, getShapeType, hotSpotHit, isDropShadowVisible, moveBy, paint3DBorder, paintFilledShape, paintHotSpots, paintShadow, paintShapeBorder, setCenter, setDropShadowColor, setDropShadowOffsetX, setDropShadowOffsetY, setLocation, setShapeType, shapeTypeToStringMap
 
Methods inherited from class y.view.NodeRealizer
addLabel, boundsChanged, calcUnionRect, createCopy, createNodeLabel, getAutoBoundsFeature, getFillColor, getFillColor2, getHotSpotColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getMouseInputEditorProvider, getNode, getPortCandidates, getSizeConstraintProvider, getSloppySelectionColor, isInBox, isSelected, isTransparent, isVisible, labelCount, paint, paintLayer, paintLayerSloppy, removeLabel, repaint, setCenterX, setCenterY, setEdgesDirty, setFillColor, setFillColor2, setFrame, setFrame, setHeight, setHotSpotColor, setLabel, setLabelText, setLayer, setLayer, setLineColor, setLineType, setSelected, setSloppySelectionColor, setTransparent, setVisible, setWidth, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultClosedGroupIcon

public static final Icon defaultClosedGroupIcon
The default icon used by the state label, if the group realizer is closed.


defaultOpenGroupIcon

public static final Icon defaultOpenGroupIcon
The default icon used by the state label, if the group realizer is open.

Constructor Detail

GroupNodeRealizer

public GroupNodeRealizer()

GroupNodeRealizer

public GroupNodeRealizer(NodeRealizer arg)
Method Detail

createCopy

public NodeRealizer createCopy(NodeRealizer arg)
Description copied from class: ShapeNodeRealizer
Creates a copy of this realizer type that will be initialized with the values found in the given realizer.

Overrides:
createCopy in class ShapeNodeRealizer

getAutoBoundsInsets

public Insets getAutoBoundsInsets()
Description copied from interface: AutoBoundsFeature
Returns the currently set auto bounds insets.

Specified by:
getAutoBoundsInsets in interface AutoBoundsFeature

setAutoBoundsInsets

public void setAutoBoundsInsets(Insets insets)
The same as setBorderInsets(Insets).

Specified by:
setAutoBoundsInsets in interface AutoBoundsFeature

isAutoBoundsEnabled

public boolean isAutoBoundsEnabled()
Returns true if autobounds have been disabled and the realizer is not closed.

Specified by:
isAutoBoundsEnabled in interface AutoBoundsFeature
See Also:
isGroupClosed()

setAutoBoundsEnabled

public void setAutoBoundsEnabled(boolean auto)
Enabled or disables the autobounds feature of this realizer. The feature should be enabled when the realizer represents a open group and disabled when the realizer represents a closed folder.

If this feature is enabled and the realizer represents a group node in a graph hierarchy, then bounds of this realizer will be mainly determined by the bounds of the children of the underlying group node.

When turning this feature on, the bounds and the border of this node will change. The new bounds will be the union of the currently set bounds and the minimal bounds dictated by the children of the underlying group node. The new border will be set to represent the part of the new bounds that surmounts the previously set bounds.

Specified by:
setAutoBoundsEnabled in interface AutoBoundsFeature

getMinimalAutoBounds

public Rectangle2D getMinimalAutoBounds()
Description copied from interface: AutoBoundsFeature
Returns the minimal auto bounds of this object.

Specified by:
getMinimalAutoBounds in interface AutoBoundsFeature

updateAutoSizeBounds

public void updateAutoSizeBounds()
Forces recalculation of the autosize bounds.


setMinimalInsets

public void setMinimalInsets(Insets insets)
Sets the insets that define the minimal distance between the border of the group node and its graph content.

By default the insets are set to 15 for each side.

Specified by:
setMinimalInsets in interface GroupFeature
Parameters:
insets - the insets

getMinimalInsets

public Insets getMinimalInsets()
Returns the minimal insets defined for this realizer.

Specified by:
getMinimalInsets in interface GroupFeature
Returns:
the minimal insets defined for this realizer.
See Also:
setMinimalInsets(Insets)

setBorderInsets

public void setBorderInsets(Insets inset)
Sets the size of the empty border that will be added to the minimal bounds of this realizer.

Specified by:
setBorderInsets in interface GroupFeature
Parameters:
inset - the insets

getBorderInsets

public Insets getBorderInsets()
Returns the size of the empty border that will be added to the minimal bounds of this realizer.

Specified by:
getBorderInsets in interface GroupFeature
Returns:
the size of the empty border that will be added to the minimal bounds of this realizer.

setClosedGroupIcon

public void setClosedGroupIcon(Icon icon)
Sets the icon to be used for the state label when the group is closed.

See Also:
getStateLabel(), isGroupClosed()

setOpenGroupIcon

public void setOpenGroupIcon(Icon icon)
Sets the icon to be used for the state label when the group is open.

See Also:
getStateLabel(), isGroupClosed()

setGroupClosed

public void setGroupClosed(boolean closed)
Opens or closes the group node realizer. An open node realizer is typically used to represent a group node within a graph hierarchy. A closed node realizer is usually serves as a representation of a folder node within a graph hierarchy.

Specified by:
setGroupClosed in interface GroupFeature
Parameters:
closed - true for closing, false for opening a group node
See Also:
HierarchyManager.isGroupNode(Node), HierarchyManager.isFolderNode(Node)

isGroupClosed

public boolean isGroupClosed()
Returns true if this group node realizer is closed and false otherwise.

Specified by:
isGroupClosed in interface GroupFeature
Returns:
true if this group node realizer is closed and false otherwise.

setInnerGraphDisplayEnabled

public void setInnerGraphDisplayEnabled(boolean enabled)
Sets whether or not the inner graph of a folder node should be displayed. The node represented by this realizer must be a folder node in the graph hierarchy and the realizer must be in closed mode.

See Also:
HierarchyManager.isFolderNode(Node), isGroupClosed()

isInnerGraphDisplayEnabled

public boolean isInnerGraphDisplayEnabled()
Returns whether or not the inner graph of a folder node should be displayed.


paintSloppy

public void paintSloppy(Graphics2D gfx)
Description copied from class: NodeRealizer
Paints the realizer in a cheap, uniform and sloppy way on g. By default this call draws a rectangle with this realizer's bounds and colors. No label will be painted.

Overrides:
paintSloppy in class NodeRealizer

paintNode

protected void paintNode(Graphics2D gfx)
Paints the node. The way this realizer is painted strongly depends upon its open/closed state. For closed groups (aka folders) the inner graph is painted if the property is set.

Overrides:
paintNode in class ShapeNodeRealizer
See Also:
isGroupClosed(), paintShapeNode(java.awt.Graphics2D), paintInnerGraph(java.awt.Graphics2D)

paintShapeNode

protected void paintShapeNode(Graphics2D gfx)
Invokes the paintNode method of the ShapeNodeRealizer ancestor of this realizer.


paintText

public void paintText(Graphics2D gfx)
Description copied from class: NodeRealizer
Paints the labels that belong to this realizer

Overrides:
paintText in class NodeRealizer

setGroupDepthFillColorEnabled

public void setGroupDepthFillColorEnabled(boolean enabled)
Whether or not the fill color of this node should be adapted to reflect the local group depth of this node within the graph hierarchy. By default this feature is enabled.


isGroupDepthFillColorEnabled

public boolean isGroupDepthFillColorEnabled()
Whether or not the fill color of this node gets adapted to reflect the local group depth of this node within the graph hierarchy.

See Also:
setGroupDepthFillColorEnabled(boolean)

setStateLabel

public void setStateLabel(NodeLabel stateLabel)
Sets the state label of this realizer. A state label is typically used to display a button that allows to change the state (group or folder) of the node within the graph hierarchy.


getStateLabel

public NodeLabel getStateLabel()
Returns the state label of this realizer.


getBoundingBox

public Rectangle2D.Double getBoundingBox()
Description copied from class: NodeRealizer
Return the bounding box of this realizer. The bounding box does not necessarily contain the bounding box of the realizer label.

Overrides:
getBoundingBox in class NodeRealizer

recalculateBounds

protected void recalculateBounds()
Recalculates the bounds of a group node.


calcMinimumInsetBounds

protected Rectangle2D calcMinimumInsetBounds()
Calculates the minimum inset bounds of the open group node. The minimum inset bounds are composed of the minimum group bounds plus additional insets.


calcMinimumBounds

protected Rectangle2D calcMinimumBounds()
Calculates the minimum bounds of this realizer.


calcMinimumGroupBounds

protected Rectangle2D calcMinimumGroupBounds()
Calculates the minimal bounding box for the graph elements contained within the associated group node.


getHierarchyManager

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


isBoundsDirty

protected boolean isBoundsDirty()
Returns whether or not the bounds of a group node need to be recalculated.


setBoundsDirty

protected void setBoundsDirty()
Invalidates the bounds of this realizer.


paintInnerGraph

protected void paintInnerGraph(Graphics2D gfx)
Used to paints the inner graph of a folder node when innerGraphDisplay is enabled.


getY

public double getY()
Description copied from class: NodeRealizer
Get Y-Coordinate of the upper left corner of the node.

Specified by:
getY in interface NodeLayout
Overrides:
getY in class NodeRealizer

getCenterX

public double getCenterX()
Description copied from class: NodeRealizer
Get X-Coordinate of the center of the node.

Overrides:
getCenterX in class NodeRealizer

contains

public boolean contains(double x,
                        double y)
Description copied from class: ShapeNodeRealizer
Evaluate hit test on the node realizer. When a node is transparent, only its boundary is evaluated for the hit test.

Overrides:
contains in class ShapeNodeRealizer
Returns:
true if the position (x,y) is part of the node false otherwise.

getHeight

public double getHeight()
Description copied from class: NodeRealizer
Returns the height of this realizer.

Specified by:
getHeight in interface NodeLayout
Overrides:
getHeight in class NodeRealizer

getX

public double getX()
Description copied from class: NodeRealizer
Get X-Coordinate of the upper left corner of the node.

Specified by:
getX in interface NodeLayout
Overrides:
getX in class NodeRealizer

findIntersection

public boolean findIntersection(double ix,
                                double iy,
                                double ox,
                                double oy,
                                Point2D result)
Description copied from class: ShapeNodeRealizer
Special Intersection handling for some types of shape. When shape is an ellipse or an rectangle, the intersection point is calculated, not iteratively determined.

Overrides:
findIntersection in class ShapeNodeRealizer

getWidth

public double getWidth()
Description copied from class: NodeRealizer
Returns the width of this realizer.

Specified by:
getWidth in interface NodeLayout
Overrides:
getWidth in class NodeRealizer

getCenterY

public double getCenterY()
Description copied from class: NodeRealizer
Get Y-Coordinate of the center of the node.

Overrides:
getCenterY in class NodeRealizer

getMinimumSize

public YDimension getMinimumSize()
Description copied from interface: SizeConstraintProvider
Returns the minimum size the realizer that implements this interface must have.

Specified by:
getMinimumSize in interface SizeConstraintProvider
Returns:
the minimum size the realizer that implements this interface must have.

getMaximumSize

public YDimension getMaximumSize()
Description copied from interface: SizeConstraintProvider
Returns the maximum size the realizer that implements this interface can have.

Specified by:
getMaximumSize in interface SizeConstraintProvider
Returns:
the maximum size the realizer that implements this interface can have.

calculateMinimalLabelSize

protected Dimension2D calculateMinimalLabelSize()
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.

Returns:
the maximum label dimension the first text label and the state label do need.

labelBoundsChanged

protected void labelBoundsChanged(NodeLabel label)
Description copied from class: NodeRealizer
Callback method that should be overwritten by subclasses, that are interested in changes of the realizer label bounds. This method is called after the bounds of a NodeLabel (position or size) have changed.

Overrides:
labelBoundsChanged in class NodeRealizer
Parameters:
label - the label whoose bounds have changed.

intersects

public boolean intersects(double rx,
                          double ry,
                          double rw,
                          double rh)
Description copied from class: NodeRealizer
Returns true iff the bounding box of this realizer intersects with the given box.

Overrides:
intersects in class NodeRealizer

calcUnionRect

public void calcUnionRect(Rectangle2D r)
Description copied from class: ShapeNodeRealizer
Enlarges the given rectangle such that it will contain the bounding box of this realizer and the bounding box of the realizer label and its drop shadow.

Overrides:
calcUnionRect in class ShapeNodeRealizer

findBBIntersection

public boolean findBBIntersection(double ix,
                                  double iy,
                                  double ox,
                                  double oy,
                                  Point2D result)
Description copied from class: NodeRealizer
Returns true iff the coord (ix,iy) is identical with (getCenterX(),getCenterY()) and the coord (ox,oy), lies outside the bounding box of this realizer. In that case the intersection point of the line (ix,iy) - (ox,oy) with the bounding box of this realizer will be stored in the given point.

Overrides:
findBBIntersection in class NodeRealizer

write

public void write(ObjectOutputStream out)
           throws IOException
Description copied from class: ShapeNodeRealizer
Writes this realizer in a serialized form to the given stream.

Overrides:
write in class ShapeNodeRealizer
Throws:
IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Description copied from class: ShapeNodeRealizer
Reads in the serialized form of this realizer. The realizer must have been written out before by it's ShapeNodeRealizer.write(ObjectOutputStream) method.

Overrides:
read in class ShapeNodeRealizer
Throws:
IOException
ClassNotFoundException

setSize

public void setSize(double w,
                    double h)
Description copied from class: ShapeNodeRealizer
Sets the size of the realizer. Note that this method resizes the node in a way that the center location of this realizer won't change. The upper left corner of this realizer *will* change though.

Specified by:
setSize in interface NodeLayout
Overrides:
setSize in class ShapeNodeRealizer
Parameters:
w - the width of the node.
h - the height of the node.

isConsiderNodeLabelSize

public boolean isConsiderNodeLabelSize()
Returns whether label sizes will be taken into account when calculating the minimal node bounds. Method calculateMinimalLabelSize() 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() 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.

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