com.mindfusion.diagramming
Class DiagramLink

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

public class DiagramLink
extends DiagramItem
implements InplaceEditable, Routable

Links between nodes in JDiagram diagrams are represented by instances of the DiagramLink class. Links connect at most two nodes, which can be accessed via the getOrigin() and getDestination() methods. If linked to node anchor points, the point indices can be accessed using the getOriginAnchor() and getDestinationAnchor() methods. To control whether users are allowed to move link end points, call one or both of the setAllowMoveStart(boolean) and setAllowMoveEnd(boolean).

Links are built of smaller parts, called segments, which can be straight lines, cascading orthogonal lines or Bezier curves. The type of segments can be set through the setShape(int) method. The number of links segments is specified via the setSegmentCount(int) method. Access to the control point locations is provided via the getControlPoints() method.

Usually only the start and end segments of a link are updated if the nodes it connects are moved around. Number, orientation and/or position of link segments can change dynamically in various ways depending on the values set through setAutoRoute(boolean), setDynamic(boolean) and setRetainForm(boolean). The setCascadeOrientation(int) method lets you specify the orientation of the first segment of a link of style Cascading.

If setSnapToNodeBorder(boolean) is enabled, a link automatically aligns its end points to the border of the origin or destination nodes when a user moves the first or last control points. This has a higher priority than aligning to the grid, but a lower priority than aligning to an anchor point.

Links can display distinct arrowhead shapes at their ends. These shapes can be set via the setHeadShape(java.lang.String) and setBaseShape(java.lang.String) methods. The size of the arrowhead and base images can be specified respectively via the setHeadShapeSize(float) and setBaseShapeSize(float) methods. Arrowhead shapes can be displayed in the middle of each segment to facilitate users by distinguishing different links. The type and size of these shapes is set via the setIntermediateShape(java.lang.String) and setIntermediateShapeSize(float) methods. The outlines of arrowhead shapes are painted with the pen specified via setHeadPen(com.mindfusion.diagramming.Pen).

Links can have some text associated with them, displayed as specified via the setText(java.lang.String), DiagramItem.setTextBrush(com.mindfusion.diagramming.Brush) and setTextStyle(int) methods.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.mindfusion.diagramming.DiagramItem
brush, cycleDetected, cycleProtect, modifyDX, modifyDY, modifyHandle, modifying, pen, ptEnd, ptMdfLast, ptOrg, ptSavedEnd, ptSavedOrg, subordinateGroup
 
Constructor Summary
DiagramLink()
          Used internally to implement serialization functionality.
DiagramLink(Diagram parent)
          Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram.
DiagramLink(Diagram parent, DiagramNode src, DiagramNode dest)
          Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified nodes as link's origin and destination.
DiagramLink(Diagram parent, DiagramNode src, java.awt.geom.Point2D dest)
          Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified nodes as link's origin and destination.
DiagramLink(DiagramLink prototype, DiagramNode src, DiagramNode dest)
          Initializes a new instance of the DiagramLink class by copying its properties from another link, and setting the specified nodes as link's origin and destination.
DiagramLink(Diagram parent, java.awt.geom.Point2D src, DiagramNode dest)
          Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified nodes as link's origin and destination.
DiagramLink(Diagram parent, java.awt.geom.Point2D src, java.awt.geom.Point2D dest)
          Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified points as link's origin and destination.
 
Method Summary
 void addLabel(LinkLabel label)
          Adds a new label to this link.
 LinkLabel addLabel(java.lang.String text)
          Adds a new label to this link.
protected  boolean allowCreate(java.awt.geom.Point2D current, InteractionState ist)
          Invoked during interactive creation of items to test whether the operation can be completed in the current context.
protected  boolean allowModify(java.awt.geom.Point2D current, InteractionState ist)
          Invoked during interactive modification of items to test whether the operation can be completed in the current context.
 void applyRoute(java.util.ArrayList<java.awt.Point> routePoints, RouteDescriptor routeDescriptor, PointList resultPoints)
           
protected  void cancelModify(InteractionState ist)
          Invoked when the interactive modification of this object has been canceled.
 DiagramItem clone(boolean clipboard)
          Creates a copy of this link.
protected  void completeCreate(java.awt.geom.Point2D end)
          Invoked when the item creation has been completed.
protected  void completeModify(java.awt.geom.Point2D end, InteractionState ist)
          Invoked when the item modification has been completed.
 boolean containsPoint(java.awt.geom.Point2D point)
          DiagramItem.containsPoint override.
