y.view.hierarchy
Class GroupNodeRealizer

java.lang.Object
  |
  +--y.view.NodeRealizer
        |
        +--y.view.ShapeNodeRealizer
              |
              +--y.view.hierarchy.GroupNodeRealizer
All Implemented Interfaces:
AutoBoundsFeature, NodeLayout

public class GroupNodeRealizer
extends ShapeNodeRealizer
implements AutoBoundsFeature

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 (GroupNodeRealizer.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)).


Nested Class Summary
static class GroupNodeRealizer.StateChangeListener
          This static inner class can be used to automatically adjust the groupClosed property of GroupNodeRealizer instances.
 
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
 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.
 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 heirarchy manager responsibly for managing the node represented by this realizer.
 Rectangle2D getMinimalAutoBounds()
          Returns the minimal auto bounds of this object.
 Insets getMinimalInsets()
          Returns the minimal insets defined for this realizer.
 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.
 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 paintNode(Graphics2D gfx)
          Paints the node.
 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.
 void setAutoBoundsEnabled(boolean auto)
          Enabled or disables the autobounds feature of this realizer.
 void setAutoBoundsInsets(Insets insets)
          The same as GroupNodeRealizer.setBorderInsets(Insets).
 void setBorderInsets(Insets inset)
          Sets the size of the empty border that will be added to the minimal bounds of this realizer.
 void setClosedGroupIcon(Icon icon)
          Sets the icon to be used for the state label when the group is closed.
 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 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
getShapeType, moveBy, setCenter, setLocation, setShapeType, setSize, shapeTypeToStringMap
 
Methods inherited from class y.view.NodeRealizer
addLabel, calcUnionRect, createCopy, createNodeLabel, getFillColor, getFillColor2, getHotSpotColor, getLabel, getLabel, getLabelText, getLayer, getLineColor, getLineType, getNode, getPortCandidates, getSloppySelectionColor, hotSpotHit, isInBox, isSelected, isTransparent, isVisible, labelCount, paint, paintHotSpots, paintLayer, paintLayerSloppy, removeLabel, 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 GroupNodeRealizer.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:
GroupNodeRealizer.isGroupClosed()

setAutoBoundsEnabled

public void setAutoBoundsEnabled(boolean auto)
Enabled or disables the autobounds feature of this realizer. The feature should be enabled when the realizer represnets 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.


getMinimalInsets

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

See Also:
GroupNodeRealizer.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.


getBorderInsets

public Insets getBorderInsets()
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:
GroupNodeRealizer.getStateLabel(), GroupNodeRealizer.isGroupClosed()

setOpenGroupIcon

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

See Also:
GroupNodeRealizer.getStateLabel(), GroupNodeRealizer.isGroupClosed()

setGroupClosed

public void setGroupClosed(boolean closed)
Opens or closes the group node realizer. An open node realizer is typically used to represnet 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.

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

isGroupClosed

public boolean isGroupClosed()
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), GroupNodeRealizer.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)
Description copied from class: ShapeNodeRealizer
Paints the node.

Overrides:
paintNode in class ShapeNodeRealizer

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

getHierarchyManager

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


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

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: NodeRealizer
Enlarges the given rectangle such that it will contain the bounding box of this realizer and the bounding box of the realizer label.

Overrides:
calcUnionRect in class NodeRealizer

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
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
IOException
ClassNotFoundException

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

2003