Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.nwoods.jgo
Class JGoLink

    java.lang.Object
      com.nwoods.jgo.JGoObject
          com.nwoods.jgo.JGoDrawable
              com.nwoods.jgo.JGoStroke
                  com.nwoods.jgo.JGoLink

All Implemented Interfaces:
  JGoIdentifiablePart, JGoXMLSaveRestore, java.io.Serializable

Direct Known Subclasses:
  JGoLabeledLink

public class JGoLink
extends JGoStroke
implements JGoIdentifiablePart

JGoLink is a JGoStroke that connects two different JGoPorts.

If the position of one or both of its JGoPorts changes, the JGoLink redraws itself to connect the new positions.

The default link stroke will consist of three segments. The end segments, at the ports, will be relatively short and either horizontal or vertical. The middle segment will be just a straight line connecting the two short segments at the ports. There is no short end segment if the corresponding port does not have a link port spot (i.e., the value is NoSpot).

By turning on the Orthogonal property, a link will have segments that are all either horizontal or vertical. To handle what would normally be "Z" shaped links, there are five segments (i.e. six stroke points).

A selected link will not have selection handles at the very end points, unless there are only one or two segments in the stroke. Resizing a link causes a new link to be started, keeping one of the ports for the new link.

You can define your own style of link by overriding calculateStroke() or by overriding paint().

"Resizing" the first or last pick points continues to have the old behavior of disconnecting the link and starting to create a new one. Furthermore, if the link isOrthogonal, and the resize handle is one of the two middle ones, then it also moves the other middle stroke point to maintain orthogonality of that middle segment.

The resize behavior for the user's "relinking" an existing link to a different port sets the link's corresponding port to null and calls the JGoView.startReLink method. The static boolean property DefaultResizingRelinks has been added to control whether resizing links should use the new modify-the-existing-link behavior or the delete-and-create-anew behavior. The default value is true, to use the view's ReLink methods. The value of false would use the view's NewLink methods.

A Relinkable link (by default true) allows the user to interactively reconnect one end of the link to another valid port (or to the original port; or to nothing, thereby deleting the link).

A link that AvoidsNodes has a smarter implementation of calculateStroke() that routes the path of the link so as to try not to cross any avoidable objects. Of course, if either end of the link is inside an object, or if there is no non-area-crossing path that be found, the path of the link may default to the standard calculateStroke behavior. You can customize the objects to be avoided by overriding JGoDocument.isAvoidable and JGoDocument.getAvoidableRectangle -- by default JGoDocument.isAvoidable is true for instances of JGoArea, and the size and position of the object to be avoided is just the bounding rectangle of the area. This property, by default false, only applies when isOrthogonal() is true and isCubic() is false. Setting this property to true will incur some additional overhead to search for the shortest, straightest path between the ports. You may wish to set JGoView.setDragsRealtime(false) in order to improve responsiveness while dragging.

A link that JumpsOver is drawn with small half-ellipses where the path of the segment crosses over another link whose isJumpsOver() property is true. Both the link that crosses over and the link that is crossed over must have the Orthogonal property true, the Cubic property false, and the JumpsOver property true. The crossed over link must be "behind" the crossing link. This property is false by default. Setting this property to true will incur some additional overhead to detect segment intersections. You may wish to set JGoView.setDragsRealtime(false) in order to improve responsiveness while dragging. This property may also be ignored when the view's scale is small.

Orthogonal links can also be drawn with rounded corners--turn on the RoundedCorners property. The size of the corner is specified by the Curviness property, but is limited by the lengths of the segments meeting at a corner.

The Curviness property not only controls rounded corners for Orthogonal links, but the default curve for Cubic (Bezier) strokes. Positive values cause the Bezier stroke to curve clockwise; negative values curve counter-clockwise; and a value of zero produces a straight line.

See Also:
  Serialized Form

Field Summary
`static int` | `AdjustingStyleCalculate` Clear all of the existing points and add points for the standard kinds of strokes.
`static int` | `AdjustingStyleEnd` When there are more than the standard number of points in the stroke, or if the stroke is orthogonal, just modify the end points, while leaving the intermediate points unchanged.
`static int` | `AdjustingStyleScale` When there are more than the standard number of points in the stroke, scale and rotate the intermediate points so that the link's shape stays approximately the same.
`static int` | `AdjustingStyleStretch` When there are more than the standard number of points in the stroke, linearly interpolate the intermediate points along the X and Y dimensions between the ports.
`static int` | `ChangedAdjustingStyle` a CHANGED JGoDocumentEvent or JGoViewEvent hint: how calculateStroke determines the path of the link
`static int` | `ChangedAvoidsNodes` a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link "jumps over" other Orthogonal links
`static int` | `ChangedCurviness` a CHANGED JGoDocumentEvent or JGoViewEvent hint: how curvy a Cubic link is when the path is automatically calculated
`static int` | `ChangedFromPort` a CHANGED JGoDocumentEvent or JGoViewEvent hint: the "from" port has changed
`static int` | `ChangedJumpsOver` a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link "jumps over" other Orthogonal links
`static int` | `ChangedOrthogonal` a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link routing style has changed
`static int` | `ChangedPartID` a CHANGED JGoDocumentEvent or JGoViewEvent hint:
`static int` | `ChangedRelinkable` a CHANGED JGoDocumentEvent or JGoViewEvent hint: whether the user can reconnect this link has changed
`static int` | `ChangedRoundedCorners` a CHANGED JGoDocumentEvent or JGoViewEvent hint:
`static int` | `ChangedToPort` a CHANGED JGoDocumentEvent or JGoViewEvent hint: the "to" port has changed
`static int` | `ChangedUserObject` a CHANGED JGoDocumentEvent or JGoViewEvent hint:
`static int` | `RelinkableFromHandle` a handle ID: the user can relink from the "from" port
`static int` | `RelinkableToHandle` a handle ID: the user can relink from the "to" port