protected  DiagramItemProperties createProperties()
          DiagramItem.createProperties() override.
 RouteDescriptor createRouteDescriptor()
           
protected  DiagramItemState createState()
          DiagramItem.createState() override.
protected  void draw(java.awt.Graphics2D graphics, RenderOptions options)
           
 void drawArrowhead(java.awt.Graphics2D graphics, Pen pen, Brush b, Shape shape, java.awt.geom.Point2D pivot, java.awt.geom.Point2D position, java.awt.geom.Point2D segmentStart, double size, boolean shadow)
          Draws an arrowhead shape.
protected  void drawShadow(java.awt.Graphics2D graphics, RenderOptions options)
           
 boolean getAllowMoveEnd()
          Gets a value indicating whether users are allowed to move the last control point of a link.
 boolean getAllowMoveStart()
          Gets a value indicating whether users are allowed to move the first control point of a link.
 boolean getAutoRoute()
          Gets a value indicating whether a link should automatically find its way between nodes so that it will not cross other nodes.
 Shape getBaseShape()
          Gets the shape that is displayed at the origin of a link.
 float getBaseShapeSize()
          Gets the size of the shape displayed at the origin of a link.
 java.awt.geom.Rectangle2D.Float getBounds()
          Gets the smallest rectangle that bounds all points of a link.
 int getCascadeOrientation()
          Gets the orientation of the first segment of a cascading link.
 PointList getControlPoints()
          Gets the list of control points of a link.
 int getCustomDraw()
          Gets the type of custom drawing performed on this link.
 DiagramNode getDestination()
          Gets the destination node of a link.
 int getDestinationAnchor()
          Gets the index of the anchor point to which a link is connected at its destination.
 int getDestinationIndex()
          Gets the index of the row of a table or the anchor point of a box to which a link is connected.
 boolean getDynamic()
          Gets whether a link should automatically update the position of its end points while a node related to the link is moved, so that the link end segments always point to the center of the link's nodes.
 java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
           
 Pen getEffectiveHeadPen()
          Creates a Pen object representing the currently effective head pen of the link.
 int getHandlesStyle()
          Gets the style of the link selection handles.
 Pen getHeadPen()
          Gets the pen used to draw the arrowhead shapes outlines.
 Shape getHeadShape()
          Gets the shape of the arrowhead.
 float getHeadShapeSize()
          Gets the size of the arrowhead shape.
 Shape getIntermediateShape()
          Gets the shape that is displayed at the middle of each segment of a link.
 float getIntermediateShapeSize()
          Gets the size of the shape displayed at the middle of each segment of a link.
 java.util.ArrayList<LinkLabel> getLabels()
          Returns the list of all labels displayed by this link.
 float getLength()
          Gets the length of this link.
 int getLongestHSegment()
          Returns the index of the longest non-vertical segment of the link.
 DiagramNode getOrigin()
          Gets the origin node of a link.
 int getOriginAnchor()
          Gets the index of the anchor point to which a link is connected at its origin.
 int getOriginIndex()
          Gets the index of the row of a table or the anchor point of a box to which a link is connected.
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 getRetainForm()
          Gets a value indicating whether a link should preserve its original shape while the nodes related to that link are moved around.
 short getSegmentCount()
          Gets the number of segments of this link.
 int getShape()
          Gets the shape of a link.
 boolean getSnapToNodeBorder()
          Gets a value indicating whether the end points of a link are automatically aligned to node borders while a user modifies the link.
 java.lang.String getText()
          Gets the text of the link's label.
 int getTextStyle()
          Gets the alignment of the link's label.
 java.lang.String getTextToEdit()
           
 boolean intersects(DiagramNode node)
          Determines whether a link intersects the specified node.
 boolean isConnected()
          Gets a value indicating whether a link is connected to any nodes.
 LinkLabel labelFromPoint(java.awt.geom.Point2D point)
          Returns the label whose layout rectangle contains the specified point.
protected  void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
          Loads the item content from an XML element.
protected  void onChangeFont()
           
protected  void onLoad(Diagram diagram)
          DiagramItem.onLoad(com.mindfusion.diagramming.Diagram) override.
 void readExternal(java.io.ObjectInput in)
          Implements Externalizable.
 void reassignAnchorPoints()
          Chooses new anchor points for a link.
 void removeLabel(LinkLabel label)
          Removes the specified label from this link.
