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.
Constructs an OverviewResizingTool and sets the name for the tool.
Optionalinit: Partial<OverviewResizingTool>Gets or sets the GraphObject that is being resized. 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 ResizingTool, and not during normal operation.
Gets or sets the width and height multiples with which the user must resize.
The effective cell size is computed by first looking at the Adornment.adornedPart's Part.resizeCellSize.
If either or both of its width and height are NaN, it will use this property, cellSize.
If either or both of this property's width and height are NaN, it will
consider the Diagram.grid's Panel.gridCellSize.
The default value is go.Size(NaN, NaN).
Setting this property does not raise any events.
Gets or sets whether the ResizingTool moves the member Parts of a Group that has no Group.placeholder. By default this property is true. Setting this property does not raise any events.
since2.1.26
Returns the GraphObject that is the tool handle being dragged by the user. This will be contained by an Adornment whose category is "ResizingTool". Its Adornment.adornedObject is the same as the adornedObject. This is normally set by doActivate, remembering the result of the call to Tool.findToolHandleAt.
This property is also settable, but should only be set either within an override of doActivate or prior to calling doActivate.
Gets or sets a small GraphObject that is copied as a resizing handle for the selected part. By default this is a Shape that is a small blue rectangle. This ResizingTool will automatically update the GraphObject.cursor property to match the corresponding corners or sides, if it is set to "pointer" or "...resize" in this archetype. Setting this property does not raise any events.
Here is an example of changing the default handle to be larger yellow circles:
myDiagram.toolManager.resizingTool.handleArchetype =
new go.Shape('Circle', { width: 10, height: 10, fill: 'yellow', cursor: 'pointer' });
This property is ignored when a custom resizing Adornment is specified as the Part.resizeAdornmentTemplate. That property is normally null, in which case this tool will automatically construct Adornments holding eight copies of this handle archetype, each with a GraphObject.alignment being one of the standard eight Spots.
Gets or sets whether this tool is started and is actively doing something.
You can set this to true after your tool is started (i.e. when it is the Diagram.currentTool and doStart had been called), but when it is not yet in a state that it is actually "doing" something, because it is waiting for the right circumstances. This is typically only important when the tool is used in a modal fashion.
The default value is false. This is normally set by doActivate and doDeactivate.
Gets or sets whether this tool can be started by a mouse event.
Set this to false to prevent canStart from returning true. Setting this property to false should prevent this tool from being used in a mode-less fashion by the ToolManager with a mouse down/move/up event. However, even when this property is false, this tool can still be used in a modal fashion: it can still be started by explicitly setting the Diagram.currentTool property to this tool.
The default value is true.
Gets or sets whether the ResizingTool snaps object sizes to the diagram's background grid during the resize. By default this property is false. Setting this property does not raise any events.
Gets or sets the maximum size to which the user can resize. The effective maximum size is the minimum of this value and the GraphObject.maxSize, independently in each direction.
The default value is go.Size(9999, 9999).
Any new value must be of type Size; NaN width or height values are treated as Infinity.
Setting this property does not raise any events.
Gets or sets the minimum size to which the user can resize. The effective minimum size is the maximum of this value and the GraphObject.minSize, independently in each direction.
The default value is go.Size(1, 1).
Any new value must be of type Size; NaN width or height values are treated as zero.
Setting this property does not raise any events.
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".
This name is sometimes used by tools that use Adornments as the Part.category for their Adornments. It is also sometimes used by tools that conduct transactions as the transaction name.
Gets or sets the Point opposite to the chosen, dragged handle of the "Resizing" Adornment. This property has no meaning until after doActivate has been called.
since2.2
This property returns the Size that was the original value of the GraphObject.desiredSize of the element that is being resized.
This property returns the Point that was the original value of the Part.location of the Part that is being resized.
Gets or sets the name of the transaction to be committed by stopTransaction
If null, the transaction will be rolled back.
If this is non-null at the time of a call to stopTransaction, it calls Diagram.commitTransaction with this transaction name; if this is null at that time, it calls Diagram.rollbackTransaction.
The default value is null; startTransaction will also set this to null. Because a value of null when stopTransaction is called will rollback the transaction, it is important that your code sets this property to a non-null value when it thinks it has succeeded.
This property exists so that no matter what execution path occurs to end the usage of a tool, any ongoing transaction can be properly committed or rolled-back. Many tools call startTransaction and stopTransaction; thus they set this property for their transaction to be committed. doCancel also sets this property to null.
VirtualcancelThis is called to cancel any running "WaitAfter" timer.
This is called when a tool is stopped.
This method is rarely overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualcanThis tool may run when there is a mouse-down event on a resize handle, the diagram is not read-only and it allows resizing, the left mouse button is being used, and this tool's adornment's resize handle is at the current mouse point.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualcanThis method controls for some Tools whether canStart may return true depending on the button being used. Normally this returns true if InputEvent.left is true. This method may be overridden to consider other buttons, or to ignore which button by just returning true.
true, if the left mouse button is being held down
since4.0
VirtualcanAs of version 4, this predicate method is no longer called by the ToolManager. Most of the responsibility for pinch zooming has been moved to the PanningTool.
deprecatedVirtualcomputeThe size should be a multiple of the value returned by this method.
This is called once when the tool is activated.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualcomputeThe effective maximum resizing size is the minimum of the maxSize and the adornedObject's GraphObject.maxSize.
This is called once when the tool is activated.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualcomputeThe effective minimum resizing size is the maximum of minSize and the adornedObject's GraphObject.minSize.
This is called once when the tool is activated.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualcomputeDecide whether to allow arbitrary reshaping or whether to keep the same aspect ratio of the object being resized. If the adornedObject is a Shape, then if the Shape.geometryStretch is GeometryStretch.Uniform, this method will return false to restrict reshaping to maintain the object's current ratio of height to width. Also, if the user is holding down the Shift key, this method will return false.
This is called on each mouse-move and on mouse-up; the result is passed to the call to resize. This permits the user to change the behavior dynamically during resizing.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
For example, to always keep the object's original aspect ratio, override this method to return false. When initializing a Diagram:
const diagram = new go.Diagram, "myDiagramDiv"
{
"resizingTool.computeReshape": function() { return false; },
// ... rest of Diagram init
})
Or when overriding the method dynamically:
myDiagram.toolManager.resizingTool.computeReshape = function() { return false; }
Your override might want to look at the this.adornedObject.part.data properties to decide whether to allow reshaping.
true to allow any aspect ratio; false to preserve the adornedObject's height/width ratio
VirtualcomputeGiven a Spot in the original bounds of the object being resized and a new Point, compute the new Rect.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
a Point in local coordinates.
the alignment spot of the handle being dragged.
the result of the call to computeMinSize.
the result of the call to computeMaxSize.
the result of the call to computeCellSize.
true if the new size may change the aspect ratio from that of the natural bounds of the adornedObject.
a Rectangle in the adornedObject's local coordinates, not in document coordinates
Find the handle, remember the object's original bounds, save the results of calling computeMinSize, computeMaxSize, and computeCellSize, capture the mouse, and start a transaction.
Normally when this method is called the value of handle will be null, resulting in a call to Tool.findToolHandleAt to find a "Resizing" tool handle, which is then remembered as the value of handle. If when this method is called the value of handle is already set, then there is no need to call Tool.findToolHandleAt, because the programmer has already set up which resize handle they want the user to be resizing.
Restore the original size of the GraphObject.
Stop the current transaction, forget the handle and adornedObject, and release the mouse.
VirtualdoThe 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.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualdoThe diagram will call this method upon a key up event. Implementations of this method can look at Diagram.lastInput to get the key.
By default this method does nothing. This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualdoThe 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.
By default this method checks isActive; if that is false it calls canStart. If that in turn is true, this calls doActivate. This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
Call resize with a new size determined by the current mouse point. This determines the new bounds by calling computeResize.
When this calls computeResize it passes as the reshape argument the result of calling computeReshape. The min, max, and cell arguments will be the saved results of doActivate's calls to computeMinSize, computeMaxSize, and computeCellSize.
Call resize with the final bounds based on the most recent mouse point, commit the transaction, and raise the "PartResized" DiagramEvent. This determines the new bounds by calling computeResize.
When this calls computeResize it passes as the reshape argument the result of calling computeReshape.
VirtualdoThe 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.
By default this method does nothing. (But the ToolManager.doMouseWheel override will call Tool.standardMouseWheel.) This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualdoThe 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.
You should not call this method -- only the Diagram.currentTool property setter should call this method.
By default this method does nothing. This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
If you override this method, it is commonplace to also override doStop to clean up whatever you set up in this method.
VirtualdoThe 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.
You should not call this method -- only the Diagram.currentTool property setter should call this method. If you want to stop a tool unexpectedly, you should call doCancel. If your implementation of a tool wants to stop itself, you should call stopTool.
By default this method does nothing. This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
It is commonplace to override this method in order to clean up whatever you have set up in an override of doStart.
VirtualdoThis 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.
By default this does nothing. This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
The event that caused standardWaitAfter.
VirtualfindThis 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.
This method is very infrequently overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
a Point in document coordinates.
the required Part.category of the Adornment.
VirtualisReturn 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.
This uses the value of ToolManager.dragSize. On touch devices the value is automatically increased to accommodate the unavoidable movement of fingers.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
Optionalfirst: PointPoint in view coordinates, defaults to Diagram.firstInput's InputEvent.viewPoint.
Optionallast: PointPoint in view coordinates, defaults to Diagram.lastInput's InputEvent.viewPoint.
OverrideresizeOverrides go.ResizingTool.resize to resize the overview box via setting the observed diagram's scale.
the intended new rectangular bounds the overview box.
VirtualstandardImplement the standard behavior for mouse clicks, searching for and calling click handler functions on GraphObjects or on Diagram, and raising the corresponding DiagramEvent.
A click on a GraphObject of the diagram will raise one of the following DiagramEvents: "ObjectSingleClicked", "ObjectDoubleClicked", or "ObjectContextClicked". This will also look at the corresponding click property: GraphObject.click, GraphObject.doubleClick, or GraphObject.contextClick. If the value is a function, this will call it, passing the current InputEvent and the GraphObject. If the value is null, it tries looking at the parent GraphObject.panel, and so on, walking up the visual tree until it finds the appropriate function to call. After calling the click function, if the value of InputEvent.handled is false, this method will continue walking up the visual tree looking for more click functions to call. Once it has looked at the top-level object (a Part) for a click function, this method stops.
A click in the background of the diagram will raise one of the following DiagramEvents: "BackgroundSingleClicked", "BackgroundDoubleClicked", or "BackgroundContextClicked". This will also look at the corresponding click property: Diagram.click, Diagram.doubleClick, or Diagram.contextClick. If the value is a function, this will call it, passing the current InputEvent.
This method is not responsible for selecting or deselecting any parts. Call standardMouseSelect for that functionality.
Note that this calls GraphObject.isEnabledObject on the target object; if it returns false, no click action will occur.
The ClickSelectingTool calls this method in its override of doMouseUp in order to raise "click" events. Note that by default GraphObjects in Layers that are Layer.isTemporary will not be "clicked". To change that behavior it is easiest to set GraphObject.isActionable to true on those objects for which you wish to handle "click" events. Then the ActionTool's doMouseUp override will raise the standard "click" events.
This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Learn page on Extensions for how to override methods and how to call this base method.
Optionalnavig: ((a: GraphObject) => T | null) | nullAn optional custom navigation function to find target objects. This argument is passed to Diagram.findObjectAt.
Optionalpred: ((a: T) => boolean) | nullAn optional custom predicate function to find target objects. A null value is effectively the same as a function that always returns true. This argument is passed to Diagram.findObjectAt, unless the value is undefined, which means to use a predicate to consider only objects in layers holding permanent objects.
true if InputEvent.handled had been set to true on the Diagram.lastInput.
VirtualstandardImplement 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.
The GraphObject.mouseEnter property provides a function to call when the mouse first enters an object or any of its contained objects (if the object is actually a Panel).
The GraphObject.mouseLeave property provides a function to call when the mouse leaves an object and all of its contained objects (if the object is actually a Panel).
The GraphObject.mouseOver property and Diagram.mouseOver properties provide functions to call when the mouse moves but stays within the same GraphObject or when the mouse moves in the background of the Diagram.
This method is also responsible for updating the Diagram.currentCursor according to the value of GraphObject.cursor and Diagram.defaultCursor.
This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualstandardImplement the standard behavior for selecting parts with the mouse, depending on the control and shift modifier keys.
Control-clicking on a part will select it if it wasn't already, and will deselect if it had been selected. Shift-clicking on a part will add it to the selection (if it wasn't already). Otherwise, clicking on a part will select it (if it wasn't already).
Note that there are restrictions on selection. For example, a part cannot be selected in this manner if Part.selectable is false, or if Diagram.maxSelectionCount would be exceeded.
A left click in the background of the diagram with no modifier keys clears the selection.
This method does not implement any click event behavior -- that is implemented by standardMouseClick.
The ClickSelectingTool calls this method in its override of doMouseUp in order to change the selection.
This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualstandardImplement the standard behavior for mouse wheel events. ToolManager.doMouseWheel calls this method.
Turning the mouse wheel if Diagram.allowVerticalScroll is true causes the diagram to scroll up or down. If InputEvent.shift and Diagram.allowHorizontalScroll are true, the diagram scrolls left or right.
If InputEvent.control and Diagram.allowZoom are true, turning the mouse wheel changes the diagram's scale, zooming in or out while trying to keep the point in the model at the same point as the mouse.
The value of ToolManager.mouseWheelBehavior affects what operations might occur upon mouse wheel events.
This method may be overridden, but you should consider calling this base method in order to get all of its functionality. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualstandardAs of version 4, this method is no longer called by the ToolManager. Most of the responsibility for pinch zooming has been moved to the PanningTool.
deprecatedVirtualstandardAs of version 4, this method is no longer called by the ToolManager. Most of the responsibility for pinch zooming has been moved to the PanningTool.
deprecatedVirtualstandardThis 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.
This is normally used to implement mouse hover and mouse hold events. If the mouse has moved, it must not have moved beyond the distance as determined by Tool.isBeyondDragSize for it be considered "stationary". So the regular ToolManager.doMouseMove implementation only calls this method when the mouse has moved beyond the drag size.
This method is rarely overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
The delay, in milliseconds.
Optionalevent: InputEventAn optional event that caused this timer. Defaults to Diagram.lastInput. This gets passed on to doWaitAfter.
Call Diagram.startTransaction with the given transaction name. This always sets transactionResult to null.
This is normally called in an override of doActivate, if the tool modifies the model, along with a call to stopTransaction in an override of doDeactivate. Alternatively, you can surround a block of code that sets the transactionResult with calls to startTransaction and stopTransaction.
Optionaltname: stringa string describing the transaction.
the value of the call to Diagram.startTransaction.
VirtualstopIf 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.
If you want to stop the current tool and have it restore the original state, call doCancel. Please read the Learn page on Extensions for how to override methods and how to call this base method.
VirtualstopThis 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.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
the result of the call to rollback or commit the transaction.
VirtualupdateShow an Adornment with the resize handles at points along the edge of the bounds of the selected Part's Part.resizeObject.
First this finds the object in the visual tree of the Part that should get the resize adornment and that the user will be able to resize interactively. It finds the object that has the Part.resizeObjectName property of the Part. If the Part.resizeObjectName property is an empty string, as it is by default, it uses the whole part.
It then builds the adornment, associating it with the chosen resize object. If Part.resizeAdornmentTemplate is non-null, it is copied. Otherwise it constructs a new Adornment with a Placeholder and eight copies of handleArchetype, four at the corners and four at the middle of each side.
This method may be overridden. Please read the Learn page on Extensions for how to override methods and how to call this base method.
The OverviewResizingTool class lets the user resize the box within an overview.
If you want to experiment with this extension, try the Overview Resizing sample.