com.mindfusion.diagramming
Class ContainerNode

java.lang.Object
  extended by com.mindfusion.diagramming.DiagramItem
      extended by com.mindfusion.diagramming.DiagramNode
          extended by com.mindfusion.diagramming.ContainerNode
All Implemented Interfaces:
InplaceEditable, java.io.Externalizable, java.io.Serializable

public class ContainerNode
extends DiagramNode
implements InplaceEditable

Implements nodes that can contain other nodes.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.mindfusion.diagramming.DiagramNode
allowIncomingLinks, allowOutgoingLinks, anchorPattern, AV_Cancel, AV_EndModIncoming, AV_EndModOutgoing, AV_StartModIncoming, AV_StartModOutgoing, AV_UpdateIncoming, AV_UpdateOutgoing, AV_UpdIntscIncoming, AV_UpdIntscOutgoing, AV_UpdPosIncoming, AV_UpdPosOutgoing, bounds, enabledHandles, handlesStyle, incomingLinks, masterGroup, obstacle, outgoingLinks, savedBounds
 
Fields inherited from class com.mindfusion.diagramming.DiagramItem
brush, cycleDetected, cycleProtect, modifyDX, modifyDY, modifyHandle, modifying, pen, ptEnd, ptMdfLast, ptOrg, ptSavedEnd, ptSavedOrg, subordinateGroup
 
Constructor Summary
ContainerNode()
          Initializes a new instance of the ContainerNode class.
ContainerNode(ContainerNode prototype)
          Initializes a new instance of the ContainerNode class using the specified node as a prototype.
ContainerNode(Diagram parent)
          Initializes a new instance of the ContainerNode class with the default values of the specified diagram.
 
Method Summary
 void add(DiagramNode node)
          Adds a node to this container.
 boolean containsRecursively(DiagramNode node)
          Determines whether this container contains the specified node, either directly or recursively through other containers.
protected  DiagramItemProperties createProperties()
          DiagramItem.createProperties() override.
 void drawLocal(java.awt.Graphics2D graphics, RenderOptions options)
          Draws the container on the specified Graphics2D surface.
 boolean getAutoShrink()
          Gets a value indicating whether the container should shrink in size when nodes are removed from it.
 java.lang.String getCaption()
          Gets the container's caption text.
 Brush getCaptionBackBrush()
          Gets the brush used to paint the caption area of this container.
 Brush getCaptionBrush()
          Gets the brush used to draw the container's caption text.
 TextFormat getCaptionFormat()
          Gets the caption alignment and format.
 float getCaptionHeight()
          Gets the height of the container's caption area.
static ContainerNode getContainer(DiagramNode node)
          Retrieves the container node (if any) the specified node belongs to.
 float getCornerRadius()
          Gets the radius of node's corner arcs when its Shape is set to RoundedRectangle.
 java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
          Implements InplaceEditable.
 Brush getEffectiveCaptionBrush()
          Creates a Brush object representing the currently effective caption brush of the container.
 boolean getFoldable()
          Gets a value indicating whether the user is allowed to fold this container.
 boolean getFolded()
          Gets a value indicating whether this container is folded.
 java.awt.geom.Dimension2D getFoldedSize()
          Gets the size of the container when folded.
 Pen getHighlightPen()
          Gets the Pen used to draw the container frame lines when an item is dragged over the container.
 float getMargin()
          Gets how much space should be left between contained nodes and the container borders.
 java.awt.geom.Dimension2D getMinimumSize()
          Gets the minimum size of the container.
 int getShape()
          Gets the shape of this container.
 java.lang.String getTextToEdit()
          Implements InplaceEditable.
 java.awt.geom.Dimension2D getUnfoldedSize()
          Returns the original size of a folded container.
 boolean getVisible()
          Gets a value indicating whether the container is visible.
 int hitTestHandle(java.awt.geom.Point2D point)
          DiagramNode.hitTestHandle(java.awt.geom.Point2D) override.
protected  void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
          Loads the item content from an XML element.
protected  void onChildModified(DiagramNode node, int handle)
          Called when a group child node has been modified.
 void onDragOut(DiagramItem item)
          Invoked when a diagram item is being dragged out of this node.
 boolean onDragOver(DiagramItem item)
          Invoked when a diagram item is being dragged over this node.
 boolean onDropOver(DiagramItem item)
          Invoked when a diagram item is dropped over this node.
 void readExternal(java.io.ObjectInput in)
          Implements Externalizable.
 void remove(DiagramNode node)
          Removes a node from this container.
protected  void restoreProperties(DiagramItemProperties props)
          DiagramItem.restoreProperties(com.mindfusion.diagramming.DiagramItemProperties) override.
protected  void saveProperties(DiagramItemProperties props)
          DiagramItem.saveProperties(com.mindfusion.diagramming.DiagramItemProperties) override.
protected  void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
          Saves the item content into an XML element.
 void setAutoShrink(boolean value)
          Sets a value indicating whether the container should shrink in size when nodes are removed from it.
 void setCaption(java.lang.String value)
          Sets the container's caption text.
 void setCaptionBackBrush(Brush value)
          Sets the brush used to paint the caption area of this container.
 void setCaptionBrush(Brush value)
          Sets the brush used to draw the container's caption text.
 void setCaptionFormat(TextFormat value)
          Sets the caption alignment and format.
 void setCaptionHeight(float value)
          Sets the height of the container's caption area.
 void setCornerRadius(float value)
          Sets the radius of node's corner arcs when its Shape is set to RoundedRectangle.
 void setEditedText(java.lang.String newText)
          Implements InplaceEditable.
 void setFoldable(boolean value)
          Sets a value indicating whether the user is allowed to fold this container.
 void setFolded(boolean value)
          Sets a value indicating whether this container is folded.
 void setFoldedSize(java.awt.geom.Dimension2D value)
          Sets the size of the container when folded.
 void setHighlightPen(Pen value)
          Sets the Pen used to draw the container frame lines when an item is dragged over the container.
 void setMargin(float value)
          Sets how much space should be left between contained nodes and the container borders.
 void setMinimumSize(java.awt.geom.Dimension2D value)
          Sets the minimum size of the container.
 void setShape(int value)
          Sets the shape of this container.
 void setVisible(boolean value)
          Sets a value indicating whether the container is visible.
 void updateBounds()
          Updates the container bounds to fit its contents.
 void updateBounds(boolean includeLinks)
          Updates the container bounds to fit its contents.
 void writeExternal(java.io.ObjectOutput out)
          Implements Externalizable.
 
Methods inherited from class com.mindfusion.diagramming.DiagramNode
allowCreate, allowModify, attachTo, attachTo, attachTo, cancelModify, completeCreate, completeModify, constraintsInfringed, containsPoint, containsPoint, createConnectionPoint, createState, detach, draw, drawShadow, drawShadowLocal, getAllIncomingLinks, getAllLinks, getAllOutgoingLinks, getAllowIncomingLinks, getAllowOutgoingLinks, getAnchorPattern, getBounds, getCenter, getConstraints, getEffects, getEnabledHandles, getExpandable, getExpanded, getHandlesStyle, getIncomingLinks, getLocalBounds, getLocalBoundsD, getMasterGroup, getObstacle, getOutgoingLinks, getRepaintRect, getRotatedBounds, getRotationAngle, groupContains, move, moveTo, nodesIntersect, onRemove, onRotationAngleChanged, onUpdateBounds, putExpandable, rectFromPoints, resize, resizeToFitImage, restoreState, saveState, setAllowIncomingLinks, setAllowOutgoingLinks, setAnchorPattern, setBounds, setBounds, setBoundsDirect, setConstraints, setEnabledHandles, setExpandable, setExpanded, setExpandedFlag, setHandlesStyle, setObstacle, setReflexive, setRotationAngle, shouldRenderAnchors, startCreate, startModify, updateCreate, updateLinkPositions, updateModify
 
Methods inherited from class com.mindfusion.diagramming.DiagramItem
clone, getBrush, getEffectiveBrush, getEffectiveFont, getEffectivePen, getEffectiveShadowBrush, getEffectiveTextBrush, getFont, getHyperLink, getId, getIgnoreLayout, getLayerIndex, getLayoutTraits, getLocked, getMeasureUnit, getParent, getPen, getPrintable, getRuntimeIndex, getSelected, getShadowBrush, getShadowOffsetX, getShadowOffsetY, getStyle, getSubordinateGroup, getTag, getTextBrush, getTextPadding, getToolTip, getValue, getWeight, getZIndex, hasSubordinates, onAdd, onChangeFont, onChangeTextPadding, onClick, onDoubleClick, onLoad, onModify, onStyleChanged, putSelected, query, repaint, repaint, repaint, setBrush, setDiagramDirty, setFont, setHyperLink, setId, setIgnoreLayout, setLayerIndex, setLocked, setPen, setPrintable, setSelected, setShadowBrush, setShadowOffsetX, setShadowOffsetY, setStyle, setTag, setTextBrush, setTextPadding, setToolTip, setWeight, setZIndex, shouldRender, zBottom, zLevelDown, zLevelUp, zTop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerNode

public ContainerNode()
Initializes a new instance of the ContainerNode class.


ContainerNode

public ContainerNode(Diagram parent)
Initializes a new instance of the ContainerNode class with the default values of the specified diagram.


ContainerNode