protected  void restoreProperties(DiagramItemProperties props)
          DiagramItem.restoreProperties(com.mindfusion.diagramming.DiagramItemProperties) override.
protected  void restoreState(DiagramItemState state)
          DiagramItem.restoreState(com.mindfusion.diagramming.DiagramItemState) override.
 boolean route()
          Sets the link control points so that a link goes between its related nodes without crossing other nodes.
protected  void saveProperties(DiagramItemProperties props)
          DiagramItem.saveProperties(com.mindfusion.diagramming.DiagramItemProperties) override.
protected  void saveState(DiagramItemState state)
          DiagramItem.saveState(com.mindfusion.diagramming.DiagramItemState) override.
protected  void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
          Saves the item content into an XML element.
 void setAllowMoveEnd(boolean value)
          Sets a value indicating whether users are allowed to move the last control point of a link.
 void setAllowMoveStart(boolean value)
          Sets a value indicating whether users are allowed to move the first control point of a link.
 void setAutoRoute(boolean value)
          Sets a value indicating whether a link should automatically find its way between nodes so that it will not cross other nodes.
 void setBaseShape(Shape value)
          Sets the shape that is displayed at the origin of a link.
 void setBaseShape(java.lang.String shapeId)
          Sets the shape that is displayed at the origin of a link.
 void setBaseShapeSize(float value)
          Sets the size of the shape displayed at the origin of a link.
 void setCascadeOrientation(int value)
          Sets the orientation of the first segment of a cascading link.
 void setCustomDraw(int value)
          Gets the type of custom drawing performed on this link.
 void setDestination(DiagramNode value)
          Sets the destination node of a link.
 void setDestinationAnchor(int value)
          sets the anchor point to which a link is connected at its destination.
 void setDestinationIndex(int value)
          Sets the row of a table or the anchor point of a box to which a link is connected.
 void setDynamic(boolean value)
          Sets whether a link should automatically update the position of its end points while a node related to the link is moved, so that the link end segments always point to the center of the link's nodes.
 void setEditedText(java.lang.String newText)
           
 void setHandlesStyle(int value)
          Sets the style of the link selection handles.
 void setHeadPen(Pen value)
          Sets the pen used to draw the arrowhead shapes outlines.
 void setHeadShape(Shape value)
          Sets the shape of the arrowhead.
 void setHeadShape(java.lang.String shapeId)
          Sets the shape of the arrowhead.
 void setHeadShapeSize(float value)
          Sets the size of the arrowhead shape.
 void setIntermediateShape(Shape value)
          Sets the shape that is displayed at the middle of each segment of a link.
 void setIntermediateShape(java.lang.String shapeId)
          Sets the shape that is displayed at the middle of each segment of a link.
 void setIntermediateShapeSize(float value)
          Sets the size of the shape displayed at the middle of each segment of a link.
 void setOrigin(DiagramNode value)
          Sets the origin node of a link.
 void setOriginAnchor(int value)
          Sets the anchor point to which a link is connected at its origin.
 void setOriginIndex(int value)
          Sets the row of a table or the anchor point of a box to which a link is connected.
 void setRetainForm(boolean value)
          Sets a value indicating whether a link should preserve its original shape while the nodes related to that link are moved around.
 void setSegmentCount(int value)
          Sets the number of segments of this link.
 void setShape(int value)
          Sets the shape of a link.
 void setSnapToNodeBorder(boolean value)
          Sets a value indicating whether the end points of a link should be automatically aligned to node borders while a user modifies the link.
 void setText(java.lang.String value)
          Sets the text of the link's label.
 void setTextStyle(int value)
          Sets the alignment of the link's label.
 void setVisible(boolean value)
          Specifies whether the link should be drawn on the screen.
protected  void startCreate(java.awt.geom.Point2D org)
          Invoked once when the user starts creating a new item interactively.
protected  void startModify(java.awt.geom.Point2D org, int handle, InteractionState ist)
          Invoked when the user starts modifying this item interactively.
protected  void updateCreate(java.awt.geom.Point2D current)
          Invoked during interactive creation of this item.
 void updateFromPoints()
          Updates a link after its control point positions are changed programmatically.
 void updateFromPoints(boolean updateGroups)
          Updates a link after its control point positions are changed programmatically.
 void updateFromPoints(boolean updateGroups, boolean updateSegmentCount)
          Updates the link's internal state after the link's control points have been changed.
