Instruments are Panels that include:
Optionally there are other TextBlocks or Shapes that show additional information. Indicators can be Shapes or TextBlocks or more complicated Panels. For more about scales, please read Graduated Panels. For simplicity, all of these instruments only show one value. But you could define instruments that show multiple values on the same scale, or that have multiple scales.
When an instrument is also a control, the user can modify the instrument's value. When the instrument is editable, there may be a handle that the user can drag. This might be the same as the indicator or might be a different object.
This sample defines five different types of instruments.
The value to be shown by the instrument is assumed to be the data.value
property.
The value is shown both textually in a TextBlock and graphically using an indicator on the
scale. If the value of data.editable
is true,
Of course you can change the details of anything you want to use. You might want to add more TextBlocks to show more information. A few properties already have data Bindings, such as:
data.text
, for the name of the instrumentdata.min
, to control the range of the scaledata.max
, to control the range of the scaledata.color
, to control some colors used by the instrumentThe GoJS Geometry class controls the "shape" of a Shape, whereas the Shape.fill and Shape.stroke and other shape properties control the colors and appearance of the shape. For common shape figures, there are predefined geometries that can be used by setting Shape.figure. However one can also define custom geometries.
One can construct any Geometry by allocating and initializing a Geometry of at least one PathFigure holding some PathSegments. But you may find that using the string representation of a Geometry is easier to write and save in a database. Use the static method Geometry.parse or the Shape.geometryString property to transform a geometry path string into a Geometry object.
More information can be found in the GoJS Intro.
Tools handle all input events, such as mouse and keyboard interactions, in a Diagram. There are many kinds of predefined Tool classes that implement all of the common operations that users do.
For flexibility and simplicity, all input events are canonicalized as InputEvents and redirected by the diagram to go to the Diagram.currentTool. By default the Diagram.currentTool is an instance of ToolManager held as the Diagram.toolManager. The ToolManager implements support for all mode-less tools. The ToolManager is responsible for finding another tool that is ready to run and then making it the new current tool. This causes the new tool to process all of the input events (mouse, keyboard, and touch) until the tool decides that it is finished, at which time the diagram's current tool reverts back to the Diagram.defaultTool, which is normally the ToolManager, again.
More information can be found in the GoJS Intro.