public ContainerNode(ContainerNode prototype)
Initializes a new instance of the ContainerNode class using the specified node as a prototype.

Method Detail

add

public void add(DiagramNode node)
Adds a node to this container. If the container bounds do not include the specified node bounds, the container will grow automatically to accommodate the new node.

Parameters:
node - The DiagramNode that should be added to the container.

remove

public void remove(DiagramNode node)
Removes a node from this container.

Parameters:
node - The DiagramNode that should be removed from the container.

drawLocal

public void drawLocal(java.awt.Graphics2D graphics,
                      RenderOptions options)
Draws the container on the specified Graphics2D surface.

Overrides:
drawLocal in class DiagramNode
Parameters:
graphics - A Graphics2D object where the node should be rendered.
options - Provides options for the drawing operation.

hitTestHandle

public int hitTestHandle(java.awt.geom.Point2D point)
DiagramNode.hitTestHandle(java.awt.geom.Point2D) override.

Parameters:
point - A Point2D value specifying where to look for a selection handle.
Returns:
The index of a selection handle, or -1 if there isn't any handle found at the specified position.

onDragOver

public boolean onDragOver(DiagramItem item)
Invoked when a diagram item is being dragged over this node.

Overrides:
onDragOver in class DiagramNode
Parameters:
item - The DiagramItem being dragged.
Returns:
false if the diagram should notify nodes below this one; otherwise, true.

onDragOut

public void onDragOut(DiagramItem item)
Invoked when a diagram item is being dragged out of this node.

Overrides:
onDragOut in class DiagramNode
Parameters:
item - The DiagramItem being dragged.

onDropOver

public boolean onDropOver(DiagramItem item)
Invoked when a diagram item is dropped over this node.

Overrides:
onDropOver in class DiagramNode
Parameters:
item - The DiagramItem being dragged.
Returns:
false if the diagram should notify nodes below this one; otherwise, true.

onChildModified

protected void onChildModified(DiagramNode node,
                               int handle)
Called when a group child node has been modified.

Overrides:
onChildModified in class DiagramItem
Parameters:
node - The DiagramNode that has been moved or resized.
handle - An AdjustmentHandles constant indicating which handle has been used to modify the node.

updateBounds

public void updateBounds()
Updates the container bounds to fit its contents.


updateBounds

public void updateBounds(boolean includeLinks)
Updates the container bounds to fit its contents.


writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Implements Externalizable.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class DiagramNode
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implements Externalizable.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class DiagramNode
Throws:
java.io.IOException
java.lang.ClassNotFoundException

saveToXml

protected void saveToXml(org.w3c.dom.Element xmlElement,
                         XmlPersistContext context)
Saves the item content into an XML element.

Overrides:
saveToXml in class DiagramNode
Parameters:
xmlElement - An Element the item's data should be stored into.
context - Provides contextual information about the serialization process and some helper serialization methods.

loadFromXml

protected void loadFromXml(org.w3c.dom.Element xmlElement,
                           XmlPersistContext context)
                    throws javax.xml.transform.TransformerException,
                           XmlException
Loads the item content from an XML element.

Overrides:
loadFromXml in class DiagramNode
Parameters:
xmlElement - An Element containing the item's data.
context - Provides contextual information about the serialization process and some helper serialization methods.
Throws:
javax.xml.transform.TransformerException
XmlException

createProperties

protected DiagramItemProperties createProperties()
DiagramItem.createProperties() override.

Overrides:
createProperties in class DiagramNode
Returns:
A DiagramItemProperties-derived object containing a snapshot of the item's properties.

saveProperties

protected void saveProperties(DiagramItemProperties props)
DiagramItem.saveProperties(com.mindfusion.diagramming.DiagramItemProperties) override.

Overrides:
saveProperties in class DiagramNode
Parameters:
props - A DiagramItemProperties-derived object where the item's properties should be saved.

restoreProperties

protected void restoreProperties(DiagramItemProperties props)
DiagramItem.restoreProperties(com.mindfusion.diagramming.DiagramItemProperties) override.

Overrides:
restoreProperties in class DiagramNode
Parameters:
props - A DiagramItemProperties -derived object containing a snapshot of the item's properties.

getTextToEdit

public java.lang.String getTextToEdit()
Implements InplaceEditable.

Specified by:
getTextToEdit in interface InplaceEditable

setEditedText

public void setEditedText(java.lang.String newText)
Implements InplaceEditable.

Specified by:
setEditedText in interface InplaceEditable

getEditRect

public java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
Implements InplaceEditable.

Specified by:
getEditRect in interface InplaceEditable

getContainer

public static ContainerNode getContainer(DiagramNode node)
Retrieves the container node (if any) the specified node belongs to.