protected  void updateModify(java.awt.geom.Point2D current, InteractionState ist)
          Invoked during interactive modification of this item.
 void writeExternal(java.io.ObjectOutput out)
          Implements Externalizable.
 
Methods inherited from class com.mindfusion.diagramming.DiagramItem
getBrush, getEffectiveBrush, getEffectiveFont, getEffectivePen, getEffectiveShadowBrush, getEffectiveTextBrush, getFont, getHyperLink, getId, getIgnoreLayout, getLayerIndex, getLayoutTraits, getLocked, getMasterGroup, getMeasureUnit, getParent, getPen, getPrintable, getRuntimeIndex, getSelected, getShadowBrush, getShadowOffsetX, getShadowOffsetY, getStyle, getSubordinateGroup, getTag, getTextBrush, getTextPadding, getToolTip, getValue, getVisible, getWeight, getZIndex, hasSubordinates, onAdd, onChangeTextPadding, onChildModified, onClick, onDoubleClick, onModify, onRemove, 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

DiagramLink

public DiagramLink(Diagram parent)
Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram.

Parameters:
parent - A Diagram instance whose default link attributes are copied to this link.

DiagramLink

public DiagramLink(Diagram parent,
                   DiagramNode src,
                   DiagramNode dest)
Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified nodes as link's origin and destination.

Parameters:
parent - A Diagram instance whose default link attributes are copied to this link.
src - A DiagramNode -derived object representing the link origin node.
dest - A DiagramNode -derived object representing the link destination node.

DiagramLink

public DiagramLink(Diagram parent,
                   DiagramNode src,
                   java.awt.geom.Point2D dest)
Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified nodes as link's origin and destination.

Parameters:
parent - A Diagram instance whose default link attributes are copied to this link.
src - A DiagramNode -derived object representing the link origin node.
dest - A Point2D.Float object representing the link destination point.

DiagramLink

public DiagramLink(Diagram parent,
                   java.awt.geom.Point2D src,
                   DiagramNode dest)
Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified nodes as link's origin and destination.

Parameters:
parent - A Diagram instance whose default link attributes are copied to this link.
src - A Point2D.Float object representing the link origin point.
dest - A DiagramNode -derived object representing the link destination node.

DiagramLink

public DiagramLink(Diagram parent,
                   java.awt.geom.Point2D src,
                   java.awt.geom.Point2D dest)
Initializes a new instance of the DiagramLink class by setting its properties to the default values defined in the specified diagram, and setting the specified points as link's origin and destination.

Parameters:
parent - A Diagram instance whose default link attributes are copied to this link.
src - A Point2D.Float object representing the link origin point.
dest - A Point2D.Float object representing the link destination point.

DiagramLink

public DiagramLink(DiagramLink prototype,
                   DiagramNode src,
                   DiagramNode dest)
Initializes a new instance of the DiagramLink class by copying its properties from another link, and setting the specified nodes as link's origin and destination.

Parameters:
prototype - An DiagramLink instance whose attributes are copied to this link.
src - A DiagramNode -derived object representing the link origin node.
dest - A DiagramNode -derived object representing the link destination node.

DiagramLink

public DiagramLink()
Used internally to implement serialization functionality.

Method Detail

clone

public DiagramItem clone(boolean clipboard)
Creates a copy of this link.

Overrides:
clone in class DiagramItem

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 DiagramItem
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 DiagramItem
Throws:
java.io.IOException
java.lang.ClassNotFoundException

onLoad

protected void onLoad(Diagram diagram)
DiagramItem.onLoad(com.mindfusion.diagramming.Diagram) override.

Overrides:
onLoad in class DiagramItem

saveToXml

protected void saveToXml(org.w3c.dom.Element xmlElement,
                         XmlPersistContext context)
Description copied from class: DiagramItem
Saves the item content into an XML element.

Overrides:
saveToXml in class DiagramItem
Parameters:
xmlElement - 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.

loadFromXml

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

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

startCreate

protected void startCreate(java.awt.geom.Point2D org)
Description copied from class: DiagramItem
Invoked once when the user starts creating a new item interactively.

Overrides:
startCreate in class DiagramItem
Parameters:
org - Position of the mouse pointer.

updateCreate

protected void updateCreate(java.awt.geom.Point2D current)
Description copied from class: DiagramItem
Invoked during interactive creation of this item.

Overrides:
updateCreate in class DiagramItem
Parameters:
current - Position of the mouse pointer.

completeCreate

protected void completeCreate(java.awt.geom.Point2D end)
Description copied from class: DiagramItem
Invoked when the item creation has been completed.

