Class RotatingTool

Extends Tool. The RotatingTool is used to interactively change the GraphObject.angle of a GraphObject by setting its GraphObject.angle property. You may want to save the angle to the model by using a TwoWay Binding on the "angle" property of the GraphObject that is named by Part.rotateObjectName.

This tool allows the user to rotate the Part.rotateObject of the selected Part. Normally this works with Parts or Nodes; it does not make sense for Links. The Part must be Part.rotatable, which is false by default.

You can limit the permitted angles by setting snapAngleMultiple and snapAngleEpsilon. For example, if you want to permit only angles that are multiples of 90 degrees, set snapAngleMultiple to 90 and snapAngleEpsilon to 45. Pressing the Shift key ignores these properties.

This tool makes use of an Adornment that includes a rotation handle. It is shown when the selected Part is Part.rotatable. The rotate handle is normally a copy of RotatingTool.handleArchetype. unless you specify a custom rotate Adornment by setting Part.rotateAdornmentTemplate.

This tool conducts a transaction while the tool is active. A successful rotation will result in a "PartRotated" DiagramEvent and a "Rotating" transaction.

Constructor Summary Details

Name Description
RotatingTool()

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

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

Properties Summary Details

Name, Value Type Description
adornedObject

Gets the GraphObject that is being rotated.More... This may be the same object as the selected Part or it may be contained within that Part.

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

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

handleArchetype

Gets or sets a small GraphObject that is copied as a rotation handle for the selected part.More... By default this is a Shape that is a small yellow circle. Setting this property does not raise any events.

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

  myDiagram.toolManager.rotatingTool.handleArchetype =
    $(go.Shape, "XLine",
      { width: 8, height: 8, stroke: "green", fill: "transparent" });

This property is ignored when a custom rotating Adornment is specified as the Part.rotateAdornmentTemplate.

originalAngle
{number} 1.1

This read-only property returns the angle that was the original value of the GraphObject.angle of the GraphObject that is being rotated.

snapAngleEpsilon
{number}

Gets or sets the the closeness to a desired angle at which the angle is "snapped to".More...

The default value is 2 degrees, meaning that any angle within 2 degrees of a multiple of the snapAngleMultiple automatically snaps to that multiple. Values are limited to half of the snapAngleMultiple; such values restrict user selected angles only to exact multiples of snapAngleMultiple -- no other angles between them. Setting this property does not raise any events.

snapAngleMultiple
{number}

Gets or sets the preferred angles for the selected object.More...

The default value is 45 degrees, meaning that angles that are multiples of 45 degrees are automatically preferred, if the actual angle is close to that multiple. The closeness is determined by the snapAngleEpsilon property. A value of zero for snapAngleMultiple results in no snapping at all. Setting this property does not raise any events.

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 rotate handle, the diagram is not read-only and it allows rotation, the left mouse button is being used, and this tool's adornment's rotate handle is at the current mouse point.More...

This method may be overridden.

Returns:
{boolean}
computeRotate(newPoint)
{number}

Compute the new angle given a point.More... If the Shift key is pressed, this method ignores the snapAngleMultiple and snapAngleEpsilon.

If the angle is close (by snapAngleEpsilon degrees) to a multiple of snapAngleMultiple degrees, make it exactly that multiple.

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
in document coordinates.
Returns:
{number} the new angle, in degrees.
doActivate()

Capture the mouse, remember the original GraphObject.angle, and start a transaction.

doCancel()

Restore the original GraphObject.angle of the adorned object.

doDeactivate()

Stop the current transaction and release the mouse.

doMouseMove()

Call rotate with a new angle determined by the current mouse point.More... This determines the new angle by calling computeRotate.

doMouseUp()

Call rotate with an angle based on the most recent mouse point, commit the transaction, and raise the "PartRotated" DiagramEvent.

rotate(newangle)

Change the angle of the selected part's Part.rotateObject.More... This modifies its GraphObject.angle.

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:
{number} newangle
in degrees.
updateAdornments(part)

Show an Adornment with a rotate handle at a point to the side of the adorned object if the part is selected and visible and if Part.canRotate() 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
the 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