Parameters:
node - The DiagramNode whose container you need to find.
Returns:
A ContainerNode that contains the specified node, or null if the node is not contained.

containsRecursively

public boolean containsRecursively(DiagramNode node)
Determines whether this container contains the specified node, either directly or recursively through other containers.

Parameters:
node - The DiagramNode to check.
Returns:
true if this container contains the node; otherwise, false.

getHighlightPen

public Pen getHighlightPen()
Gets the Pen used to draw the container frame lines when an item is dragged over the container.


setHighlightPen

public void setHighlightPen(Pen value)
Sets the Pen used to draw the container frame lines when an item is dragged over the container.


getMargin

public float getMargin()
Gets how much space should be left between contained nodes and the container borders.


setMargin

public void setMargin(float value)
Sets how much space should be left between contained nodes and the container borders.


getMinimumSize

public java.awt.geom.Dimension2D getMinimumSize()
Gets the minimum size of the container. The container won't shrink smaller than that size, even if it does not contain any items.


setMinimumSize

public void setMinimumSize(java.awt.geom.Dimension2D value)
Sets the minimum size of the container. The container won't shrink smaller than that size, even if it does not contain any items.


getCaption

public java.lang.String getCaption()
Gets the container's caption text.


setCaption

public void setCaption(java.lang.String value)
Sets the container's caption text.


getCaptionBrush

public Brush getCaptionBrush()
Gets the brush used to draw the container's caption text.


setCaptionBrush

public void setCaptionBrush(Brush value)
Sets the brush used to draw the container's caption text.


getEffectiveCaptionBrush

public Brush getEffectiveCaptionBrush()
Creates a Brush object representing the currently effective caption brush of the container. This method returns a system brush corresponding to the container's CaptionBrush if the container's CaptionBrush is not null, or a system brush corresponding to the TextBrush property of the container's style.


getCaptionHeight

public float getCaptionHeight()
Gets the height of the container's caption area.


setCaptionHeight

public void setCaptionHeight(float value)
Sets the height of the container's caption area.


getCaptionBackBrush

public Brush getCaptionBackBrush()
Gets the brush used to paint the caption area of this container.


setCaptionBackBrush

public void setCaptionBackBrush(Brush value)
Sets the brush used to paint the caption area of this container.

Parameters:
value - A Brush instance that should be used to paint caption area.

getCaptionFormat

public TextFormat getCaptionFormat()
Gets the caption alignment and format.


setCaptionFormat

public void setCaptionFormat(TextFormat value)
Sets the caption alignment and format.


getFolded

public boolean getFolded()
Gets a value indicating whether this container is folded. When folded, the container children are not visible, and only its caption bar is displayed.


setFolded

public void setFolded(boolean value)
Sets a value indicating whether this container is folded. When folded, the container children are not visible, and only its caption bar is displayed.


getFoldable

public boolean getFoldable()
Gets a value indicating whether the user is allowed to fold this container. A foldable container can be folded and unfolded by clicking the up/down arrow displayed in the caption area.


setFoldable

public void setFoldable(boolean value)
Sets a value indicating whether the user is allowed to fold this container. A foldable container can be folded and unfolded by clicking the up/down arrow displayed in the caption area.


getAutoShrink

public boolean getAutoShrink()
Gets a value indicating whether the container should shrink in size when nodes are removed from it.


setAutoShrink

public void setAutoShrink(boolean value)
Sets a value indicating whether the container should shrink in size when nodes are removed from it.


getVisible

public boolean getVisible()
Gets a value indicating whether the container is visible.

Overrides:
getVisible in class DiagramItem
Returns:
true if the item is visible, otherwise false.

setVisible

public void setVisible(boolean value)
Sets a value indicating whether the container is visible.

Overrides:
setVisible in class DiagramItem
Parameters:
value - true if the item should be visible, otherwise false.

getFoldedSize

public java.awt.geom.Dimension2D getFoldedSize()
Gets the size of the container when folded.


setFoldedSize

public void setFoldedSize(java.awt.geom.Dimension2D value)
Sets the size of the container when folded.


getUnfoldedSize

public java.awt.geom.Dimension2D getUnfoldedSize()
Returns the original size of a folded container.


getShape

public int getShape()
Gets the shape of this container.

Returns:
One of the SimpleShape constants.

setShape

public void setShape(int value)
Sets the shape of this container.

Parameters:
value - One of the SimpleShape constants.

getCornerRadius

public float getCornerRadius()
Gets the radius of node's corner arcs when its Shape is set to RoundedRectangle.

Returns:
The radius of node's corner arcs.

setCornerRadius

public void setCornerRadius(float value)
Sets the radius of node's corner arcs when its Shape is set to RoundedRectangle.

Parameters:
value - The radius of node's corner arcs.