Overrides:
completeCreate in class DiagramItem
Parameters:
end - The mouse pointer position.

allowCreate

protected boolean allowCreate(java.awt.geom.Point2D current,
                              InteractionState ist)
Description copied from class: DiagramItem
Invoked during interactive creation of items to test whether the operation can be completed in the current context.

Specified by:
allowCreate in class DiagramItem
Parameters:
current - The current mouse pointer position.
ist - An InteractionState object containing more information about the current state of the operation.
Returns:
true to allow the creation of this item; otherwise, false.

allowModify

protected boolean allowModify(java.awt.geom.Point2D current,
                              InteractionState ist)
Description copied from class: DiagramItem
Invoked during interactive modification of items to test whether the operation can be completed in the current context.

Specified by:
allowModify in class DiagramItem
Parameters:
current - The current mouse pointer position.
ist - An InteractionState object containing more information about the current state of the operation.
Returns:
true to allow the modification of this item; otherwise, false.

startModify

protected void startModify(java.awt.geom.Point2D org,
                           int handle,
                           InteractionState ist)
Description copied from class: DiagramItem
Invoked when the user starts modifying this item interactively.

Overrides:
startModify in class DiagramItem
Parameters:
org - Position of the mouse pointer.
handle - Index of the adjustment handle used to modify the item.
ist - An InteractionState object containing more information about the current state of the operation.

updateModify

protected void updateModify(java.awt.geom.Point2D current,
                            InteractionState ist)
Description copied from class: DiagramItem
Invoked during interactive modification of this item.

Overrides:
updateModify in class DiagramItem
Parameters:
current - Position of the mouse pointer.
ist - An InteractionState object containing more information about the current state of the operation.

completeModify

protected void completeModify(java.awt.geom.Point2D end,
                              InteractionState ist)
Description copied from class: DiagramItem
Invoked when the item modification has been completed.

Overrides:
completeModify in class DiagramItem
Parameters:
end - The mouse pointer position.
ist - An InteractionState object containing more information about the current state of the operation.

cancelModify

protected void cancelModify(InteractionState ist)
Description copied from class: DiagramItem
Invoked when the interactive modification of this object has been canceled.

Overrides:
cancelModify in class DiagramItem
Parameters:
ist - An InteractionState object containing more information about the current state of the operation.

draw

protected void draw(java.awt.Graphics2D graphics,
                    RenderOptions options)
Specified by:
draw in class DiagramItem

drawShadow

protected void drawShadow(java.awt.Graphics2D graphics,
                          RenderOptions options)
Specified by:
drawShadow in class DiagramItem

drawArrowhead

public void drawArrowhead(java.awt.Graphics2D graphics,
                          Pen pen,
                          Brush b,
                          Shape shape,
                          java.awt.geom.Point2D pivot,
                          java.awt.geom.Point2D position,
                          java.awt.geom.Point2D segmentStart,
                          double size,
                          boolean shadow)
Draws an arrowhead shape.

Parameters:
graphics - The DrawingContext surface to draw the shape on.
pen - A Pen instance used to draw the shape outline.
b - A Brush instance used to fill the shape.
shape - A Shape instance that defines the arrowhead geometry.
pivot - A Point specified in percents that corresponds to the arrowhead tip position within the Shape geometry.
position - A point on the drawing surface where the arrowhead tip should be located.
segmentStart - A point specifying the arrowhead direction.
size - A double value that specifies the arrowhead size.

setVisible

public void setVisible(boolean value)
Specifies whether the link should be drawn on the screen.

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

isConnected

public boolean isConnected()
Gets a value indicating whether a link is connected to any nodes.

Returns:
true if the link is connected to any node, false otherwise.

getOrigin

public DiagramNode getOrigin()
Gets the origin node of a link.

Returns:
The origin DiagramNode.

setOrigin

public void setOrigin(DiagramNode value)
Sets the origin node of a link.

Parameters:
value - A DiagramNode object representing the link origin.

getDestination

public DiagramNode getDestination()
Gets the destination node of a link.

Returns:
The destination DiagramNode.

setDestination

public void setDestination(DiagramNode value)
Sets the destination node of a link.

Parameters:
value - A DiagramNode object representing the link destination.

getOriginIndex

public int getOriginIndex()
Gets the index of the row of a table or the anchor point of a box to which a link is connected.

Returns:
An integer value specifying the row or anchor point index.

setOriginIndex

public void setOriginIndex(int value)
Sets the row of a table or the anchor point of a box to which a link is connected.

Parameters:
value - An integer value specifying the index of the origin anchor point.

getDestinationIndex

public int getDestinationIndex()
Gets the index of the row of a table or the anchor point of a box to which a link is connected.

Returns:
An integer value specifying the row or anchor point index.

setDestinationIndex

public void setDestinationIndex(int value)
Sets the row of a table or the anchor point of a box to which a link is connected.

Parameters:
value - An integer value specifying the index of the destination anchor point.

getOriginAnchor

public int getOriginAnchor()
Gets the index of the anchor point to which a link is connected at its origin.

Returns:
An integer value specifying the anchor point index.

setOriginAnchor

public void setOriginAnchor(int value)
Sets the anchor point to which a link is connected at its origin.

Parameters:
value - An integer value specifying the index of the origin anchor point.

getDestinationAnchor

public int getDestinationAnchor()
Gets the index of the anchor point to which a link is connected at its destination.

Returns:
An integer value specifying the anchor point index.

setDestinationAnchor

public void setDestinationAnchor(int value)
sets the anchor point to which a link is connected at its destination.

Parameters:
value - An integer value specifying the index of the destination anchor point.

getSegmentCount

public short getSegmentCount()
Gets the number of segments of this link.

Returns:
A short value specifying the number of segments in the link.

setSegmentCount

public void setSegmentCount(int value)
Sets the number of segments of this link.

Parameters:
value - An integer value specifying the number of segments in the link.

getControlPoints

public PointList getControlPoints()
Gets the list of control points of a link.

Returns:
A PointList containing the link's control points.

updateFromPoints

public void updateFromPoints()
Updates a link after its control point positions are changed programmatically.


updateFromPoints

public void updateFromPoints(boolean updateGroups)
Updates a link after its control point positions are changed programmatically.


updateFromPoints

public void updateFromPoints(boolean updateGroups,
                             boolean updateSegmentCount)
                      throws java.lang.Exception
Updates the link's internal state after the link's control points have been changed.

Parameters:
updateGroups - true to update the positions of nodes attached to the link; otherwise, false.
updateSegmentCount - true to update the SegmentCount property based on the number of points in the collection.
Throws:
java.lang.Exception

getDynamic

public boolean getDynamic()
Gets whether a link should automatically update the position of its end points while a node related to the link is moved, so that the link end segments always point to the center of the link's nodes.

Returns:
true if the link updates its end points automatically, otherwise false.

setDynamic

public void setDynamic(boolean value)
Sets whether a link should automatically update the position of its end points while a node related to the link is moved, so that the link end segments always point to the center of the link's nodes.

Parameters:
value - true if the link should update its end points positions automatically, otherwise false.

getRetainForm

public boolean getRetainForm()
Gets a value indicating whether a link should preserve its original shape while the nodes related to that link are moved around.

Returns:
true if the link should preserve its shape, otherwise false.

setRetainForm

public void setRetainForm(boolean value)
Sets a value indicating whether a link should preserve its original shape while the nodes related to that link are moved around.

Parameters:
value - true if the link should preserve its shape, otherwise false.

getCascadeOrientation

public int getCascadeOrientation()
Gets the orientation of the first segment of a cascading link.

Returns:
One of the Orientation constants.

setCascadeOrientation

public void setCascadeOrientation(int value)
Sets the orientation of the first segment of a cascading link.

Parameters:
value - One of the Orientation constants.

getAllowMoveStart

public boolean getAllowMoveStart()
Gets a value indicating whether users are allowed to move the first control point of a link.

Returns:
true if the first control point can be moved, otherwise false.

setAllowMoveStart

public void setAllowMoveStart(boolean value)
Sets a value indicating whether users are allowed to move the first control point of a link.

Parameters:
value - true if the first control point can be moved, otherwise false.

getAllowMoveEnd

public boolean getAllowMoveEnd()
Gets a value indicating whether users are allowed to move the last control point of a link.

Returns:
true if the last control point can be moved, otherwise false.

setAllowMoveEnd

public void setAllowMoveEnd(boolean value)
Sets a value indicating whether users are allowed to move the last control point of a link.

Parameters:
value - true if the last control point can be moved, otherwise false.

getShape

public int getShape()
Gets the shape of a link.

Returns:
One of the LinkShape constants.

setShape

public void setShape(int value)
Sets the shape of a link.

Parameters:
value - One of the LinkShape constants.

