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. Extensions can be found in the GoJS kit under the
extensions (for loading via script tags),
extensionsTS (UMD modules), or
extensionsJSM (ES6 modules) folders. See the Extensions intro page for more information.
The FreehandDrawingTool allows the user to draw a shape using the mouse. It collects all of the points from a mouse-down, all mouse-moves, until a mouse-up, and puts all of those points in a Geometry used by a Shape. It then adds a node data object to the diagram's model.
This tool may be installed as the first mouse down tool:
myDiagram.toolManager.mouseDownTools.insertAt(0, new FreehandDrawingTool());
If you want to experiment with this extension, try the Freehand Drawing sample.
Don't construct this directly -- this is an abstract class.
Gets or sets the node data object that is copied and added to the model when the freehand drawing operation completes.
Gets or sets whether this tool can only run if the user starts in the diagram's background rather than on top of an existing Part.
The default value is true.
Gets or sets the Shape that is used to hold the line as it is being drawn.
The default value is a simple Shape drawing an unfilled open thin black line.
Only start if the diagram is modifiable and allows insertions. OPTIONAL: if the user is starting in the diagram's background, not over an existing Part.
Capture the mouse and use a "crosshair" cursor.
Release the mouse and reset the cursor.
Start drawing the line by starting to accumulate points in the temporaryShape's geometry.
Keep accumulating points in the temporaryShape's geometry.
Finish drawing the line by adding a node data object holding the geometry string and the node position that the node template can bind to. This copies the archetypePartData and adds it to the model.