Fields inherited from class com.nwoods.jgo.JGoStroke
`ChangedAddPoint, ChangedAllPoints, ChangedArrowAngle, ChangedArrowHeads, ChangedArrowLength, ChangedArrowShaftLength, ChangedArrowWidth, ChangedCubic, ChangedHighlight, ChangedModifiedPoint, ChangedRemovePoint, myPoints`

Fields inherited from class com.nwoods.jgo.JGoObject
`Bottom, BottomCenter, BottomLeft, BottomMiddle, BottomRight, Center, CenterLeft, CenterRight, Changed4ResizeHandles, ChangedAutoRescale, ChangedBrush, ChangedDraggable, ChangedDragsNode, ChangedGeometry, ChangedGrabChildSelection, ChangedInitializing, ChangedPen, ChangedResizable, ChangedSelectable, ChangedUpdatePartner, ChangedVisible, ChangedZOrder, LastChangedHint, Left, LeftCenter, NoHandle, NoSpot, NumReservedHandles, RepaintAll, Right, RightCenter, SideLeft, SideRight, Top, TopCenter, TopLeft, TopMiddle, TopRight`

Constructor Summary
`JGoLink()` Create an unconnected link.
`JGoLink(JGoPort from, JGoPort to)` Create a link from one port to another.

Method Summary
`protected void` | `addOrthoPoints(int startFromX, int startFromY, double fromDir, int endToX, int endToY, double toDir)` If the link should be routed orthogonally, this method is called in order to add stroke points between the end segments.
`protected boolean` | `adjustPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)` Adjust all of the existing points in this link's stroke in an inclusive range according to new first and last stroke points.
`void` | `calculateStroke()` Given the information (start and end port) of this link we need to calculate the JGoStroke that goes between them.
`void` | `changeValue(JGoDocumentChangedEdit e, boolean undo)` This method is called by the JGoDocumentChangedEdit.undo and redo methods to actually perform the property value change for a JGoObject.
`void` | `copyNewValueForRedo(JGoDocumentChangedEdit e)` This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed.
`JGoObject` | `copyObject(JGoCopyEnvironment env)` Create a copy of the JGoLink, but do not copy or share the links ports.
`void` | `copyObjectDelayed(JGoCopyEnvironment env, JGoObject newobj)` This is called in the second pass of copying objects, so that each JGoLink can find and hook up to the appropriate new copies of ports.
`protected void` | `gainedSelection(JGoSelection selection)` Called whenever this link is added to a selection in some view.
`int` | `getAdjustingStyle()` Return the current behavior for the calculateStroke method.
`int` | `getCurviness()` Returns the offset from a straight line used to position the control points of a cubic (Bezier) link between two ports that have NoSpot.
`int` | `getFirstPickPoint()` Return the start point to display a handle on.
`JGoPort` | `getFromPort()` Returns the source port of this link.
`int` | `getLastPickPoint()` Return the end point to display a handle on.
`protected int` | `getMidOrthoPosition(int from, int to, boolean vertical)` Return the horizontal or vertical position for the middle segment of the orthogonally routed link.
`JGoPort` | `getOtherPort(JGoPort p)` Sometimes when you get a link connected to a port, you don't know which end was connected to the port.
`int` | `getPartID()` Return the integer PartID for this JGoObject that is in a JGoDocument.
`JGoPort` | `getToPort()` Returns the destination port of this link.
`java.lang.Object` | `getUserObject()` Gets an Object value that is not used by JGo.
`java.awt.Rectangle` | `handleResize(java.awt.Graphics2D g, JGoView view, java.awt.Rectangle prevRect, java.awt.Point newPoint, int whichHandle, int event, int minWidth, int minHeight)` Called when a link point is moved.
`boolean` | `isAvoidsNodes()` Return whether this orthogonal link's path should try to avoid any JGoAreas.
`boolean` | `isCubic()` Links are automatically Cubic if isSelfLoop() is true and isOrthogonal() is false
`static boolean` | `isDefaultResizingRelinks()` Return whether reconnecting an existing link by dragging its end resize handles just modifies the link or deletes it and starts creating a new link.
`boolean` | `isJumpsOver()` Return whether this link changes its path to "jump over" any Orthogonal, non-Cubic links that it crosses.
`boolean` | `isOrthogonal()` This predicate is true if the link should be routed vertically and horizontally.
`boolean` | `isRelinkable()` Return whether the user can interactively reconnect one end of this link to another valid port.
`boolean` | `isRoundedCorners()` Return whether this link, when Orthogonal, draws its path with round corners.
`boolean` | `isSelfLoop()` Returns true when both ports are the same and non-null.
`protected boolean` | `modifyEndPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)` Modify only the end points of this stroke to match the new From and To points; intermediate points are not changed.
`protected void` | `ownerChange(JGoObjectCollection oldOwner, JGoObjectCollection newOwner, JGoObject mainObject)` When a link is "deleted", we need to unlink from the ports.
`void` | `paint(java.awt.Graphics2D g, JGoView view)` Draw the stroke on the graphics context.
`void` | `portChange(JGoPort port, int hint, int prevInt, java.lang.Object prevVal)` Called when a port is changed (or moved or resized, etc.)
`protected boolean` | `rescalePoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)` Maintain the same shape for the stroke, but scale and rotate according to the new points (nFx,nFy) and (nTx,nTy).
`void` | `setAdjustingStyle(int adj)` Specify how calculateStroke modifies the stroke path of a link.
`void` | `setAvoidsNodes(boolean bFlag)` Change whether this link's path, when Orthogonal, tries to avoid any JGoAreas.
`void` | `setCurviness(int c)` Change how curvy a cubic link will be between two ports with NoSpot, or how rounded the corners of an orthogonal link will be (if isRoundedCorners() is true).
`static void` | `setDefaultResizingRelinks(boolean reuse)` Change whether the user's dragging the end selection handle points of a link will cause the link to be removed from the document and an entirely new link created by the view, or whether the link will be retained in the document and only its port is modified.
`void` | `setFromPort(JGoPort from)` Sets the source port of this link.
`void` | `setJumpsOver(boolean bFlag)` Change whether this link, when Orthogonal, "jumps over" other orthogonal links to avoid the appearance of a junction.
`void` | `setOrthogonal(boolean bOrtho)` Change whether the link will be routed vertically and horizontally.
`void` | `setPartID(int id)` Change the PartID for a JGoObject; this is normally only called by JGoDocument code when this object is added to a document layer.
`void` | `setRelinkable(boolean bFlag)` Change whether this link can be reconnected interactively by the user.
`void` | `setRoundedCorners(boolean bFlag)` Change whether this link, when Orthogonal, has rounded corners.
`void` | `setToPort(JGoPort to)` Sets the destination port of this link.
`void` | `setUserObject(java.lang.Object obj)` Sets an Object value that is not used by JGo.
`protected boolean` | `stretchPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy)` Stretch the points of this stroke by interpolating the points from startIndex to endIndex between the new points (nFx,nFy) and (nTx,nTy).
`DomNode` | `SVGReadObject(DomDoc svgDoc, JGoDocument jGoDoc, DomElement svgElement, DomElement jGoChildElement)` Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.
`void` | `SVGUpdateReference(java.lang.String attr, java.lang.Object referencedObject)` This method will be called to fill in object references.
`void` | `SVGWriteObject(DomDoc svgDoc, DomElement jGoElementGroup)` Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.
`void` | `unlink()` Called when we want to remove this link.

Methods inherited from class com.nwoods.jgo.JGoStroke
`addPoint, addPoint, calculateFilledArrowhead, computeBoundingRect, copyOldValueForUndo, copyPoints, copyPointsArray, drawArrowhead, drawArrowHeads, expandRectByPenWidth, geometryChange, getArrowAngle, getArrowFromAnchorPoint, getArrowFromEndPoint, getArrowLength, getArrowShaftLength, getArrowToAnchorPoint, getArrowToEndPoint, getArrowWidth, getEndPoint, getHighlight, getNearestIntersectionOnLine, getNearestIntersectionPoint, getNearestPointOnLine, getNearestPointOnLine, getNumPoints, getPoint, getPointX, getPointY, getSegmentNearPoint, getStartPoint, hasArrowAtEnd, hasArrowAtStart, insertPoint, insertPoint, isPointInObj, removeAllPoints, removePoint, setArrowAngle, setArrowHeads, setArrowLength, setArrowShaftLength, setArrowWidth, setCubic, setHighlight, setPoint, setPoint, setPoints, setPoints`

Methods inherited from class com.nwoods.jgo.JGoDrawable
`draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, getBrush, getPen, setBrush, setPen, SVGAddPathArgs, SVGReadAttributes, SVGWriteAttributes`

Methods inherited from class com.nwoods.jgo.JGoObject
`canView, computeMove, computeResize, copy, copyRect, doMouseClick, doMouseDblClick, doUncapturedMouseMove, findCommonParent, foredate, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getParent, getParentJGoNode, getParentNode, getPartner, getRectangleSpotLocation, getSize, getSize, getSpotLocation, getSpotLocation, getToolTipText, getTop, getTopLeft, getTopLeft, getTopLevelObject, getView, getWidth, growRect, handleMove, hideSelectionHandles, is4ResizeHandles, isAutoRescale, isBoundingRectInvalid, isChildOf, isDraggable, isDragsNode, isInitializing, isResizable, isSelectable, isSkipsUndoManager, isSuspendChildUpdates, isSuspendUpdates, isTopLevel, isUpdatePartner, isVisible, lostSelection, partnerUpdate, pick, redirectSelection, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectForce, setBoundingRectForce, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setPartner, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendChildUpdates, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setVisible, setWidth, showSelectionHandles, spotOpposite, update, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### AdjustingStyleCalculate

    public static final int AdjustingStyleCalculate

  Clear all of the existing points and add points for the standard kinds of strokes.

  A JGoLink has a number of standard appearances, as determined by calculateStroke():

  - When both ports have link spots that are NoSpot, draw a straight line if the isCubic() is false or draw a Bezier curve if the isCubic() is true.
  - When only one port has a link spot, draw a two segment straight line.
  - When both ports have link spots, draw either a three-segment line or a Bezier curve, depending on the value of isCubic().
  - If isOrthogonal() is true, draw a five-segment line (either straight segments or with rounded corners) or a Bezier curve.
  - If isSelfLoop() is true, draw either a Bezier curve or a five-segment line if isOrthogonal() is true.

  See Also:
    Constant Field Values

### AdjustingStyleScale

    public static final int AdjustingStyleScale

  When there are more than the standard number of points in the stroke, scale and rotate the intermediate points so that the link's shape stays approximately the same.

  This style, implemented by the rescalePoints method, does not maintain the horizontal and vertical line segments of an orthogonal link. Orthogonal links with this adjusting style will instead recalculate the standard stroke path, as if the adjusting style were AdjustingStyleCalculate.

  See Also:
    Constant Field Values

### AdjustingStyleStretch

    public static final int AdjustingStyleStretch

  When there are more than the standard number of points in the stroke, linearly interpolate the intermediate points along the X and Y dimensions between the ports.

  This style, implemented by the stretchPoints method, does not maintain the horizontal and vertical line segments of an orthogonal link. Orthogonal links with this adjusting style will instead only modify the end points of the existing path, as if the adjusting style were AdjustingStyleEnd.

  See Also:
    Constant Field Values

### AdjustingStyleEnd

    public static final int AdjustingStyleEnd

  When there are more than the standard number of points in the stroke, or if the stroke is orthogonal, just modify the end points, while leaving the intermediate points unchanged.

  This style maintains orthogonality for orthogonal links.

  See Also:
    Constant Field Values

### RelinkableFromHandle

    public static final int RelinkableFromHandle

  a handle ID: the user can relink from the "from" port

  See Also:
    Constant Field Values

### RelinkableToHandle

    public static final int RelinkableToHandle

  a handle ID: the user can relink from the "to" port

  See Also:
    Constant Field Values

### ChangedFromPort

    public static final int ChangedFromPort

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: the "from" port has changed

  See Also:
    Constant Field Values

### ChangedToPort

    public static final int ChangedToPort

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: the "to" port has changed

  See Also:
    Constant Field Values

### ChangedOrthogonal

    public static final int ChangedOrthogonal

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link routing style has changed

  See Also:
    Constant Field Values

### ChangedRelinkable

    public static final int ChangedRelinkable

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: whether the user can reconnect this link has changed

  See Also:
    Constant Field Values

### ChangedJumpsOver

    public static final int ChangedJumpsOver

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link "jumps over" other Orthogonal links

  See Also:
    Constant Field Values

### ChangedAvoidsNodes

    public static final int ChangedAvoidsNodes

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: the link "jumps over" other Orthogonal links

  See Also:
    Constant Field Values

### ChangedCurviness

    public static final int ChangedCurviness

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: how curvy a Cubic link is when the path is automatically calculated

  See Also:
    Constant Field Values

### ChangedAdjustingStyle

    public static final int ChangedAdjustingStyle

  a CHANGED JGoDocumentEvent or JGoViewEvent hint: how calculateStroke determines the path of the link

  See Also:
    Constant Field Values

### ChangedUserObject

    public static final int ChangedUserObject

  a CHANGED JGoDocumentEvent or JGoViewEvent hint:

  See Also:
    Constant Field Values

### ChangedPartID

    public static final int ChangedPartID

  a CHANGED JGoDocumentEvent or JGoViewEvent hint:

  See Also:
    Constant Field Values

### ChangedRoundedCorners

    public static final int ChangedRoundedCorners

  a CHANGED JGoDocumentEvent or JGoViewEvent hint:

  See Also:
    Constant Field Values

Constructor Detail

### JGoLink

    public JGoLink()

  Create an unconnected link.

### JGoLink

    public JGoLink(JGoPort from,
                   JGoPort to)

  Create a link from one port to another.

  Because links are automatically redrawn when either port moves, they are by default not Draggable. However, they are by default Selectable and Resizable and Relinkable, allowing users to reconnect an end of the link.

  If both ports belong to documents, they must belong to the same document. Creating a link does not automatically add it to any document. You will need to add the link to the desired document layer before the link can appear in any view.

Parameters:
  `from` - the starting port.
  `to` - the ending port.

Method Detail

### copyObject

    public JGoObject copyObject(JGoCopyEnvironment env)

  Create a copy of the JGoLink, but do not copy or share the links ports.

  Overrides:
    `copyObject` in class `JGoStroke`
  Parameters:
    `env` - the environment for the copy operation - keeps track of copied objects.

### copyObjectDelayed

    public void copyObjectDelayed(JGoCopyEnvironment env,
                                  JGoObject newobj)

  This is called in the second pass of copying objects, so that each JGoLink can find and hook up to the appropriate new copies of ports.

  If both new ports corresponding to this link's existing ports cannot be found, this link is removed from the document.

  Overrides:
    `copyObjectDelayed` in class `JGoObject`
  Parameters:
    `env` - a JGoCopyEnvironment that remembers the mapping of original objects to copied ones
    `newobj` - the newly copied instance of this object

### unlink

    public void unlink()

  Called when we want to remove this link.

  This removes the link from both ports, and then removes the link from the containing document or view.

### gainedSelection

    protected void gainedSelection(JGoSelection selection)

  Called whenever this link is added to a selection in some view.

  The default behavior creates resize handles at each of the link's stroke points.

  Overrides:
    `gainedSelection` in class `JGoStroke`
  Parameters:
    `selection` - the selection to which this object was added

### handleResize

    public java.awt.Rectangle handleResize(java.awt.Graphics2D g,
                                           JGoView view,
                                           java.awt.Rectangle prevRect,
                                           java.awt.Point newPoint,
                                           int whichHandle,
                                           int event,
                                           int minWidth,
                                           int minHeight)

  Called when a link point is moved.

  By default resizing a link (i.e., dragging a resize handle on a link), if the handle is either the first or last one, disconnects the selected link at one end and starts connecting that end to a possibly different port. If the handle being dragged is one not at either end, then the default behavior is to just move the stroke's point. However, if isOrthogonal() is true, the default behavior is to constrain such movement in a horizontal or vertical fashion, as seems appropriate based on the coordinates of the middle segment's points.

  Overrides:
    `handleResize` in class `JGoStroke`
  Parameters:
    `g` - the graphics context to draw on
    `view` - the view we're being resizing in
    `prevRect` - the previous bounding rectangle (unused)
    `newPoint` - the location of the new point
    `whichHandle` - the handle number of the point being moved
    `event` - the event
    `minWidth` - the minimum width of the object (unused)
    `minHeight` - the minimim height of the object (unused)
  Returns:
    null, because no XOR resize box is needed

### ownerChange

    protected void ownerChange(JGoObjectCollection oldOwner,
                               JGoObjectCollection newOwner,
                               JGoObject mainObject)

  When a link is "deleted", we need to unlink from the ports.

  Overrides:
    `ownerChange` in class `JGoObject`
  Parameters:
    `oldOwner` - the previous owner object
    `newOwner` - the new owner object
    `mainObject` - the object being inserted or removed from the document or view

### portChange

    public void portChange(JGoPort port,
                           int hint,
                           int prevInt,
                           java.lang.Object prevVal)

  Called when a port is changed (or moved or resized, etc.)

  By default this will recalculate the points in the link's stroke, unless the change hint indicates a change in the port's Style or PortObject, or unless the port's link point appears not to have moved.

  The parameters are the same as for a port's call to update, with the addition of a JGoPort argument that indicates which port had changed.

### getFirstPickPoint

    public int getFirstPickPoint()

  Return the start point to display a handle on.

  Overrides:
    `getFirstPickPoint` in class `JGoStroke`
  Returns:
    the first point which can be selected

### getLastPickPoint

    public int getLastPickPoint()

  Return the end point to display a handle on.

  Overrides:
    `getLastPickPoint` in class `JGoStroke`
  Returns:
    the last point which can be selected

### getFromPort

    public JGoPort getFromPort()

  Returns the source port of this link.

  Returns:
    the source port of this link.

### getToPort

    public JGoPort getToPort()

  Returns the destination port of this link.

  Returns:
    the destination port of this link.

### setFromPort

    public void setFromPort(JGoPort from)

  Sets the source port of this link.

  Parameters:
    `from` - the source port of this link.

### setToPort

    public void setToPort(JGoPort to)

  Sets the destination port of this link.

  Parameters:
    `to` - the destination port of this link.

### getOtherPort

    public JGoPort getOtherPort(JGoPort p)

  Sometimes when you get a link connected to a port, you don't know which end was connected to the port. This function returns the port at the other end of the link from the given port.

### isCubic

    public boolean isCubic()

  Links are automatically Cubic if isSelfLoop() is true and isOrthogonal() is false

  Overrides:
    `isCubic` in class `JGoStroke`

### isSelfLoop

    public boolean isSelfLoop()

  Returns true when both ports are the same and non-null. This is used by calculateStroke to decide whether to draw the link stroke as a cubic curve forming a loop.

### getCurviness

    public int getCurviness()

  Returns the offset from a straight line used to position the control points of a cubic (Bezier) link between two ports that have NoSpot. This also specifies the maximum diameter of rounded corners for orthogonal links when isRoundedCorners() is true. This defaults to 10.

### setCurviness

    public void setCurviness(int c)

  Change how curvy a cubic link will be between two ports with NoSpot, or how rounded the corners of an orthogonal link will be (if isRoundedCorners() is true).

  Parameters:
    `c` - a zero value will produce a straight line; negative values cause the link to curve counterclockwise

### calculateStroke

    public void calculateStroke()

  Given the information (start and end port) of this link we need to calculate the JGoStroke that goes between them. We need to take into account the direction of the ports and esthetically pleasing bends in the link.

### adjustPoints

    protected boolean adjustPoints(int startIndex,
                                   int nFx,
                                   int nFy,
                                   int endIndex,
                                   int nTx,
                                   int nTy)

  Adjust all of the existing points in this link's stroke in an inclusive range according to new first and last stroke points.

  This is primarily useful to help maintain intermediate inflection points in a link when one or both ports moves. By default this just calls rescalePoints, stretchPoints, or modifyEndPoints. This method is not called when there are no existing points to be adjusted or when getAdjustingStyle is AdjustingStyleCalculate. When this link is Orthogonal, an AdjustingStyle of AdjustingStyleScale will just return false to result in the standard orthogonal path. An AdjustingStyle of AdjustingStyleStretch for an orthogonal link is treated as if it were AdjustingStyleEnd.

  Parameters:
    `startIndex` - the zero-based index of the first point to be changed, to be (nFx,nFy)
    `nFx` - X document coordinate of the new From point
    `nFy` - Y document coordinate of the new From point
    `endIndex` - the zero-based index of the last point to be changed, to be (nTx,nTy)
    `nTx` - X document coordinate of the new To point
    `nTy` - Y document coordinate of the new To point
  Returns:
    true if the stroke points were adjusted, false if calculateStroke should plot the standard path

### rescalePoints

    protected boolean rescalePoints(int startIndex,
                                    int nFx,
                                    int nFy,
                                    int endIndex,
                                    int nTx,
                                    int nTy)

  Maintain the same shape for the stroke, but scale and rotate according to the new points (nFx,nFy) and (nTx,nTy).

  The startIndex point should be set to the new From point (nFx,nFy) and the endIndex point should be set to the new To point (nTx,nTy). All the intermediate points should be scaled and rotated accordingly to maintain the same shape as the original set of points from startIndex to endIndex, inclusive. The method adjustPoints calls this method when getAdjustingStyle returns AdjustingStyleScale. This method should not be used when Orthogonal is true.

  Parameters:
    `startIndex` - the zero-based index of the first point to be changed, to be (nFx,nFy)
    `nFx` - X document coordinate of the new From point
    `nFy` - Y document coordinate of the new From point
    `endIndex` - the zero-based index of the last point to be changed, to be (nTx,nTy)
    `nTx` - X document coordinate of the new To point
    `nTy` - Y document coordinate of the new To point
  Returns:
    true if the stroke points were adjusted, false if calculateStroke should plot the standard path

### stretchPoints

    protected boolean stretchPoints(int startIndex,
                                    int nFx,
                                    int nFy,
                                    int endIndex,
                                    int nTx,
                                    int nTy)

  Stretch the points of this stroke by interpolating the points from startIndex to endIndex between the new points (nFx,nFy) and (nTx,nTy).

  The startIndex point should be set to (nFx,nFy), the endIndex point should be set to (nTx,nTy), and all the intermediate points should be interpolated linearly to stretch or compress the original set of points from startIndex to endIndex, inclusive, along each of the X and Y dimensions. The method adjustPoints calls this method when getAdjustingStyle is AdjustingStyleStretch. This method should not be used when Orthogonal is true.

  Parameters:
    `startIndex` - the zero-based index of the first point to be changed, to be (nFx,nFy)
    `nFx` - X document coordinate of the new From point
    `nFy` - Y document coordinate of the new From point
    `endIndex` - the zero-based index of the last point to be changed, to be (nTx,nTy)
    `nTx` - X document coordinate of the new To point
    `nTy` - Y document coordinate of the new To point
  Returns:
    true if the stroke points were adjusted, false if calculateStroke should plot the standard path

### modifyEndPoints

    protected boolean modifyEndPoints(int startIndex,
                                      int nFx,
                                      int nFy,
                                      int endIndex,
                                      int nTx,
                                      int nTy)

  Modify only the end points of this stroke to match the new From and To points; intermediate points are not changed.

  The startIndex point should be set to (nFx,nFy), and the endIndex point should be set to (nTx,nTy), and the intermediate points should be not be changed unless needed to maintain orthogonality when Orthogonal is true.

  Parameters:
    `startIndex` - the zero-based index of the first point to be changed, to be (nFx,nFy)
    `nFx` - X document coordinate of the new From point
    `nFy` - Y document coordinate of the new From point
    `endIndex` - the zero-based index of the last point to be changed, to be (nTx,nTy)
    `nTx` - X document coordinate of the new To point
    `nTy` - Y document coordinate of the new To point
  Returns:
    true if the stroke points were adjusted, false if calculateStroke should plot the standard path

### addOrthoPoints

    protected void addOrthoPoints(int startFromX,
                                  int startFromY,
                                  double fromDir,
                                  int endToX,
                                  int endToY,
                                  double toDir)

  If the link should be routed orthogonally, this method is called in order to add stroke points between the end segments.

  The default implementation only adds points if both end segment directions are horizontal or vertical.

  Parameters:
    `startFromX` - position of inner endpoint of first segment
    `startFromY` - position of inner endpoint of first segment
    `fromDir` - the direction of the first segment coming out of the from port
    `endToX` - position of inner endpoint of last segment
    `endToY` - position of inner endpoint of last segment
    `toDir` - the direction of the last segment going into the to port

### getMidOrthoPosition

    protected int getMidOrthoPosition(int from,
                                      int to,
                                      boolean vertical)

  Return the horizontal or vertical position for the middle segment of the orthogonally routed link.

  By default this is just the mid-point between the from and to positions. You may want to override this in order to move the middle segment to one side or the other, either to make room for other objects or to avoid overlapping the middle segments of links coming from other ports on the same node.

  Parameters:
    `from` - position of the inner end of the first segment
    `to` - position of the inner end of the last segment
    `vertical` - Whether the mid-position is along the vertical axis or horizontal

### isOrthogonal

    public boolean isOrthogonal()

  This predicate is true if the link should be routed vertically and horizontally.

### setOrthogonal

    public void setOrthogonal(boolean bOrtho)

  Change whether the link will be routed vertically and horizontally.

  With the default implementation setting this property to true is only effective if both ports have vertical or horizontal end segments (i.e. JGoPort.getFromLinkDir() and JGoPort.getToLinkDir() both returned a vertical or horizontal direction).

  Parameters:
    `bOrtho` - true if the link should be drawn with vertical and horizontal segments

### setJumpsOver

    public void setJumpsOver(boolean bFlag)

  Change whether this link, when Orthogonal, "jumps over" other orthogonal links to avoid the appearance of a junction.

  Parameters:
    `bFlag` - true if this link displays "jump over"s

### isJumpsOver

    public boolean isJumpsOver()

  Return whether this link changes its path to "jump over" any Orthogonal, non-Cubic links that it crosses.

  By default this is false.

### setRoundedCorners

    public void setRoundedCorners(boolean bFlag)

  Change whether this link, when Orthogonal, has rounded corners.

  Parameters:
    `bFlag` - true if this link's path is drawn with circular corners, with a radius determined by getCurviness()

### isRoundedCorners

    public boolean isRoundedCorners()

  Return whether this link, when Orthogonal, draws its path with round corners.

  By default this is false.

### setAvoidsNodes

    public void setAvoidsNodes(boolean bFlag)

  Change whether this link's path, when Orthogonal, tries to avoid any JGoAreas.

  Parameters:
    `bFlag` - true if this link is routed by calculateStroke() to avoid any JGoAreas.

### isAvoidsNodes

    public boolean isAvoidsNodes()

  Return whether this orthogonal link's path should try to avoid any JGoAreas.

  By default this is false.

### setAdjustingStyle

    public void setAdjustingStyle(int adj)

  Specify how calculateStroke modifies the stroke path of a link.

  Parameters:
    `adj` - one of AdjustingStyleCalculate, AdjustingStyleScale, AdjustingStyleStretch, AdjustingStyleEnd

### getAdjustingStyle

    public int getAdjustingStyle()

  Return the current behavior for the calculateStroke method.

  By default this is AdjustingStyleCalculate.

### setRelinkable

    public void setRelinkable(boolean bFlag)

  Change whether this link can be reconnected interactively by the user.

  Parameters:
    `bFlag` - true if the user can reconnect this link

### isRelinkable

    public boolean isRelinkable()

  Return whether the user can interactively reconnect one end of this link to another valid port.

  By default this is true.

### paint

    public void paint(java.awt.Graphics2D g,
                      JGoView view)

  Description copied from class: `JGoStroke`
  Draw the stroke on the graphics context.

  Overrides:
    `paint` in class `JGoStroke`
  Parameters:
    `g` - the graphics context on which to draw.
    `view` - the view we're drawing in

### getPartID

    public int getPartID()

  Description copied from interface: `JGoIdentifiablePart`
  Return the integer PartID for this JGoObject that is in a JGoDocument.

  Specified by:
    `getPartID` in interface `JGoIdentifiablePart`

### setPartID

    public void setPartID(int id)

  Description copied from interface: `JGoIdentifiablePart`
  Change the PartID for a JGoObject; this is normally only called by JGoDocument code when this object is added to a document layer.

  Specified by:
    `setPartID` in interface `JGoIdentifiablePart`

### getUserObject

    public java.lang.Object getUserObject()

  Gets an Object value that is not used by JGo.

### setUserObject

    public void setUserObject(java.lang.Object obj)

  Sets an Object value that is not used by JGo.

### copyNewValueForRedo

    public void copyNewValueForRedo(JGoDocumentChangedEdit e)

  Description copied from class: `JGoObject`
  This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. In order for the JGoDocumentChangedEdit to be able to perform a redo, it needs to remember the new property value or state. However, the JGoObject.update method does not provide such a new value. The value must be taken from this object and copied into the JGoDocumentChangedEdit by calling setNewValue and/or setNewValueInt.

  Just as the previous/old value/state information is stored as one or both of an integer and an Object, the new value/state information may be stored as either or both of an integer or an Object.

  The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.

  Overrides:
    `copyNewValueForRedo` in class `JGoStroke`

### changeValue

    public void changeValue(JGoDocumentChangedEdit e,
                            boolean undo)

  Description copied from class: `JGoObject`
  This method is called by the JGoDocumentChangedEdit.undo and redo methods to actually perform the property value change for a JGoObject.

  You will want to override this method to handle changing the additional state of your object subclasses.

  Overrides:
    `changeValue` in class `JGoStroke`

### SVGWriteObject

    public void SVGWriteObject(DomDoc svgDoc,
                               DomElement jGoElementGroup)

  Description copied from interface: `JGoXMLSaveRestore`
  Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

  This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGWriteDoc() for every JGoObject contained within a JGoDocument. The following example uses a JGoRectangle to illustrate the format of a generated SVG JGoObject:

  <g>
  <JGoClass class="com.nwoods.jgo.JGoRectangle"\>
  <rect height="75" style="stroke:black;stroke-width:1;fill:rgb(255,0,0);" width="75" x="65" y="71"/>
  <JGoClass class="com.nwoods.jgo.JGoDrawable" drawablebrush="jgoid1" drawablepen="jgoid2" embeddedpenbrush="false"/>
  <JGoClass class="com.nwoods.jgo.JGoObject" obj_flags="1054"/>
  </g>

  Note that the entire JGoObject is enclosed in a group (<g>). Each subclass of the JGoObject is described by a <JGoClass> element, starting with the most specific class and moving to the more general. Each <JGoClass> element has a "class" attribute which defines the class name. Each <JGoClass> element may also have several other attributes which uniquely describe that state of that class. Following the <JGoClass> element, each class may also genereate any other elements that are required, including representations of contained objects and standard SVG elements such as the <rect> element shown in the above example. The generation of SVG elements in the output makes it possible for the output to be read by SVG viewers and other SVG aware applications. The information contained in the <JGoClass> elements allows us to accurately save and restore all the information in a particular JGoObject subclass.

  If this class contains a reference to another object, call DomDoc.registerReferencingNode() to register that reference. This will cause the element representing the referenced object to be identified with a unique id attribute, and cause the element representing the referring object to have a user defined attribute containing a reference to that id. See DomDoc.registerReferencingNode() for more information.

  Typically, an implementation of this method will generate a <JGoClass> element using the DomDoc.createJGoClassElement() method, adding whatever attributes are necessary to describe the class. It will then call its superclass so that the superclass can add its own <JGoClass> element and other information to jGoElementGroup within the DomDoc.

  Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGWriteObject() and com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for examples using this method.

  Refer to the file com.nwoods.jgo.svg\xsvg.dtd for a formal description of JGo extensions to the SVG document type.

  Specified by:
    `SVGWriteObject` in interface `JGoXMLSaveRestore`
  Overrides:
    `SVGWriteObject` in class `JGoStroke`

### SVGReadObject

    public DomNode SVGReadObject(DomDoc svgDoc,
                                 JGoDocument jGoDoc,
                                 DomElement svgElement,
                                 DomElement jGoChildElement)

  Description copied from interface: `JGoXMLSaveRestore`
  Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

  This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.

  This method may also be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() when reading any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.

  If this class contains a reference to another object, call DomDoc.registerReferencingObject() to register that reference. This will cause the JGoObject.SVGUpdateReference() to be called on the referencing object after all the objects have been created, passing in the object befing referenced. See DomDoc.registerReferencingObject() for more information.

  Typically, an implementation of this method starts by verifying that the element being read is a <JGoClass> element (which will be true if jGoChildElement is not null). This will always be true unless you have subclassed the DefaultDocument.SVGReadElement() method as described above. It will then read the expected attributes of the <JGoClass> element (as written by SVGReadObject()), call SVGReadObject() on its superclass, and finally return the next element by calling svgElement.getNextSibling().

  Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGReadObject() and com.nwoods.jgo.examples.SimpleNode.SVGReadObject() for examples using this method.

  Specified by:
    `SVGReadObject` in interface `JGoXMLSaveRestore`
  Overrides:
    `SVGReadObject` in class `JGoStroke`

### SVGUpdateReference

    public void SVGUpdateReference(java.lang.String attr,
                                   java.lang.Object referencedObject)

  Description copied from class: `JGoObject`
  This method will be called to fill in object references.

  This is called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() after all the objects have been created and if DomDoc.registerReferencingObject() has been previously called by SVGReadObject().

  Typically, an implementation of this method will first call the superclass and then fill in the appropriate object reference based on the attr argument.

  Refer to com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for an example using this method.

  Overrides:
    `SVGUpdateReference` in class `JGoStroke`

### setDefaultResizingRelinks

    public static void setDefaultResizingRelinks(boolean reuse)

  Change whether the user's dragging the end selection handle points of a link will cause the link to be removed from the document and an entirely new link created by the view, or whether the link will be retained in the document and only its port is modified.

  Parameters:
    `reuse` - if true, user relinking keeps the existing link and just sets one of the link's ports

### isDefaultResizingRelinks

    public static boolean isDefaultResizingRelinks()

  Return whether reconnecting an existing link by dragging its end resize handles just modifies the link or deletes it and starts creating a new link.

  The initial value is true.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD