controlP5 slider - multiple calls to setNumberOfTickMarks issue
in
Contributed Library Questions
•
2 years ago
Just noticed something odd with the way the slider handles tick marks. I have 2 sets of sliders, one which sets a maximum value for an array of others. When the new maximum value is set, the tick marks should also change so that I get the correct number jumps between ticks on the second set. The problem I have found is that tick marks are never removed, only added. Perhaps somebody could offer another method of achieving what I want, or a solution for removing tick marks.
In this situation, the only time the number of ticks before is different then after is if there are more ticks.
- void max_RPM(int theRPM)
- {
- for(int i=0; i<16; i++)
- {
- println("number of ticks before: " + led[i].getNumberOfTickMarks());
- led[i].setMax(theRPM);
- led[i].setNumberOfTickMarks(theRPM/250+1);
- println("number of ticks after: " + led[i].getNumberOfTickMarks());
- }
- }
The code from controlP5 Slider.java for new tick marks:
- protected ArrayList<TickMark> _myTickMarks;
- public void setNumberOfTickMarks(int theNumber) {
- //Added by Swingline to RESET ticks
- //this isn't elegant but....
- _myTickMarks.clear();
- _myTickMarks.trimToSize();
- int n = theNumber - _myTickMarks.size();
- if (n <= theNumber) {
- for (int i = 0; i < n; i++) {
- _myTickMarks.add(new TickMark(this));
- }
- }
I tried using the ArrayList functions clear, remove, trimToSize none worked at removing the tick marks.
2