RotatingTool class

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. 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 Links or Link#paths, so if you want to rotate a label on a Link, make sure to name that label and refer to it as the Part#rotateObjectName.

You can control the point about which the object is rotated by setting Part#rotationSpot. The rotation spot can be computed dynamically by overriding #computeRotationPoint. The value of that method call is saved as #rotationPoint.

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 during rotation ignores these two properties.

This tool makes use of an Adornment that includes a rotation handle. It is shown when the selected Part is Part#rotatable. You can control its direction relative to the #rotationPoint by setting #handleAngle to a multiple of 90 degrees, and its distance from the rotation point by setting #handleDistance. 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.

If you want to programmatically start a user's rotating of the Part#rotateObject of an existing selected node, you can set the #handle property to the rotate handle and then start and activate the tool.

  var node = ...;
  myDiagram.select(node);
  var adorn = node.findAdornment("Rotating");
  var tool = myDiagram.toolManager.rotatingTool;
  // specify the rotation handle of the "Rotating" Adornment of the selected node
  tool.handle = adorn.elt(0);
  myDiagram.currentTool = tool;  // starts the RotatingTool
  tool.doActivate();             // activates the RotatingTool
Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

RotatingTool()
factory

Properties

adornedObject GraphObject?

Available on RotatingTool, provided by the RotatingTool$Typings extension

Gets the GraphObject that is being rotated. This may be the same object as the selected Part or it may be contained within that Part.
getter/setter pair
diagram Diagram

Available on Tool, provided by the Tool$Typings extension

This read-only property returns the Diagram that owns this tool and for which this tool is handling input events.
getter/setter pair
handle GraphObject?

Available on RotatingTool, provided by the RotatingTool$Typings extension

This read-only property returns the GraphObject that is the tool handle being dragged by the user. This will be contained by an Adornment whose category is "RotatingTool". Its Adornment#adornedObject is the same as the #adornedObject.
getter/setter pair
handleAngle num

Available on RotatingTool, provided by the RotatingTool$Typings extension

Gets or sets the spot to locate the Adornment for the rotation handle when it does not have a Placeholder. This assumes the Adornment's location will be at the center of the rotation handle.
getter/setter pair
handleArchetype GraphObject?

Available on RotatingTool, provided by the RotatingTool$Typings extension

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

Available on RotatingTool, provided by the RotatingTool$Typings extension

Gets or sets the spot to locate the Adornment at a particular distance from the #adornedObject. This assumes the Adornment's location will be at the center of the rotation handle.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isActive bool

Available on Tool, provided by the Tool$Typings extension

Gets or sets whether this tool is started and is actively doing something.
getter/setter pair
isEnabled bool

Available on Tool, provided by the Tool$Typings extension

Gets or sets whether this tool can be started by a mouse event.
getter/setter pair
name String

Available on Tool, provided by the Tool$Typings extension

Gets or sets the name of this tool. The default name is an empty string, but the constructor for each instance of a subclass of Tool will initialize it appropriately. For example, the name of the DragSelectingTool is "DragSelecting".
getter/setter pair
originalAngle num

Available on RotatingTool, provided by the RotatingTool$Typings extension

This read-only property returns the angle that was the original value of the GraphObject#angle of the GraphObject that is being rotated. The value is invalid when this tool is not active.
getter/setter pair
rotationPoint Point

Available on RotatingTool, provided by the RotatingTool$Typings extension

Gets or sets the Point at which the axis of the rotation should be. #doActivate saves here the value returned by the call to #computeRotationPoint. The value is invalid when this tool is not active.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapAngleEpsilon num

Available on RotatingTool, provided by the RotatingTool$Typings extension

Gets or sets the the closeness to a desired angle at which the angle is "snapped to".
getter/setter pair
snapAngleMultiple num

Available on RotatingTool, provided by the RotatingTool$Typings extension

Gets or sets the preferred angles for the selected object.
getter/setter pair
transactionResult String?

Available on Tool, provided by the Tool$Typings extension

Gets or sets the name of the transaction to be committed by #stopTransaction
getter/setter pair

Methods

cancelWaitAfter() → void

Available on Tool, provided by the Tool$Typings extension

This is called to cancel any running "WaitAfter" timer.
canStart() bool

