Merge pull request #1615 from SiboVG/issue-236

[#236] Limit simulation time step to 0.01 s
This commit is contained in:
Billy Olsen 2022-08-28 13:37:33 -07:00 committed by GitHub
commit 09456ad157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -773,6 +773,12 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
*/
public void setValue(double v) {
checkState(true);
double clampedValue = MathUtil.clamp(v, minValue, maxValue);
if (clampedValue != v) {
log.debug("Clamped value " + v + " to " + clampedValue + " for " + this);
v = clampedValue;
}
log.debug("Setting value " + v + " for " + this);
if (setMethod == null) {

View File

@ -135,7 +135,7 @@ public class SimulationPreferencesPanel extends PreferencesPanel {
subsub.add(label, "gapright para");
DoubleModel m_ts = new DoubleModel(preferences, "TimeStep", UnitGroup.UNITS_TIME_STEP,
0, 1);
0.01, 1);
spin = new JSpinner(m_ts.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin));
@ -145,7 +145,7 @@ public class SimulationPreferencesPanel extends PreferencesPanel {
unit = new UnitSelector(m_ts);
unit.setToolTipText(tip);
subsub.add(unit, "");
slider = new BasicSlider(m_ts.getSliderModel(0, 0.2));
slider = new BasicSlider(m_ts.getSliderModel(0.01, 0.2));
slider.setToolTipText(tip);
subsub.add(slider, "w 100");

View File

@ -143,7 +143,7 @@ class SimulationOptionsPanel extends JPanel {
subsub.add(label, "gapright para");
m = new DoubleModel(conditions, "TimeStep", UnitGroup.UNITS_TIME_STEP,
0, 1);
0.01, 1);
spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin));
@ -153,7 +153,7 @@ class SimulationOptionsPanel extends JPanel {
unit = new UnitSelector(m);
unit.setToolTipText(tip);
subsub.add(unit, "");
slider = new BasicSlider(m.getSliderModel(0, 0.2));
slider = new BasicSlider(m.getSliderModel(0.01, 0.2));
slider.setToolTipText(tip);
subsub.add(slider, "w 100");