Search this API

y.view.hierarchy
Class GenericGroupNodeRealizer

java.lang.Object
  extended by y.view.NodeRealizer
      extended by y.view.GenericNodeRealizer
          extended by y.view.hierarchy.GenericGroupNodeRealizer
All Implemented Interfaces:
NodeLayout, GroupFeature, MouseInputEditorProvider
Direct Known Subclasses:
TableGroupNodeRealizer

public class GenericGroupNodeRealizer
extends GenericNodeRealizer
implements GroupFeature

This class is a specialization of GenericNodeRealizer for group and folder nodes. It is a node realizer that is crafted to represent group and folder nodes within a graph hierarchy. A GenericGroupNodeRealizer 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)). The main appearance can easily be customized by setting an own GenericNodeRealizer.Painter implementation. Note: If you are using the default implementation createDefaultConfigurationMap() please make sure to enable node hits on your MouseInputMode:

EditMode editMode = new EditMode(); editMode.getMouseInputMode().setNodeSearchingEnabled(true);
This is necessary to handle mouse clicks on the state label to open/close the group.

 

Nested Class Summary
static interface GenericGroupNodeRealizer.GenericAutoBoundsFeature
          Additional interface for node realizers whose bounds may be determined by other factors then explicit bound assignment.
 
Nested classes/interfaces inherited from class y.view.GenericNodeRealizer
GenericNodeRealizer.BoundsChangedHandler, GenericNodeRealizer.ContainsTest, GenericNodeRealizer.Factory, GenericNodeRealizer.GenericMouseInputEditorProvider, GenericNodeRealizer.GenericSizeConstraintProvider, GenericNodeRealizer.HotSpotHitTest, GenericNodeRealizer.HotSpotPainter, GenericNodeRealizer.Initializer, GenericNodeRealizer.IntersectionTest, GenericNodeRealizer.LabelBoundsChangedHandler, GenericNodeRealizer.LabelFactory, GenericNodeRealizer.LayerHandler, GenericNodeRealizer.Painter, GenericNodeRealizer.PortCandidateListProvider, GenericNodeRealizer.SelectionChangeHandler, GenericNodeRealizer.UnionRectCalculator, GenericNodeRealizer.UserDataHandler
 
Field Summary
 
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
GenericGroupNodeRealizer()
           
GenericGroupNodeRealizer(NodeRealizer nr)
           
 
Method Summary
protected  void adoptValues(GenericNodeRealizer cnr)
          Tries to copy all the values from the given instance to this instance.
 void calcUnionRect(java.awt.geom.Rectangle2D r)
          Uses the registered GenericNodeRealizer.UnionRectCalculator implementation to delegate the actual work to.
 NodeRealizer createCopy(NodeRealizer nr)
          Creates a copy of the given Realizer, using as much information as possible from the given instance to create a new GenericNodeRealizer instance.
static java.util.Map createDefaultConfigurationMap()
          Returns a Map holding the default configuration for GenericGroupNodeRealizer.
 AutoBoundsFeature getAutoBoundsFeature()
          Returns a feature, that can be used to automatically adjust the NodeRealizers bounds.
 YInsets getBorderInsets()
          Returns the size of the empty border that will be added to the minimal bounds of this realizer.
 java.awt.geom.Rectangle2D.Double getBoundingBox()
          Return the bounding box of this realizer.
 double getClosedHeight()
          Returns the height for the realizer's closed state.
 double getClosedWidth()
          Returns the width for the realizer's closed state.
 YInsets getMinimalInsets()
          Returns the minimal insets defined for this realizer.
