Fix value slider when mid-point is set perfectly in the middle

This commit is contained in:
SiboVG 2023-01-11 23:44:21 +01:00
parent ea237f0fad
commit e2e9635136

View File

@ -321,7 +321,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
return MAX;
double x;
if (value <= mid.getValue()) {
if ((value <= mid.getValue()) || (quad2 == 0)) { // If quad 2 is 0, the midpoint is perfectly in center
// Use linear scale
//linear0 = min;
//linear1 = (mid-min)/pos;
@ -468,7 +468,10 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
}
public BoundedRangeModel getSliderModel(double min, double mid, double max) {
return new ValueSliderModel(min, mid, max);
if (MathUtil.equals(mid, (max + min)/2.0))
return new ValueSliderModel(min, max);
else
return new ValueSliderModel(min, mid, max);
}
public BoundedRangeModel getSliderModel(double min, double mid, DoubleModel max) {