Commit ae1a4492 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

In "ActionSetTimeStep.java", fixed slider so that fast-forward and rewind works immediately

Fixes issue #267.
parent 61f8ed1f
Pipeline #163928 passed with stages
in 124 minutes and 51 seconds
......@@ -42,10 +42,9 @@ public class ActionSetTimeStep extends ActionVisualization implements ChangeList
@Override
public void stateChanged(final ChangeEvent event) {
JSlider source = (JSlider) event.getSource();
if(!source.getValueIsAdjusting()) {
model.setStep(source.getValue());
model.notifyObservers();
}
JSlider slider = (JSlider) event.getSource();
model.setStep(slider.getValue());
model.notifyObservers();
}
}
......@@ -20,23 +20,17 @@ public class EJSliderAction implements MouseListener {
@Override
public void mousePressed(final MouseEvent e) {
setSliderValue(e);
}
@Override
public void mouseReleased(final MouseEvent e) {
Point p = e.getPoint();
double percent = p.x / ((double) slider.getWidth());
int range = slider.getMaximum() - slider.getMinimum();
double newVal = range * percent;
int result = (int) (Math.ceil(slider.getMinimum() + newVal));
// logger.info("change to step: " + Thread.currentThread().getName() + (result+1));
slider.setValue(result);
setSliderValue(e);
}
@Override
public void mouseClicked(MouseEvent e) {
setSliderValue(e);
}
@Override
......@@ -48,4 +42,14 @@ public class EJSliderAction implements MouseListener {
public void mouseExited(MouseEvent e) {
}
private void setSliderValue(MouseEvent e) {
Point sliderPosition = e.getPoint();
double percent = sliderPosition.x / ((double) slider.getWidth());
int sliderRange = slider.getMaximum() - slider.getMinimum();
double newValue = sliderRange * percent;
int result = (int) (Math.ceil(slider.getMinimum() + newValue));
slider.setValue(result);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment