Bug 3397 - move logic to super class

Change-Id: I9674f3c39d9c1e1bb64727736089c3f0d19d59b5
This commit is contained in:
Alexander Tatarinovich committed 2016-08-24 14:23:32 +03:00
1 parent 5fdf4366e1
commit 8fed0aeb1f
2 files changed
+10 -34

No files matched your search

@@ -655,17 +655,21 @@ public class SliderBar extends FocusPanel implements RequiresResize, HasValue<Do
if (!isMinMaxInitialized() || curValue == null) {
return;
}
this.curValue = Math.max(minValue, Math.min(maxValue, curValue));
double remainder = (this.curValue - minValue) % stepSize;
this.curValue -= remainder;
Double newValue = Math.max(minValue, Math.min(maxValue, curValue));
double remainder = (newValue - minValue) % stepSize;
newValue -= remainder;
// Go to next step if more than halfway there
if ((remainder > (stepSize / 2)) && ((this.curValue + stepSize) <= maxValue)) {
this.curValue += stepSize;
if ((remainder > (stepSize / 2)) && ((newValue + stepSize) <= maxValue)) {
newValue += stepSize;
}
boolean isValueChanged = !newValue.equals(this.curValue) && this.curValue != null;
this.curValue = newValue;
// Redraw the knob
drawKnob();
// Fire the ValueChangeEvent if the value actually changed
if (fireEvent && !curValue.equals(this.curValue)) {
if (fireEvent && isValueChanged) {
ValueChangeEvent.fire(this, this.curValue);
}
}
@@ -96,34 +96,6 @@ public class TimeSlider extends SliderBar {
}
}
/**
* Override parent version because event don't fire when we set value which is in multiples of stepSize
*/
@Override
public synchronized void setCurrentValue(Double curValue, boolean fireEvent) {
// Confine the value to the range
if (!isMinMaxInitialized() || curValue == null) {
return;
}
Double newValue = Math.max(minValue, Math.min(maxValue, curValue));
double remainder = (newValue - minValue) % stepSize;
newValue -= remainder;
// Go to next step if more than halfway there
if ((remainder > (stepSize / 2)) && ((newValue + stepSize) <= maxValue)) {
newValue += stepSize;
}
boolean isValueChanged = !newValue.equals(this.curValue) && this.curValue != null;
this.curValue = newValue;
// Redraw the knob
drawKnob();
// Fire the ValueChangeEvent if the value actually changed
if (fireEvent && isValueChanged) {
ValueChangeEvent.fire(this, this.curValue);
}
}
/**
* Draw the labels along the line.
*/