The pointers represent needles or similar type of indicators within the scale. They are used to visualize a current measurement within the scale. The most important member of the pointer object is its Value. The pointer is automatically adjusted by its containing scale so that it points to the scale location, corresponding to its value.
The size of the pointer is defined by the PointerWidth and PointerHeight properties. These properties can express the size as relative or absolute value. The location of the pointer can be adjusted through the PointerOffset property and its alignment in a linear scale can be specified through the Alignment property.
The pointer can be made interactive by setting the IsInteractive property to true. Clicking with the mouse within a scale causes all its interactive pointers to be adjusted to the value corresponding to the clicked point. A pointer can be made discrete by setting IsDiscrete to true. The value of a discrete pointer is always integer.
The sample code below illustrates how to define and add pointers to an existing scale:
Java Copy Code |
---|
Pointer pointer = new Pointer(); |
The appearance of the pointer can be customized by using the PrepaintPointer and PaintPointer events. The following example demonstrates an oval gauge with a compass needle type of pointer:
Java Copy Code |
---|
OvalGauge gauge = new OvalGauge(); Pointer pointer = new Pointer(); PathFigure figure = new PathFigure("M0.5, 0 L1, 0.5 L0.5, 1 Z"); PathFigure figure1 = new PathFigure("M0.5, 0 L0, 0.5 L0.5, 1 Z"); context.getGraphics().setColor(Color.GRAY); |
The above gauge will look similar to the following image: