Class RotatingTool

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

This tool allows the user to rotate the Part.rotateObject of the selected Part.The Part must be Part.rotatable, which is false by default.Normally this works with Parts or Nodes; it does not make sense for whole Linksor Link.paths, so if you want to rotate a label on a Link, make sure to name that labeland refer to it as the Part.rotateObjectName.

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.

For customizing the RotatingTool, see Introduction to the RotatingTool.

Constructor Summary Details

Name Description
RotatingTool()

You do not normally need to create an instance of this toolbecause 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 functionsin 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.angleof 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 degreesof a multiple of the snapAngleMultiple automaticallysnaps to that multiple.Values are limited to half of the snapAngleMultiple;such values restrict user selected angles only to exact multiples ofsnapAngleMultiple -- 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 multiplesof 45 degrees are automatically preferred, if the actual angle isclose 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 objectif 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