static HierarchyListener getStateChangeListener()
          returns a hierarchy listener for adjusting the groupClosed property of GroupFeature instances.
 boolean isAutoResize()
          Whether the realizer will resize its bounds or not.
 boolean isBoundsDirty()
          Returns whether or not the bounds of this realizer are considered to be dirty.
 boolean isGroupClosed()
          Whether the node is closed or not.
 void read(java.io.ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
 void setAutoResize(boolean autoResize)
          Whether the realizer will resize its bounds or not.
 void setBorderInsets(java.awt.Insets insets)
          Deprecated. Use setBorderInsets(y.geom.YInsets) instead.
 void setBorderInsets(YInsets insets)
          Sets the size of the empty border that will be added to the minimal bounds of this realizer.
 void setBoundsDirty(boolean boundsDirty)
          Sets this realizer's boundsDirty property to the specified value.
 void setClosedHeight(double closedHeight)
          Sets the height for of this realizer in its closed state.
 void setClosedWidth(double closedWidth)
          Sets the width for of this realizer in its closed state.
 void setGroupClosed(boolean closed)
          Opens or closes the group node realizer.
 void setMinimalInsets(java.awt.Insets insets)
          Deprecated. Use setMinimalInsets(y.geom.YInsets) instead.
 void setMinimalInsets(YInsets insets)
          Sets the insets that define the minimal distance between the border of the group node and its graph content.
 void write(java.io.ObjectOutputStream out)
          Deprecated. Use the GraphML format instead.
 
Methods inherited from class y.view.GenericNodeRealizer
boundsChanged, contains, createNodeLabel, findIntersection, findMouseInputEditor, getConfiguration, getFactory, getLayer, getMouseInputEditorProvider, getPortCandidates, getSizeConstraintProvider, getStyleProperties, getStyleProperty, getUserData, hotSpotHit, labelBoundsChanged, paint, paintHotSpots, paintNode, paintSloppy, removeStyleProperty, setConfiguration, setLayer, setStyleProperty, setUserData
 
Methods inherited from class y.view.NodeRealizer
addLabel, addPort, calcUnionRect, calcUnionRectImpl, calcUnionRectLabels, calcUnionRectPorts, createCopy, findBBIntersection, getCenterX, getCenterY, getFillColor, getFillColor2, getHeight, getHotSpotColor, getLabel, getLabel, getLabelText, getLineColor, getLineType, getNode, getPort, getSloppySelectionColor, getWidth, getX, getY, intersects, invalidatePortPositions, isInBox, isSelected, isTransparent, isVisible, labelCount, moveBy, paintLayer, paintLayerSloppy, paintPorts, paintText, portCount, removeLabel, removeLabel, removePort, removePort, repaint, setCenter, setCenterX, setCenterY, setEdgesDirty, setFillColor, setFillColor2, setFrame, setFrame, setHeight, setHotSpotColor, setLabel, setLabelText, setLayer, setLineColor, setLineType, setLocation, setSelected, setSize, setSloppySelectionColor, setTransparent, setVisible, setWidth, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericGroupNodeRealizer

public GenericGroupNodeRealizer()

GenericGroupNodeRealizer

public GenericGroupNodeRealizer(NodeRealizer nr)
Method Detail

adoptValues

protected void adoptValues(GenericNodeRealizer cnr)
Description copied from class: GenericNodeRealizer
Tries to copy all the values from the given instance to this instance. Customization interfaces will be copied by reference, user-defined data will be copied using the GenericNodeRealizer.UserDataHandler implementation or by reference if no such handler is registered with the argument's instance.

Overrides:
adoptValues in class GenericNodeRealizer
Parameters:
cnr - the realizer to obtain the configuration from

createDefaultConfigurationMap

public static java.util.Map createDefaultConfigurationMap()
Returns a Map holding the default configuration for GenericGroupNodeRealizer.

Returns:
A new Map instance.

calcUnionRect

public void calcUnionRect(java.awt.geom.Rectangle2D r)
Description copied from class: GenericNodeRealizer
Uses the registered GenericNodeRealizer.UnionRectCalculator implementation to delegate the actual work to. If no such instance is registered with this instance super.calcUnionRect(r); is called.

Overrides:
calcUnionRect in class GenericNodeRealizer

isAutoResize

public boolean isAutoResize()
Whether the realizer will resize its bounds or not. By default this is set to true.

Returns:
whether this realizer will adjust its size automatically. Default is true.

setAutoResize

public void setAutoResize(boolean autoResize)
Whether the realizer will resize its bounds or not. By default this is set to true.

Parameters:
autoResize - whether this realizer will adjust its size automatically. Default is true.

isGroupClosed

public boolean isGroupClosed()
Whether the node is closed or not.

Specified by:
isGroupClosed in interface GroupFeature
Returns:
whether this realizer is in closed state.

isBoundsDirty

public boolean isBoundsDirty()
Returns whether or not the bounds of this realizer are considered to be dirty. In this context, dirty means that the GenericGroupNodeRealizer.GenericAutoBoundsFeature associated to this realizer (via its configuration) needs to recalculate the realizer's bounds when the realizer is queried for its bounding box.

Returns:
whether or not the bounds of this realizer are considered to be dirty.

setBoundsDirty

public void setBoundsDirty(boolean boundsDirty)
Sets this realizer's boundsDirty property to the specified value. A value of true means that the bounds of this realizer are considered to be dirty. In this context, dirty means that the GenericGroupNodeRealizer.GenericAutoBoundsFeature associated to this realizer (via its configuration) needs to recalculate the realizer's bounds when the realizer is queried for its bounding box.

Note: It is the responsibility of the GenericAutoBoundsFeature implementation to mark a realizer's bounds as not dirty (anymore), i.e. setting the boundsDirty property to false.

Parameters:
boundsDirty - the new value for the boundsDirty property.

getClosedWidth

public double getClosedWidth()
Returns the width for the realizer's closed state.

Returns:
the width for the realizer's closed state.
See Also:
setClosedWidth(double)

setClosedWidth

public void setClosedWidth(double closedWidth)
Sets the width for of this realizer in its closed state.

Note: Changing from closed to open state will set closedWidth to the width of the realizer right before changing state. Changing from open to closed state will possibly update closedWidth to respect minimum width constraints of an associated SizeConstraintProvider.

Parameters:
closedWidth - the width for the closed state of the realizer.
See Also:
isGroupClosed(), setGroupClosed(boolean)

getClosedHeight

public double getClosedHeight()
Returns the height for the realizer's closed state.

Returns:
the height for the realizer's closed state.
See Also:
setClosedHeight(double)

setClosedHeight

public void setClosedHeight(double closedHeight)
Sets the height for of this realizer in its closed state.

Note: Changing from closed to open state will set closedHeight to the height of the realizer right before changing state. Changing from open to closed state will possibly update closedHeight to respect minimum height constraints of an associated SizeConstraintProvider.

Parameters:
closedHeight - the height for the closed state of the realizer.
See Also:
isGroupClosed(), setGroupClosed(boolean)

createCopy

public NodeRealizer createCopy(NodeRealizer nr)
Description copied from class: GenericNodeRealizer
Creates a copy of the given Realizer, using as much information as possible from the given instance to create a new GenericNodeRealizer instance.

Overrides:
createCopy in class GenericNodeRealizer
Parameters:
nr - the realizer to create the copy of
Returns:
a instance of GenericNodeRealizer

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 - whether to set the realizer state to open or close.
See Also:
HierarchyManager.isGroupNode(Node), HierarchyManager.isFolderNode(Node)

getBoundingBox

public java.awt.geom.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

getBorderInsets

public YInsets 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.
See Also:
setBorderInsets(y.geom.YInsets)

getMinimalInsets

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

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

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

getStateChangeListener

public static HierarchyListener getStateChangeListener()
returns a hierarchy listener for adjusting the groupClosed property of GroupFeature instances. Add this HierarchyListener implementation to the respective HierarchyManager instances and changes of the group nodes' states will be automatically reflected by the groupClosed property.

Returns:
a hierarchy listener

getAutoBoundsFeature

public AutoBoundsFeature getAutoBoundsFeature()
Description copied from class: NodeRealizer
Returns a feature, that can be used to automatically adjust the NodeRealizers bounds.

Overrides:
getAutoBoundsFeature in class NodeRealizer
Returns:
an implementation of interface AutoBoundsFeature or null, if no feature is bound to this realizer.

setMinimalInsets

public void setMinimalInsets(java.awt.Insets insets)
Deprecated. Use setMinimalInsets(y.geom.YInsets) instead.

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.

Parameters:
insets - the insets that are to be set.

setMinimalInsets

public void setMinimalInsets(YInsets 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 that are to be set.
See Also:
getMinimalInsets()

setBorderInsets

public void setBorderInsets(java.awt.Insets insets)
Deprecated. Use setBorderInsets(y.geom.YInsets) instead.

Sets the size of the empty border that will be added to the minimal bounds of this realizer.

Parameters:
insets - the insets to be set.

setBorderInsets

public void setBorderInsets(YInsets insets)
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:
insets - the insets to be set.
See Also:
getBorderInsets()

read

public void read(java.io.ObjectInputStream in)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Deprecated. Use the GraphML format instead.

Description copied from class: NodeRealizer
Reads in the serialized form of this realizer. The realizer must have been written out before by it's NodeRealizer.write(ObjectOutputStream) method.

Overrides:
read in class GenericNodeRealizer
Throws:
java.io.IOException
java.lang.ClassNotFoundException

write

public void write(java.io.ObjectOutputStream out)
           throws java.io.IOException
Deprecated. Use the GraphML format instead.

Description copied from class: NodeRealizer
Writes this realizer in a serialized form to the given stream.

Overrides:
write in class GenericNodeRealizer
Throws:
java.io.IOException

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