Available on RotatingTool, provided by the RotatingTool$Typings extension

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.
canStart() bool

Available on Tool, provided by the Tool$Typings extension

This predicate is used by the ToolManager to decide if this tool can be started mode-lessly by mouse and touch events. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
canStartMultiTouch() bool

Available on Tool, provided by the Tool$Typings extension

Called by ToolManager#doMouseDown and ToolManager#doMouseMove, this method determines whether or not to allow pinch zooming from a multi-touch event. By default this predicate just returns 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. @expose @return {boolean} @see #standardPinchZoomStart @see #standardPinchZoomMove @since 1.5
computeRotate(Point newPoint) num

Available on RotatingTool, provided by the RotatingTool$Typings extension

Compute the new angle given a point. If the Shift key is pressed, this method ignores the #snapAngleMultiple and #snapAngleEpsilon.
computeRotationPoint(GraphObject obj) Point

Available on RotatingTool, provided by the RotatingTool$Typings extension

Compute the Point about which things should rotate. This is called when this tool is activated and sometimes when updating the Adornment. The value of the call is remembered as #rotationPoint. @expose @param {GraphObject} obj the Part#rotateObject @return {Point}
doActivate() → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

Capture the mouse, remember the original GraphObject#angle, and start a transaction.
doActivate() → void

Available on Tool, provided by the Tool$Typings extension

The Diagram calls this method after setting Diagram#currentTool, to make the new tool active. This should set #isActive to true. Overrides of this method might call #startTransaction, if this tool's activity involves modification of the model. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
doCancel() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method when the user wishes to cancel the current tool's operation. Typically this is called when the user hits the ESCAPE key. This should restore the original state of what was modified by this tool, and then it should call #stopTool. This method is not responsible for cleaning up any side-effects that should be performed by #doDeactivate and/or #doStop, which will always be called whether the tool stops normally or abnormally.
doCancel() → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

Restore the original GraphObject#angle of the adorned object.
doDeactivate() → void

Available on Tool, provided by the Tool$Typings extension

The Diagram calls this method on the old tool when Diagram#currentTool is set to a new tool. This needs to set #isActive to false. Overrides of this method might call #stopTransaction, if this tool's activity involves modification of the model.
doDeactivate() → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

Stop the current transaction, forget the #handle and #adornedObject, and release the mouse.
doKeyDown() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method upon a key down event. By default this just calls #doCancel if the key is the ESCAPE key. Implementations of this method can look at Diagram#lastInput to get the key.
doKeyUp() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method upon a key up event. Implementations of this method can look at Diagram#lastInput to get the key.
doMouseDown() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method upon a mouse down event. This is normally overridden for mouse-down tools; it is not called for mouse-move or mouse-up tools. However it may also be called when the tool is run in a modal fashion, when code explicitly sets the diagram's Diagram#currentTool. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
doMouseMove() → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

Call #rotate with a new angle determined by the current mouse point. This determines the new angle by calling #computeRotate.
doMouseMove() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method upon a mouse move event. This is normally overridden for mouse-move tools; it is not called for mouse-up tools. However it may also be called when the tool is run in a modal fashion, when code explicitly sets the diagram's Diagram#currentTool. An override of this method usually does nothing when #isActive is false. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
doMouseUp() → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

Call #rotate with an angle based on the most recent mouse point, commit the transaction, and raise the "PartRotated" DiagramEvent.
doMouseUp() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method upon a mouse up event. This is normally overridden for mouse-up tools. An override of this method usually does nothing when #isActive is false, except for calling #stopTool. Tools normally stop upon a mouse up, by calling #stopTool. If you want to handle multiple mouse down-up gestures in one tool activation, you will need to override this method to only stop the tool when you want. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
doMouseWheel() → void

Available on Tool, provided by the Tool$Typings extension

The diagram will call this method as the mouse wheel is rotated. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
doStart() → void

Available on Tool, provided by the Tool$Typings extension

The Diagram calls this method when this tool becomes the current tool; you should not call this method. Tool implementations should perform their per-use initialization here, such as setting up internal data structures, or capturing the mouse. Implementations of this method can look at Diagram#lastInput to get the mouse event and input state.
doStop() → void

Available on Tool, provided by the Tool$Typings extension

