|
How to prevent wrap around on meters |
Posted by Matt on Mar-07-2013 01:47 |
|
Is there a way to prevent a meter from showing a value that is outside of the min and max on the scale? So basically the meter would act like a speedometer and have a peg at 0 and another peg at the max. Currently it appears that the meter just wraps around, so if the max was 100 and the value given to the meter was 450 it would wrap around 4 times and then show a value of 50. I would like it to show 100, maybe with a special effect to show it exceeded the limit.
Thanks |
Re: How to prevent wrap around on meters |
Posted by Peter Kwan on Mar-07-2013 23:42 |
|
Hi Matt,
You can directly perform what you mention in your code. For example, if you want the value greater than 100 to be displayed as 100, then you can write code to check if the value is greater than 100 and to display that as 100 (or to perform any special effect you want).
For example, in Java, in the original "Semi-Circle Meter" sample code, the pointer is added using:
m.addPointer(value, 0x40666699, 0x000000);
If you want value > 100 to point to 100, in C#/Java, the code is:
m.addPointer(Math.min(100, value), 0x40666699, 0x000000);
Other programming langauges should have similar features.
Hope this can help.
Regards
Peter Kwan |
Re: How to prevent wrap around on meters |
Posted by Peter Kwan on Mar-07-2013 23:56 |
|
Hi Matt,
As an example of the "special effect", you may use something like:
if (value > 100)
.... add a red pointer at 100 ....
else
.... add a blue pointer at the specified value ....
Hope this can help.
Regards
Peter Kwan |
|