public class ShapeNode extends DiagramNode implements RenderTextCallback, InplaceEditable
Use the setShape(com.mindfusion.diagramming.Shape) method to specify the shape of a node. There are many
predefined shapes provided by the Shape class, which also lets you
define your custom shapes.
ShapeNodes can be rotated, either interactively using the rotation handle above a
node, or programmatically using the DiagramNode.setRotationAngle(float) method.
Nodes can display images and text. Use the setImage(java.awt.Image) method to specify
an image that should be painted inside a node. The position and alignment of
an image within the node are set via the setImageAlign(com.mindfusion.diagramming.ImageAlign) method.
To make a node as big as its image, call resizeToFitImage().
To set the node's text, call setText(java.lang.String). The text attributes can be changed
through the DiagramItem.setTextBrush(com.mindfusion.drawing.Brush) and setTextFormat(com.mindfusion.drawing.TextFormat) methods. To get
even richer text formatting, call setEnableStyledText(boolean) to true and
embed HTML-like formatting tags in the raw text. To make a node big enough to display
its text without clipping, call resizeToFitText(com.mindfusion.diagramming.FitSize).
Call setTransparent(boolean) to make a node transparent, so that only its
text and image will be drawn.
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, savedBoundsbrush, cycleDetected, cycleProtect, modifyDX, modifyDY, modifyHandle, modifying, pen, ptEnd, ptMdfLast, ptOrg, ptSavedEnd, ptSavedOrg, subordinateGroup| Constructor and Description |
|---|
ShapeNode()
Initializes a new instance of the ShapeNode class.
|
ShapeNode(Diagram parent)
Initializes a new ShapeNode instance by setting its properties to the
default values specified in the diagram.
|
ShapeNode(ShapeNode prototype)
Initializes a new ShapeNode instance by copying the attribute values
from the specified prototype node.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancelModify(InteractionState ist)
|
boolean |
containsPoint(java.awt.geom.Point2D point)
ShapeNode.containsPoint override.
|
boolean |
containsPoint(java.awt.geom.Point2D point,
float threshold)
DiagramNode.containsPoint override.
|
protected ConnectionPoint |
createConnectionPoint(DiagramLink link,
java.awt.geom.Point2D point,
boolean incoming) |
protected DiagramItemProperties |
createProperties()
DiagramItem.createProperties() override. |
protected DiagramItemState |
createState()
DiagramItem.createState() override. |
protected void |
drawLocal(java.awt.Graphics2D graphics,
RenderOptions options)
Override in a derived class to provide implementation specific drawing for the node.
|
protected void |
drawShadowLocal(java.awt.Graphics2D graphics,
RenderOptions options)
Override in a derived class to provide implementation specific drawing for the shadow of the node.
|
boolean |
getAllowFlip()
Gets a value indicating whether the node's shape flips when an edge is dragged over its opposite edge.
|
CustomDraw |
getCustomDraw()
Gets a value indicating what type of custom drawing to perform on a node.
|
java.awt.geom.Rectangle2D |
getEditRect(DiagramItem item,
java.awt.geom.Point2D mousePosition)
Implements InplaceEditable.getEditRect.
|
boolean |
getEnableStyledText()
Gets a value indicating whether the text of a node contains formatting
tags which should be processed by JDiagram.
|
boolean |
getFlipX()
Gets a value indicating whether the node's shape is flipped horizontally.
|
boolean |
getFlipY()
Gets a value indicating whether the node's shape is flipped vertically.
|
java.awt.Font |
getFont()
Gets the font used to draw the text label of a node.
|
java.awt.Image |
getImage()
Gets the image displayed inside this node.
|
ImageAlign |
getImageAlign()
Gets the alignment of the node's image.
|
Thickness |
getImagePadding()
Gets the padding distance between node's borders and Image.
|
protected java.awt.geom.Rectangle2D |
getImageRect(boolean inLocal) |
java.lang.String |
getImageUrl()
Gets a URL used to load an image into this cell.
|
java.lang.String |
getPlainText()
Gets the plain text extracted from the formatted text
by removing the formatting tags.
|
protected java.awt.geom.Rectangle2D |
getRepaintRect(boolean includeConnected)
Gets the repaint region for this item, taking into account
factors such as pen, selection handles and shadow.
|
boolean |
getRotateImage()
Gets a value indicating whether the image displayed inside a node
should rotate together with the node.
|
boolean |
getRotateText()
Gets a value indicating whether the text displayed inside a node
should rotate together with the node.
|
Shape |
getShape()
Gets the shape of a node.
|
float |
getShapeOrientation()
Gets an orientation angle applied to the shape definition before
the shape points are mapped to the node's bounding rectangle.
|
java.lang.String |
getText()
Gets the text displayed inside this node.
|
TextFormat |
getTextFormat()
Gets a
TextFormat object specifying how to format and align the text of this node. |
java.lang.String |
getTextToEdit()
Implements InplaceEditable.getTextToEdit.
|
boolean |
getTransparent()
Gets a value indicating whether only the text and image of a node
should be drawn on the screen.
|
ShapeNodeBuilder |
init()
Returns a ShapeNodeBuilder object used to configure this ShapeNode instance.
|
protected void |
loadFromJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
Loads the node from a JSON object.
|
protected void |
loadFromXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
Loads the item content from an XML element.
|
protected void |
onAdd()
DiagramItem.onAdd() override. |
protected void |
onChangeTextPadding() |
protected void |
onLoad(Diagram diagram)
|
protected void |
onRotationAngleChanged(double oldAngle)
|
protected void |
onStyleFontChanged()
Invoked when font property values of an associated style change.
|
protected void |
onUpdateBounds(java.awt.geom.Rectangle2D oldBounds)
Invoked when the bounding rectangle of this node has changed.
|
void |
readExternal(java.io.ObjectInput in)
Implements Externalizable.
|
void |
renderText(java.lang.String text,
java.awt.geom.Rectangle2D dest,
DrawTextHint hint) |
void |
resizeToFitImage()
Resizes a node so that it will be as big as the image displayed in the node.
|
boolean |
resizeToFitText(FitSize fit)
Makes a node big enough to display its text without clipping.
|
protected void |
restoreProperties(DiagramItemProperties props)
|
protected void |
restoreState(DiagramItemState state)
|
protected void |
saveProperties(DiagramItemProperties props)
|
protected void |
saveState(DiagramItemState state)
|
protected void |
saveToJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
Saves the node as a JSON object.
|
protected void |
saveToXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
Saves the item content into an XML element.
|
void |
setAllowFlip(boolean value)
Sets a value indicating whether the node's shape flips when an edge is dragged over its opposite edge.
|
void |
setCustomDraw(CustomDraw value)
Sets a value indicating what type of custom drawing to perform on a node.
|
void |
setEditedText(java.lang.String newText)
Implements InplaceEditable.setEditedText.
|
void |
setEnableStyledText(boolean value)
Sets a value indicating whether the text of a node contains formatting
tags which should be processed by JDiagram.
|
void |
setFlipX(boolean value)
Sets a value indicating whether the node's shape is flipped horizontally.
|
void |
setFlipY(boolean value)
Sets a value indicating whether the node's shape is flipped vertically.
|
void |
setFont(java.awt.Font value)
Sets the font used to draw the text label of a node.
|
void |
setImage(java.awt.Image value)
Sets the image that should be displayed inside the node.
|
void |
setImageAlign(ImageAlign value)
Sets the alignment of the node's image.
|
void |
setImagePadding(Thickness value)
Sets the padding distance between node's borders and Image.
|
void |
setImageUrl(java.lang.String value)
Sets a URL used to load an image into this cell.
|
void |
setRotateImage(boolean value)
Sets a value indicating whether the image displayed inside a node
should rotate together with the node.
|
void |
setRotateText(boolean value)
Sets a value indicating whether the text displayed inside a node
should rotate together with the node.
|
void |
setShape(Shape value)
Sets the shape of a node to the specified
Shape instance. |
void |
setShapeOrientation(float value)
Sets an orientation angle applied to the shape definition before
the shape points are mapped to the node's bounding rectangle.
|
void |
setText(java.lang.String value)
Sets the text label displayed inside this node.
|
void |
setTextFormat(TextFormat value)
Sets a
TextFormat object specifying how to format and align the text of this node. |
void |
setTransparent(boolean value)
Sets a value indicating whether only the text and image of a node
should be drawn on the screen.
|
protected void |
updateModify(java.awt.geom.Point2D current,
InteractionState ist)
|
static ShapeNodeBuilder |
with()
Returns a ShapeNodeBuilder object used to configure and create new ShapeNode instances.
|
void |
writeExternal(java.io.ObjectOutput out)
Implements Externalizable.
|
addLabel, addLabel, allowCreate, allowModify, allowModifyImpl, attachTo, attachTo, attachTo, completeCreate, completeModify, constraintsInfringed, detach, draw, drawShadow, getAllIncomingLinks, getAllLinks, getAllOutgoingLinks, getAllowIncomingLinks, getAllowOutgoingLinks, getAnchorPattern, getBounds, getCenter, getConstraints, getContainer, getEffects, getEnabledHandles, getExpandable, getExpanded, getHandlesStyle, getIncomingLinks, getLabels, getLocalBounds, getLocalBoundsD, getLocalCenter, getMasterGroup, getMasterItem, getNearestBorderPoint, getObstacle, getOutgoingLinks, getRotatedBounds, getRotationAngle, groupContains, hitTestHandle, labelFromPoint, move, moveTo, nodesIntersect, onDragOut, onDragOver, onDropOver, onModify, onRemove, parentConstraintsInfringed, putExpandable, rectFromPoints, removeLabel, resize, resizeToFitImage, scaleElements, setAllowIncomingLinks, setAllowOutgoingLinks, setAnchorPattern, setBounds, setBounds, setBounds, setBoundsDirect, setConstraints, setEnabledHandles, setExpandable, setExpanded, setExpandedFlag, setHandlesStyle, setObstacle, setReflexive, setRotationAngle, shouldRenderAnchors, startCreate, startModify, updateCreate, updateLinkPositionsas, clone, getBrush, getEffectiveBrush, getEffectiveFont, getEffectivePen, getEffectiveShadowBrush, getEffectiveTextBrush, getHyperLink, getId, getIgnoreLayout, getLayerIndex, getLayoutTraits, getLocked, getMeasureUnit, getOpacity, getParent, getPen, getPrintable, getRuntimeIndex, getSelected, getShadowBrush, getShadowOffsetX, getShadowOffsetY, getStyle, getSubordinateGroup, getTag, getTextBrush, getTextPadding, getToolTip, getValue, getVisible, getWeight, getZIndex, hasSubordinates, hitTest, onChangeFont, onChildModified, onClick, onDoubleClick, onMeasureUnitChanged, onStyleChanged, putSelected, query, repaint, repaint, repaint, setBrush, setDiagramDirty, setHyperLink, setId, setIgnoreLayout, setLayerIndex, setLocked, setOpacity, setPen, setPrintable, setSelected, setShadowBrush, setShadowOffsetX, setShadowOffsetY, setStyle, setTag, setTextBrush, setTextPadding, setToolTip, setVisible, setWeight, setZIndex, shouldRender, zBottom, zLevelDown, zLevelUp, zToppublic ShapeNode()
public ShapeNode(Diagram parent)
parent - A Diagram instance whose default node
attributes are copied to this node.public static ShapeNodeBuilder with()
ShapeNodeBuilder instance.public ShapeNodeBuilder init()
ShapeNodeBuilder instance.protected java.awt.geom.Rectangle2D getRepaintRect(boolean includeConnected)
DiagramItemgetRepaintRect in class DiagramNodeincludeConnected - true if related items should be considered too; otherwise, false.protected void onUpdateBounds(java.awt.geom.Rectangle2D oldBounds)
DiagramNodeonUpdateBounds in class DiagramNodeprotected void drawLocal(java.awt.Graphics2D graphics,
RenderOptions options)
DiagramNodedrawLocal in class DiagramNodegraphics - The Graphics2D surface to draw the node on.options - Provides options for the drawing operation.protected void drawShadowLocal(java.awt.Graphics2D graphics,
RenderOptions options)
DiagramNodedrawShadowLocal in class DiagramNodegraphics - The Graphics2D object where the shadow should be rendered.options - Provides options for the drawing operation.public void renderText(java.lang.String text,
java.awt.geom.Rectangle2D dest,
DrawTextHint hint)
renderText in interface RenderTextCallbackpublic boolean containsPoint(java.awt.geom.Point2D point,
float threshold)
containsPoint in class DiagramNodepoint - The point to check.threshold - Specifies the size of the area around the node outlines where the point is still considered inside.public boolean containsPoint(java.awt.geom.Point2D point)
containsPoint in class DiagramNodepoint - The point to check.public java.awt.Image getImage()
java.awt.Image object.public void setImage(java.awt.Image value)
value - A java.awt.Image object.public ImageAlign getImageAlign()
ImageAlign enumeration.public void setImageAlign(ImageAlign value)
value - A member of the ImageAlign enumeration.public java.lang.String getImageUrl()
String containing the URL.public void setImageUrl(java.lang.String value)
value - A String containing the URLpublic Thickness getImagePadding()
public void setImagePadding(Thickness value)
value - A Thickness value specifying padding distance.protected java.awt.geom.Rectangle2D getImageRect(boolean inLocal)
public java.lang.String getText()
String containing the label text.public void setText(java.lang.String value)
value - A String containing the label text.public java.lang.String getPlainText()
String containing the label text stripped from
formatting tags.public TextFormat getTextFormat()
TextFormat object specifying how to format and align the text of this node.TextFormat object specifying the text format and alignment.public void setTextFormat(TextFormat value)
TextFormat object specifying how to format and align the text of this node.value - A TextFormat object specifying the text format and alignment.public boolean getTransparent()
true to display only the node text and image,
otherwise false.public void setTransparent(boolean value)
value - true to display only the node text and image,
otherwise false.public void resizeToFitImage()
public CustomDraw getCustomDraw()
CustomDraw enumeration.public void setCustomDraw(CustomDraw value)
value - A member of the CustomDraw enumeration.public boolean resizeToFitText(FitSize fit)
fit - A member of the FitSize enumeration specifying
whether the width or height of the node should remain unchanged.true if the node is resized successfully; otherwise false.public Shape getShape()
Shape object representing the node's shape.public void setShape(Shape value)
Shape instance. The
initial shape of a node is the one set via the
Diagram.setDefaultShape(com.mindfusion.diagramming.Shape) method.value - A Shape object representing the node's shape.public float getShapeOrientation()
public void setShapeOrientation(float value)
value - A float value specifying the shape definition orientation.public boolean getAllowFlip()
public void setAllowFlip(boolean value)
value - true to let users flip the shape, or false otherwise. The default value is false.public boolean getFlipX()
public void setFlipX(boolean value)
value - true if the shape is flipped horizontally, or false otherwise.public boolean getFlipY()
public void setFlipY(boolean value)
value - true if the shape is flipped vertically, or false otherwise.protected void onRotationAngleChanged(double oldAngle)
onRotationAngleChanged in class DiagramNodepublic boolean getRotateImage()
true if the node image rotates when
the node is rotated, otherwise false.public void setRotateImage(boolean value)
value - true to rotate the node image when
the node is rotated, otherwise false.public boolean getRotateText()
true if the node text rotates when
the node is rotated, otherwise false.public void setRotateText(boolean value)
value - true to rotate the node text when
the node is rotated, otherwise false.protected ConnectionPoint createConnectionPoint(DiagramLink link, java.awt.geom.Point2D point, boolean incoming)
createConnectionPoint in class DiagramNodepublic java.lang.String getTextToEdit()
getTextToEdit in interface InplaceEditablepublic void setEditedText(java.lang.String newText)
setEditedText in interface InplaceEditablenewText - The new text of this node.public java.awt.geom.Rectangle2D getEditRect(DiagramItem item, java.awt.geom.Point2D mousePosition)
getEditRect in interface InplaceEditableitem - A reference to this node.mousePosition - A Point2D instance specifying the current pointer position.public java.awt.Font getFont()
getFont in class DiagramItemjava.awt.Font object representing the label font.public void setFont(java.awt.Font value)
setFont in class DiagramItemvalue - A java.awt.Font object representing the label font.protected DiagramItemProperties createProperties()
DiagramItem.createProperties() override.createProperties in class DiagramNodeprotected void saveProperties(DiagramItemProperties props)
saveProperties in class DiagramNodeprops - A DiagramItemProperties-derived object where
the item's properties should be saved.protected void restoreProperties(DiagramItemProperties props)
restoreProperties in class DiagramNodeprops - A DiagramItemProperties -derived object containing a
snapshot of the item's properties.protected DiagramItemState createState()
DiagramNodeDiagramItem.createState() override.createState in class DiagramNodeprotected void saveState(DiagramItemState state)
DiagramNodesaveState in class DiagramNodeprotected void restoreState(DiagramItemState state)
DiagramNoderestoreState in class DiagramNodeprotected void updateModify(java.awt.geom.Point2D current,
InteractionState ist)
DiagramNodeDiagramItem.updateModify(java.awt.geom.Point2D, com.mindfusion.diagramming.InteractionState) override. Invoked during interactive modification of this node.updateModify in class DiagramNodecurrent - The current position of the mouse pointer.ist - An InteractionState object containing more information about the current state of the operation.protected void cancelModify(InteractionState ist)
DiagramNodeDiagramItem.cancelModify(com.mindfusion.diagramming.InteractionState) override. Invoked when the interactive modification of this node has been canceled.cancelModify in class DiagramNodeist - An InteractionState object containing more information about the current state of the operation.protected void onChangeTextPadding()
onChangeTextPadding in class DiagramItemprotected void onStyleFontChanged()
DiagramItemonStyleFontChanged in class DiagramItempublic boolean getEnableStyledText()
true if JDiagram should process formatting tags
when rendering the node label, otherwise false.public void setEnableStyledText(boolean value)
value - true if JDiagram should process formatting tags
when rendering the node label, otherwise false.public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.ExternalizablewriteExternal in class DiagramNodejava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.ExternalizablereadExternal in class DiagramNodejava.io.IOExceptionjava.lang.ClassNotFoundExceptionprotected void onAdd()
DiagramItem.onAdd() override.onAdd in class DiagramItemprotected void onLoad(Diagram diagram)
onLoad in class DiagramItemprotected void saveToXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
DiagramItemsaveToXml in class DiagramNodexmlElement - An Element the item's data should be stored into.context - An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.protected void loadFromXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
throws javax.xml.transform.TransformerException,
com.mindfusion.common.XmlException
DiagramItemloadFromXml in class DiagramNodexmlElement - An XmlElement containing the item's data.context - An XmlPersistContext object providing contextual
information about the serialization process and some helper serialization methodsjavax.xml.transform.TransformerExceptioncom.mindfusion.common.XmlExceptionprotected void saveToJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
saveToJson in class DiagramNodeobj - A JsonObject instance to contain the serialized data.context - A JsonPersistContext object providing contextual information
about the serialization process and helper serialization methods.protected void loadFromJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
loadFromJson in class DiagramNodeobj - A JsonObject containing the node's data.context - A JsonPersistContext object providing contextual information about
the serialization process and helper serialization methods.