AcopDialKnob is a displayer which can show a single double value. The dial knob can be used as a component which controls settable connection points.
The component consists of a round knob which is sensitive to mouse movement. The needle on the knob shows the value of the dial knob. This value is settable by dragging the knob. In addition to this needle there is a black trailer which shows the value read from the remote property. The position of the trailer is not settable through the user interface.
The following lines show an example how to use the features of the AcopDialKnob.
For features shared with other ACOP Beans see this page.
If dial knob is used to show a value that changes because of a 3rd party we don't want the dial knob setter to be out of sync each time the value changes, but want the setter needle to move together with the trailer. We will set the automatic synchronization with 0 sync time
dialKnob.setAutoSynchronize(true); dialKnob.setAutoSynchronizeDelay(0);
or if we don't want to change the values at all (just use the dial knob as a monitor displayer) we can put in read only mode
knob.setEditable(false);
The minimum and maximum values of the dial knob scale can be simply defined with the appropriate setter methods
knob.setMaximum(90); knob.setMinimum(5.2);
When the value received from the 3rd party exceeds the set value bounds (minimum/maximum), the dial knob may visually indicate this by tilting the border.
knob.setTiltingEnabled(true);
In addition, the marker of the dial knob may change color whenever the received value is out of these bounds
knob.setOutOfBoundsColor(Color.YELLOW);
We can define another set of bounds - the warning bounds
knob.setLowWarningLimit(1); knob.setHighWarningLimit(99);
and the color of the marker, when these limits are passed
knob.setWarningColor(Color.ORANGE);
We can finally defined the alarm bounds
knob.setLowAlarmLimit(0); knob.setHighAlarmLimit(100);
and the color of the marker, when these limits are passed
knob.setAlarmColor(Color.RED);
What happens if the remotely received value larger than the maximum displayed scale on the dial knob? We can set a value policy to handle such cases appropriately. We want for the scale to adjust itself (to enlarge) when the value is out of bounds.
RangedValuePolicy rescalingPolicy = new RescalingValuePolicy(); knob.setValuePolicy(rescalingPolicy);
or we want the scale to maintain its range but shift the bounds so that the new value lies between them
RangedValuePolicy shiftPolicy = new ShiftValuePolicy(); knob.setValuePolicy(shiftPolicy);
Other properties of the dial knob can also simply be adjusted by calling the appropriate setter methods. These properties include background/foreground color, title etc.:
knob.setBackground(Color.RED); knob.setForeground(Color.GREEN);
See the complete source code used in this examples.