The Diagram calls this method when this tool stops being the current tool; you should not call this method. Tool implementations should perform their per-use cleanup here, such as releasing mouse capture.
doWaitAfter(InputEvent event) → void

Available on Tool, provided by the Tool$Typings extension

This is called a certain delay after a call to #standardWaitAfter if there has not been any call to #cancelWaitAfter. The ToolManager overrides this method in order to implement support for mouse-hover behavior and tooltips.
findToolHandleAt(Point p, String category) GraphObject?

Available on Tool, provided by the Tool$Typings extension

This convenience function finds the front-most GraphObject that is at a given point and that is an element of an Adornment that is of a given category. The tool handle must be an immediate element of the Adornment, not a GraphObject that is nested within Panels within the Adornment.
isBeyondDragSize([Point? first, Point? last]) bool

Available on Tool, provided by the Tool$Typings extension

Return true when the last mouse point is far enough away from the first mouse down point to constitute a drag operation instead of just a potential click.
makeAdornment(GraphObject rotateObj) Adornment?

Available on RotatingTool, provided by the RotatingTool$Typings extension

(undocumented) Create and return an Adornment that lets the user grab a handle to rotate an object in the selected part. Please read the Introduction page on Extensions for how to override methods and how to call this base method. @expose @param {GraphObject} rotateObj the GraphObject being rotated. @return {Adornment}
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rotate(num newangle) → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

Change the angle of the selected part's Part#rotateObject. This modifies its GraphObject#angle.
standardMouseClick<T extends GraphObject>([T? navig(GraphObject)?, bool pred(T)?]) bool

Available on Tool, provided by the Tool$Typings extension

Implement the standard behavior for mouse clicks, searching for and calling click handler functions on GraphObjects or on Diagram, and raising the corresponding DiagramEvent.
standardMouseOver() → void

Available on Tool, provided by the Tool$Typings extension

Implement the standard behavior for mouse enter, over, and leave events, where the mouse is moving but no button is pressed. This should be called by mouse move event handlers when wanting to detect and invoke mouse enter/over/leave event handlers.
standardMouseSelect() → void

Available on Tool, provided by the Tool$Typings extension

Implement the standard behavior for selecting parts with the mouse, depending on the control and shift modifier keys.
standardMouseWheel() → void

Available on Tool, provided by the Tool$Typings extension

Implement the standard behavior for mouse wheel events. ToolManager#doMouseWheel calls this method.
standardPinchZoomMove() → void

Available on Tool, provided by the Tool$Typings extension

Continues pinch-zooming (started by #standardPinchZoomStart on multi-touch devices.
standardPinchZoomStart() → void

Available on Tool, provided by the Tool$Typings extension

Initiates pinch-zooming on multi-touch devices.
standardWaitAfter(num delay, [InputEvent? event]) → void

Available on Tool, provided by the Tool$Typings extension

This is called to start a new timer to call #doWaitAfter after a given delay. It first cancels any previously running "WaitAfter" timer, by calling #cancelWaitAfter.
startTransaction([String? tname]) bool

Available on Tool, provided by the Tool$Typings extension

Call Diagram#startTransaction with the given transaction name. This always sets #transactionResult to null.
stopTool() → void

Available on Tool, provided by the Tool$Typings extension

If the Diagram#currentTool is this tool, stop this tool and start the Diagram#defaultTool by making it be the new current tool. The implementation of various tool methods can call this method to stop the current tool. This will call #doStop -- you should not call that method directly.
stopTransaction() bool

Available on Tool, provided by the Tool$Typings extension

If #transactionResult is null, call Diagram#rollbackTransaction, otherwise call Diagram#commitTransaction.
stopTransaction() bool

Available on RotatingTool, provided by the RotatingTool$Typings extension

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.
toString() String
A string representation of this object.
inherited
updateAdornments(Part part) → void

Available on Tool, provided by the Tool$Typings extension

The diagram asks each tool to update any adornments the tool might use for a given part. If the tool uses its own tool handles, this should display them or hide them as appropriate. Typically this should only show them if the part is selected.
updateAdornments(Part part) → void

Available on RotatingTool, provided by the RotatingTool$Typings extension

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.

Operators

operator ==(Object other) bool
The equality operator.
inherited