# Class GeometryReshapingTool

GoJS® Diagramming Components
version 3.0.5
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

#### Hierarchy

- Tool
  - GeometryReshapingTool

The GeometryReshapingTool class allows for a Shape's Geometry to be modified by the user via the dragging of tool handles. This does not handle Links, whose routes should be reshaped by the LinkReshapingTool. The reshapeObjectName needs to identify the named go.Shape within the selected go.Part. If the shape cannot be found or if its go.Shape.geometry is not of type go.GeometryType.Path, this will not show any GeometryReshaping go.Adornment. At the current time this tool does not support adding or removing go.PathSegments to the Geometry.

If you want to experiment with this extension, try the Geometry Reshaping sample.

#####
Index

### Constructors

constructor

### Accessors

adornedShape
handle
handleArchetype
isResegmenting
midHandleArchetype
originalGeometry
resegmentingDistance
reshapeObjectName

### Methods

canStart
computeReshape
doActivate
doCancel
doDeactivate
doMouseMove
doMouseUp
reshape
updateAdornments

#####
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
Tool.stopTransaction

## Constructors

### constructor

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

- Constructs a GeometryReshapingTool and sets the handle and name of the tool.

  #### Parameters

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

  #### Returns GeometryReshapingTool

## Accessors

### `Readonly` adornedShape
: Shape

- Gets the go.Shape that is being reshaped. This must be contained within the selected Part.

### handle
: GraphObject

- This read-only property returns the go.GraphObject that is the tool handle being dragged by the user. This will be contained by an go.Adornment whose category is 'GeometryReshaping'. Its go.Adornment.adornedObject is the same as the adornedShape.

### handleArchetype
: GraphObject

- A small GraphObject used as a reshape handle for each segment. The default GraphObject is a small blue diamond.

### isResegmenting
: boolean

- Gets or sets whether this tool supports the user's addition or removal of segments in the geometry. The default value is false. When the value is true, copies of the midHandleArchetype will appear in the middle of each segment. At the current time, resegmenting is limited to straight segments, not curved ones.

### midHandleArchetype
: GraphObject

- A small GraphObject used as a reshape handle at the middle of each segment for inserting a new segment. The default GraphObject is a small blue circle.

### `Readonly` originalGeometry
: Geometry

- This read-only property remembers the original value for go.Shape.geometry, so that it can be restored if this tool is cancelled.

### resegmentingDistance
: number

- The maximum distance at which a resegmenting handle being positioned on a straight line between the adjacent points will cause one of the segments to be removed from the geometry. The default value is 3.

### reshapeObjectName
: string

- The name of the GraphObject to be reshaped. The default name is 'SHAPE'.

## Methods

### `Override` canStart

- canStart(): boolean

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

  #### Returns boolean

### computeReshape

- computeReshape(p: Point): Point

- This is called by doMouseMove and doMouseUp to limit the input point before calling reshape. By default, this doesn't limit the input point.

  #### Parameters

  - ##### p: Point

    the point where the handle is being dragged.

  #### Returns Point

### `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 adornedShape to be the go.Shape being reshaped. It also remembers the original geometry in case this tool is cancelled. And it starts a transaction.

  #### Returns void

### `Override` doCancel

- doCancel(): void

- Restore the shape to be the original geometry and stop this tool.

  #### Returns void

### `Override` doDeactivate

- doDeactivate(): void

- This stops the current reshaping operation with the Shape as it is.

  #### Returns void

### `Override` doMouseMove

- doMouseMove(): void

- Call reshape with a new point determined by the mouse to change the geometry of the adornedShape.

  #### Returns void

### `Override` doMouseUp

- doMouseUp(): void

- Reshape the Shape's geometry with a point based on the most recent mouse point by calling reshape, and then stop this tool.

  #### Returns void

### reshape

- reshape(newPoint: Point): void

- Change the geometry of the adornedShape by moving the point corresponding to the current handle to be at the given go.Point. This is called by doMouseMove and doMouseUp with the result of calling computeReshape to constrain the input point.

  #### Parameters

  - ##### newPoint: Point

    the value of the call to computeReshape.

  #### Returns void

### `Override` updateAdornments

- updateAdornments(part: Part): void

- Show an go.Adornment with a reshape handle at each point of the geometry. Don't show anything if reshapeObjectName doesn't return a go.Shape that has a go.Shape.geometry of type go.GeometryType.Path.

  #### Parameters

  - ##### part: Part

  #### Returns void

Copyright © 1998-2024 by Northwoods Software Corporation.