getHeadPen

public Pen getHeadPen()
Gets the pen used to draw the arrowhead shapes outlines.

Returns:
A Pen object.

setHeadPen

public void setHeadPen(Pen value)
Sets the pen used to draw the arrowhead shapes outlines.

Parameters:
value - A Pen object representing the arrowhead pen.

getEffectiveHeadPen

public Pen getEffectiveHeadPen()
Creates a Pen object representing the currently effective head pen of the link. This method returns a pen corresponding to the link's HeadPen if it is not null, or a pen with the HeadStroke and HeadStrokeThickness properties of the link's style.


getText

public java.lang.String getText()
Gets the text of the link's label.

Returns:
A String containing the label text.

setText

public void setText(java.lang.String value)
Sets the text of the link's label.

Parameters:
value - A String containing the label text.

addLabel

public LinkLabel addLabel(java.lang.String text)
Adds a new label to this link.

Parameters:
text - The label's text.
Returns:
A LinkLabel instance.

addLabel

public void addLabel(LinkLabel label)
Adds a new label to this link.

Parameters:
label - A LinkLabel instance.

removeLabel

public void removeLabel(LinkLabel label)
Removes the specified label from this link.

Parameters:
label - A LinkLabel instance.

labelFromPoint

public LinkLabel labelFromPoint(java.awt.geom.Point2D point)
Returns the label whose layout rectangle contains the specified point.

Parameters:
point - A Point2D instance.
Returns:
The LinkLabel that contains the specified point.

getLabels

public java.util.ArrayList<LinkLabel> getLabels()
Returns the list of all labels displayed by this link.

Returns:
An ArrayList instance.

getTextStyle

public int getTextStyle()
Gets the alignment of the link's label.

Returns:
One of the LinkTextStyle constants.

setTextStyle

public void setTextStyle(int value)
Sets the alignment of the link's label.

Parameters:
value - One of the LinkTextStyle constants.

getHeadShape

public Shape getHeadShape()
Gets the shape of the arrowhead.

Returns:
One of the ArrowHeads constants.

setHeadShape

public void setHeadShape(java.lang.String shapeId)
Sets the shape of the arrowhead.

Parameters:
shapeId - A string specifying the Shape id.

setHeadShape

public void setHeadShape(Shape value)
Sets the shape of the arrowhead.

Parameters:
value - One of the ArrowHeads constants.

getBaseShape

public Shape getBaseShape()
Gets the shape that is displayed at the origin of a link.

Returns:
One of the ArrowHeads constants.

setBaseShape

public void setBaseShape(java.lang.String shapeId)
Sets the shape that is displayed at the origin of a link.

Parameters:
shapeId - A string specifying the Shape id.

setBaseShape

public void setBaseShape(Shape value)
Sets the shape that is displayed at the origin of a link.

Parameters:
value - One of the ArrowHeads constants.

getIntermediateShape

public Shape getIntermediateShape()
Gets the shape that is displayed at the middle of each segment of a link.

Returns:
One of the ArrowHeads constants.

setIntermediateShape

public void setIntermediateShape(java.lang.String shapeId)
Sets the shape that is displayed at the middle of each segment of a link.

Parameters:
shapeId - A string specifying the Shape id.

setIntermediateShape

public void setIntermediateShape(Shape value)
Sets the shape that is displayed at the middle of each segment of a link.

Parameters:
value - One of the ArrowHeads constants.

getHeadShapeSize

public float getHeadShapeSize()
Gets the size of the arrowhead shape.

Returns:
A float value specifying the shape size.

setHeadShapeSize

public void setHeadShapeSize(float value)
Sets the size of the arrowhead shape.

Parameters:
value - A float value specifying the shape size.

getBaseShapeSize

public float getBaseShapeSize()
Gets the size of the shape displayed at the origin of a link.

Returns:
A float value specifying the shape size.

setBaseShapeSize

public void setBaseShapeSize(float value)
Sets the size of the shape displayed at the origin of a link.

Parameters:
value - A float value specifying the shape size.

getIntermediateShapeSize

public float getIntermediateShapeSize()
Gets the size of the shape displayed at the middle of each segment of a link.

Returns:
A float value specifying the shape size.

setIntermediateShapeSize

public void setIntermediateShapeSize(float value)
Sets the size of the shape displayed at the middle of each segment of a link.

Parameters:
value - A float value specifying the shape size.

getHandlesStyle

public int getHandlesStyle()
Gets the style of the link selection handles.

