# Class LinkReshapingTool

GoJS® Diagramming Components
version 3.0.14
by Northwoods Software®

#### Hierarchy

- Tool
  - LinkReshapingTool
    - CurvedLinkReshapingTool
    - OrthogonalLinkReshapingTool
    - SnapLinkReshapingTool

The LinkReshapingTool is used to interactively change the route of a Link by 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, and Introduction 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.

#####
Index

### Constructors

constructor

### Accessors

adornedLink
handle
handleArchetype
midHandleArchetype
originalPoint
originalPoints
resegmentingDistance

### Methods

canStart
computeReshape
doActivate
doCancel
doDeactivate
doMouseMove
doMouseUp
getReshapingBehavior
reshape
setReshapingBehavior
stopTransaction
updateAdornments

### Properties

All
Horizontal
None
Vertical

#####
Inherited Index

### Accessors

Tool.diagram
Tool.isActive
Tool.isEnabled
Tool.name
Tool.transactionResult

### Methods

Tool.canStartMultiTouch
Tool.cancelWaitAfter
Tool.doKeyDown
Tool.doKeyUp
Tool.doMouseDown
Tool.doMouseWheel
Tool.doStart
Tool.doStop
Tool.doWaitAfter
Tool.findToolHandleAt
Tool.isBeyondDragSize
Tool.standardMouseClick
Tool.standardMouseOver
Tool.standardMouseSelect
Tool.standardMouseWheel
Tool.standardPinchZoomMove
Tool.standardPinchZoomStart
Tool.standardWaitAfter
Tool.startTransaction
Tool.stopTool

## Constructors

### constructor

- new LinkReshapingTool(init?: Partial<LinkReshapingTool>): LinkReshapingTool

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

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

  #### Parameters

  - ##### `Optional` init: Partial<LinkReshapingTool>

  #### Returns LinkReshapingTool

## Accessors

### `Readonly` adornedLink
: Link

- This read-only property returns the Link that is being routed manually.

### handle
: GraphObject

- Returns the GraphObject that is the tool handle being dragged by the user. This will be contained by an Adornment whose category is "LinkReshaping". Its Adornment.adornedPart is the same as the adornedLink. This is normally set by doActivate, remembering the result of the call to Tool.findToolHandleAt.

### handleArchetype
: GraphObject

- Gets or sets a small GraphObject that is copied as a reshape handle at each movable point in the selected link's route. 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 =
        new go.Shape('Circle', { width: 10, height: 10, fill: 'yellow' });

  `see`

  midHandleArchetype

### midHandleArchetype
: GraphObject

- Gets or sets a small GraphObject that is copied as a resegment handle at each mid-point in the selected Link's route. 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 =
        new go.Shape('Triangle', { width: 10, height: 10, fill: 'cyan' });

  `see`

  handleArchetype

### `Readonly` originalPoint
: Point

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

### `Readonly` originalPoints
: List<Point>

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

### resegmentingDistance
: number

- Gets or sets the distance from a straight line that controls whether a Link.resegmentable Link segment is kept as a separate segment or removed to form a straight segment of the adjacent points.

  The default value is 3.

  `since`

  3.0

## Methods

### `Virtual` `Override` canStart

- canStart(): boolean

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

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

  #### Returns boolean

### `Virtual` computeReshape

- computeReshape(p: Point): Point

- This is called by doMouseMove and doMouseUp to limit the input point before calling reshape.

  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

  - ##### p: Point

    the point where the handle is being dragged.

  #### Returns Point

  Either the same Point p or one constrained by the reshape behavior to be moved only vertically or only horizontally.

### `Override` doActivate

- doActivate(): void

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

  If successful this sets handle to be the reshape handle that it finds and 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.

  #### Returns void

### `Override` doCancel

- doCancel(): void

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

  #### Returns void

### `Override` doDeactivate

- doDeactivate(): void

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

  #### Returns void

### `Override` doMouseMove

- doMouseMove(): void

- Call reshape with a new point determined by the mouse to change the route of the adornedLink.

  #### Returns void

### `Override` doMouseUp

- doMouseUp(): void

- 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.

  #### Returns void

### `Protected` getReshapingBehavior

- getReshapingBehavior(obj: GraphObject): ReshapingBehavior

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

  #### Parameters

  - ##### obj: GraphObject

    a reshape handle in the "LinkReshaping" Adornment.

  #### Returns ReshapingBehavior

  a ReshapingBehavior value

### `Virtual` reshape

- reshape(newPoint: Point): void

- Change the route of the adornedLink by moving the point corresponding to the current handle to be at the given Point. This is called by doMouseMove and doMouseUp with the result of calling computeReshape 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

  - ##### newPoint: Point

    the value of the call to computeReshape.

  #### Returns void

### `Protected` setReshapingBehavior

- setReshapingBehavior(obj: GraphObject, behavior: ReshapingBehavior): void

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

  #### Parameters

  - ##### obj: GraphObject

    a reshape handle in the "LinkReshaping" Adornment.

  - ##### behavior: ReshapingBehavior

    one of ReshapingBehavior.All, .Vertical, .Horizontal, or .None

  #### Returns void

### `Virtual` `Override` stopTransaction

- stopTransaction(): boolean

- This calls the super Tool.stopTransaction method, and if the result is `true`, attempts to optimize the transaction by removing all changes except the first and last by calling Transaction.optimize.

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

  #### Returns boolean

  the result of the call to rollback or commit the transaction.

### `Virtual` `Override` updateAdornments

- updateAdornments(part: Part): void

- 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.

  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

  #### Returns void

## Properties

### `Static` `Readonly` All

`deprecated`

See ReshapingBehavior.All.

### `Static` `Readonly` Horizontal

`deprecated`

See ReshapingBehavior.Horizontal.

### `Static` `Readonly` None

`deprecated`

See ReshapingBehavior.None.

### `Static` `Readonly` Vertical

`deprecated`

See ReshapingBehavior.Vertical.

Copyright © 1998-2024 by Northwoods Software Corporation.