# Class RescalingTool

GoJS® Diagramming Components
version 3.0.7
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
  - RescalingTool

A custom tool for rescaling an object.

Install the RescalingTool as a mouse-down tool by calling: myDiagram.toolManager.mouseDownTools.add(new RescalingTool());

Normally it would not make sense for the same object to be both resizable and rescalable.

Note that there is no `Part.rescaleObjectName` property and there is no `Part.rescalable` property. So although you cannot customize any Node to affect this tool, you can set RescalingTool.rescaleObjectName and set RescalingTool.isEnabled to control whether objects are rescalable and when.

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

#####
Index

### Constructors

constructor

### Accessors

adornedObject
handle
handleArchetype
rescaleObjectName

### Methods

canStart
computeScale
doActivate
doCancel
doDeactivate
doMouseMove
doMouseUp
findRescaleObject
makeAdornment
scale
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 RescalingTool(init?: Partial<RescalingTool>): RescalingTool

- #### Parameters

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

  #### Returns RescalingTool

## Accessors

### adornedObject
: GraphObject

- Gets the go.GraphObject that is being rescaled. This may be the same object as the selected go.Part or it may be contained within that Part.

  This property is also settable, but should only be set when overriding functions in RescalingTool, and not during normal operation.

### handle
: GraphObject

- This 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 "RescalingTool". Its go.Adornment.adornedObject is the same as the adornedObject.

  This property is also settable, but should only be set either within an override of doActivate or prior to calling doActivate.

### handleArchetype
: GraphObject

- Gets or sets a small GraphObject that is copied as a rescale handle for the selected part. By default this is a go.Shape that is a small blue square. Setting this property does not raise any events.

  Here is an example of changing the default handle to be green "X":

        tool.handleArchetype =
          new go.Shape("XLine",
            { width: 8, height: 8, stroke: "green", fill: "transparent" })

### rescaleObjectName
: string

- This property returns the name of the GraphObject that identifies the object to be rescaled by this tool.

  The default value is the empty string, resulting in the whole Node being rescaled. This property is used by findRescaleObject when calling go.Panel.findObject.

## Methods

### `Override` canStart

- canStart(): boolean

- This tool can start running if the mouse-down happens on a "Rescaling" handle.

  #### Returns boolean

### computeScale

- computeScale(newPoint: Point): number

- Compute the new scale given a point.

  This method is called by both doMouseMove and doMouseUp. 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

    in document coordinates

  #### Returns number

### `Override` doActivate

- doActivate(): void

- Activating this tool remembers the handle that was dragged, the adornedObject that is being rescaled, starts a transaction, and captures the mouse.

  #### Returns void

### `Override` doCancel

- doCancel(): void

- Restore the original go.GraphObject.scale of the adorned object.

  #### Returns void

### `Override` doDeactivate

- doDeactivate(): void

- Stop the current transaction, forget the handle and adornedObject, and release the mouse.

  #### Returns void

### `Override` doMouseMove

- doMouseMove(): void

- Call scale with a new scale determined by the current mouse point. This determines the new scale by calling computeScale.

  #### Returns void

### `Override` doMouseUp

- doMouseUp(): void

- Call scale with a new scale determined by the most recent mouse point, and commit the transaction.

  #### Returns void

### findRescaleObject

- findRescaleObject(part: Part): GraphObject

- Return the GraphObject to be rescaled by the user.

  #### Parameters

  - ##### part: Part

  #### Returns GraphObject

### makeAdornment

- makeAdornment(rescaleObj: GraphObject): Adornment

- #### Parameters

  - ##### rescaleObj: GraphObject

  #### Returns Adornment

### scale

- scale(newScale: number): void

- Set the go.GraphObject.scale of the findRescaleObject.

  #### Parameters

  - ##### newScale: number

  #### Returns void

### `Override` updateAdornments

- updateAdornments(part: Part): void

- #### Parameters

  - ##### part: Part

  #### Returns void

Copyright © 1998-2024 by Northwoods Software Corporation.