Returns:
One of the HandlesStyle constants.

setHandlesStyle

public void setHandlesStyle(int value)
Sets the style of the link selection handles.

Parameters:
value - One of the HandlesStyle constants.

containsPoint

public boolean containsPoint(java.awt.geom.Point2D point)
DiagramItem.containsPoint override.

Specified by:
containsPoint in class DiagramItem
Parameters:
point - The point to check.
Returns:
true it this item contains the specified point; otherwise, false.

getBounds

public java.awt.geom.Rectangle2D.Float getBounds()
Gets the smallest rectangle that bounds all points of a link.

Specified by:
getBounds in class DiagramItem
Returns:
A Rectangle2D.Float object representing the link's bounding rectangle.

getRepaintRect

protected java.awt.geom.Rectangle2D getRepaintRect(boolean includeConnected)
Description copied from class: DiagramItem
Gets the repaint region for this item, taking into account factors such as pen, selection handles and shadow.

Overrides:
getRepaintRect in class DiagramItem
Parameters:
includeConnected - true if related items should be considered too; otherwise, false.
Returns:
A rectangular region that should be repainted when this item is modified.

getAutoRoute

public boolean getAutoRoute()
Gets a value indicating whether a link should automatically find its way between nodes so that it will not cross other nodes.

Returns:
true if the link is routed automatically, otherwise false.

setAutoRoute

public void setAutoRoute(boolean value)
Sets a value indicating whether a link should automatically find its way between nodes so that it will not cross other nodes.

Parameters:
value - true if the link should be routed automatically, otherwise false.

route

public boolean route()
Sets the link control points so that a link goes between its related nodes without crossing other nodes.


reassignAnchorPoints

public void reassignAnchorPoints()
Chooses new anchor points for a link.


createRouteDescriptor

public RouteDescriptor createRouteDescriptor()
Specified by:
createRouteDescriptor in interface Routable

applyRoute

public void applyRoute(java.util.ArrayList<java.awt.Point> routePoints,
                       RouteDescriptor routeDescriptor,
                       PointList resultPoints)
Specified by:
applyRoute in interface Routable

createState

protected DiagramItemState createState()
DiagramItem.createState() override.

Overrides:
createState in class DiagramItem

saveState

protected void saveState(DiagramItemState state)
DiagramItem.saveState(com.mindfusion.diagramming.DiagramItemState) override.

Overrides:
saveState in class DiagramItem

restoreState

protected void restoreState(DiagramItemState state)
DiagramItem.restoreState(com.mindfusion.diagramming.DiagramItemState) override.

Overrides:
restoreState in class DiagramItem

intersects

public boolean intersects(DiagramNode node)
Determines whether a link intersects the specified node.

Parameters:
node - A DiagramNode object.
Returns:
true if the link intersects the specified node, otherwise false.

getLongestHSegment

public int getLongestHSegment()
Returns the index of the longest non-vertical segment of the link.

Returns:
An integer value specifying the index of the segment.

getLength

public float getLength()
Gets the length of this link.


getSnapToNodeBorder

public boolean getSnapToNodeBorder()
Gets a value indicating whether the end points of a link are automatically aligned to node borders while a user modifies the link.

Returns:
true if the link ends are aligned to node borders, otherwise false.

setSnapToNodeBorder

public void setSnapToNodeBorder(boolean value)
Sets a value indicating whether the end points of a link should be automatically aligned to node borders while a user modifies the link.

Parameters:
value - true if the link ends should be aligned to node borders, otherwise false.

onChangeFont

protected void onChangeFont()
Overrides:
onChangeFont in class DiagramItem

createProperties

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

Overrides:
createProperties in class DiagramItem
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 DiagramItem
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 DiagramItem
Parameters:
props - A DiagramItemProperties -derived object containing a snapshot of the item's properties.

getEditRect

public java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
Specified by:
getEditRect in interface InplaceEditable

getTextToEdit

public java.lang.String getTextToEdit()
Specified by:
getTextToEdit in interface InplaceEditable

setEditedText

public void setEditedText(java.lang.String newText)
Specified by:
setEditedText in interface InplaceEditable

getCustomDraw

public int getCustomDraw()
Gets the type of custom drawing performed on this link.

Returns:
This property allows invoking custom painting code for a link.

setCustomDraw

public void setCustomDraw(int value)
Gets the type of custom drawing performed on this link.

Parameters:
value - This property allows invoking custom painting code for a link.