Class LinkReshapingTool

Extends Tool. The LinkReshapingTool is used to interactively change the route of a Linkby setting its Link.points list.You may want to save the route to the model by using a TwoWay Binding on the "points" property of the Link.

This tool makes use of an Adornment, shown when the adorned Link is selected,that includes some number of reshape handles.This tool conducts a transaction while the tool is active.A successful reshaping will result in a "LinkReshaped" DiagramEvent and a "LinkReshaping" transaction.

For a general discussion of link routing, see:Introduction to Links,Introduction to Link Labels, andIntroduction to Link Connection Points.For customizing the linking tools, see Introduction to the Linking Tools.For a general discussion of validation, see Introduction to Validation.

Constructor Summary Details

Name Description
LinkReshapingTool()

You do not normally need to create an instance of this toolbecause one already exists as the ToolManager.linkReshapingTool, which you can modify.More...

The Tool.name of this tool is "LinkReshaping".

Properties Summary Details

Name, Value Type Description
handle

This read-only property returns the GraphObject that is the tool handle being dragged by the user.More... This will be contained by an Adornment whose category is "LinkReshaping".Its Adornment.adornedPart is the same as the adornedLink.

handleArchetype

Gets or sets a small GraphObject that is copied as a reshape handle at each movable point in the selected link's route.More... By default this is a Shape that is a small blue rectangle.Setting this property does not raise any events.

Here is an example of changing the default handles to be larger yellow circles:

  myDiagram.toolManager.linkReshapingTool.handleArchetype =    $(go.Shape, "Circle",      { width: 10, height: 10, fill: "yellow" });
midHandleArchetype
{GraphObject} 1.2

Gets or sets a small GraphObject that is copied as a resegment handle at each mid-point in the selected Link's route.More... By default this is a Shape that is a small blue diamond.Setting this property does not raise any events.

Here is an example of changing the default handle to be larger cyan triangles:

  myDiagram.toolManager.linkReshapingTool.midHandleArchetype =    $(go.Shape, "Triangle", { width: 10, height: 10, fill: "cyan" });
See also:
originalPoint
{Point} 1.1

This read-only property returns the Point that was the original location of the handle that is being dragged to reshape the Link.

originalPoints
{List.} 1.1

This read-only property returns the List of Points that was the original route of the Link that is being reshaped.More... This List should not be modified; its value is indeterminate until a reshaping has been activated.

Properties borrowed from class Tool:
diagram, isActive, isEnabled, name, transactionResult

Method Summary Details

Name, Return Type Description
canStart()
{boolean}

This tool may run when there is a mouse-down event on a reshape handle.More...

This method may be overridden.

Returns:
{boolean}
computeReshape(p)
{Point}

This is called by doMouseMove and doMouseUp to limit the input pointbefore calling reshape.More...

This method may be overridden.Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Parameters:
{Point} p
the point where the handle is being dragged.
Returns:
{Point} Either the same Point p or one constrained by the reshape behavior to be movedonly vertically or only horizontally.
doActivate()

Start reshaping, if findToolHandleAt finds a reshape handle at the mouse down point.More...

If successful this sets handle to be the reshape handle that it findsand adornedLink to be the Link being routed.It also remembers the original link route (a list of Points) in case this tool is cancelled.And it starts a transaction.

doCancel()

Restore the link route to be the original points and stop this tool.

doDeactivate()

This stops the current reshaping operation with the link route shaped the way it is.

doMouseMove()

Call reshape with a new point determined by the mouseto change the route of the adornedLink.

doMouseUp()

Reshape the route with a point based on the most recent mouse point by calling reshape,and then raise a "LinkReshaped" DiagramEvent before stopping this tool.

getReshapingBehavior(obj)
{EnumValue} 1.3

Get the permitted reshaping behavior for a particular reshape handle.More...

Parameters:
{GraphObject} obj
a reshape handle in the "LinkReshaping" Adornment.
Returns:
{EnumValue} one of LinkReshapingTool.All, .Vertical, .Horizontal, or .None
reshape(newPoint)

Change the route of the adornedLink by moving the point corresponding to the currenthandle to be at the given Point.More... This is called by doMouseMove and doMouseUp with the result of callingcomputeReshape to constrain the input point.

This method respects the orthogonality of the link, if necessary limiting movement along only one axis.To maintain orthogonality it may need to modify more than one point in the route.

This method may be overridden.Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Parameters:
{Point} newPoint
the value of the call to computeReshape.
setReshapingBehavior(obj, behavior)
1.3

Set the permitted reshaping behavior for a particular reshape handle.More...

Parameters:
{GraphObject} obj
a reshape handle in the "LinkReshaping" Adornment.
{EnumValue} behavior
one of LinkReshapingTool.All, .Vertical, .Horizontal, or .None
updateAdornments(part)

Show an Adornment with reshape handles at each of the interesting points of the link's route,if the link is selected and visible and if Part.canReshape is true.More...

This method may be overridden.Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Parameters:
{Part} part
Methods borrowed from class Tool:
cancelWaitAfter, canStartMultiTouch, doKeyDown, doKeyUp, doMouseDown, doMouseWheel, doStart, doStop, doWaitAfter, findToolHandleAt, isBeyondDragSize, standardMouseClick, standardMouseOver, standardMouseSelect, standardMouseWheel, standardPinchZoomMove, standardPinchZoomStart, standardWaitAfter, startTransaction, stopTool, stopTransaction

Constants Summary Details

Name Description
All {EnumValue}

Allow dragging in any direction.

Horizontal {EnumValue}

Allow only horizontal (left-and-right) dragging.

None {EnumValue}

Disallow dragging.

Vertical {EnumValue}

Allow only vertical (up-and-down) dragging.