Commit 72ca89da authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

In "AdjustPanel" of PostVis: The "time" spinner uses the time resolution of...

In "AdjustPanel" of PostVis: The "time" spinner uses the time resolution of the "time resolution" spinner now

Also renamed the (slightly) bulky term "simTimeStepLength" to simple "timeResolution".
This affects mostly these files:
- VadereGui/.../messages.properties
- VadereGui/.../PostvisualizationConfig.java
- VadereGui/.../PostvisualizationModel.java
- VadereUtils/.../VadereConfig.java
  Here, I renamed the key "PostVis.visTimeStepLength" to "PostVis.timeResolution"
  and use our default simulation step length (of 0.4 seconds) as default value
  instead of 0.1 seconds.
parent 75a7e780
Pipeline #180328 passed with stages
in 129 minutes and 42 seconds
......@@ -203,8 +203,8 @@ OutputprocessorsView.dataProcessor.text={Processor: ""}
AdjustPanel.lblVelocity.text=FPS
AdjustPanel.lblTime=Time
AdjustPanel.lblStep.text=Timestep
AdjustPanel.lblVisTime.text=Res.
AdjustPanel.lblStep.text=SimStep
AdjustPanel.lblTimeResolution.text=Res.
ProjectView.warning.lwjgl.title=Warning
ProjectView.warning.opencl.title=Warning
......
......@@ -208,8 +208,8 @@ OutputprocessorsView.dataProcessor.text={"Processor": ""}
AdjustPanel.lblVelocity.text=FPS
AdjustPanel.lblTime=Zeit
AdjustPanel.lblStep.text=Zeitschritt
AdjustPanel.lblVisTime.text=Aufl.
AdjustPanel.lblStep.text=SimSchritt
AdjustPanel.lblTimeResolution.text=Aufl.
ProjectView.mntmOutputToSceneario.text=Generiere Szenario
ProjectView.mntmRunOutput.text=Offline erneut starten
......
......@@ -87,7 +87,7 @@ public class Player implements Runnable {
switch (state) {
case RUNNING: {
if (isRunnable()) {
double newSimeTimeInSec = model.getSimTimeInSec() + model.getVisTimeStepLength();
double newSimeTimeInSec = model.getSimTimeInSec() + model.getTimeResolution();
if(model.getSimTimeInSec() >= model.getMaxSimTimeInSec()) {
newSimeTimeInSec = 0;
}
......
......@@ -17,7 +17,7 @@ public class PostvisualizationConfig extends DefaultSimulationConfig {
private int fps = CONFIG.getInt("PostVis.framesPerSecond");
private final int MAX_VELOCITY = CONFIG.getInt("PostVis.maxFramePerSecond");
private double visTimeStepLength = CONFIG.getDouble("PostVis.visTimeStepLength");
private double timeResolution = CONFIG.getDouble("PostVis.timeResolution");
private Observable observable;
public PostvisualizationConfig() {}
......@@ -37,9 +37,9 @@ public class PostvisualizationConfig extends DefaultSimulationConfig {
setChanged();
}
public void setVisTimeStepLength(double visTimeStepLength) {
this.visTimeStepLength = visTimeStepLength;
CONFIG.setProperty("PostVis.visTimeStepLength", visTimeStepLength);
public void setTimeResolution(double timeResolution) {
this.timeResolution = timeResolution;
CONFIG.setProperty("PostVis.timeResolution", timeResolution);
setChanged();
}
......@@ -47,8 +47,8 @@ public class PostvisualizationConfig extends DefaultSimulationConfig {
return fps;
}
public double getVisTimeStepLength() {
return visTimeStepLength;
public double getTimeResolution() {
return timeResolution;
}
public int getMaxVelocity() {
......
......@@ -48,7 +48,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
private double visTime;
private double visTimeStepLength;
private double timeResolution;
private double simTimeStepLength;
......@@ -75,7 +75,7 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
this.topographyId = 0;
this.potentialContainer = null;
this.simTimeStepLength = new AttributesSimulation().getSimTimeStepLength();
this.visTimeStepLength = this.simTimeStepLength;
this.timeResolution = this.simTimeStepLength;
this.visTime = 0;
this.predicateColoringModel = new PredicateColoringModel();
this.outputChanged = false;
......@@ -118,19 +118,19 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
}
private double stepToTime(final int step) {
return visTimeStepLength * (step - 1);
return timeResolution * (step - 1);
}
public synchronized PredicateColoringModel getPredicateColoringModel() {
return predicateColoringModel;
}
public synchronized double getVisTimeStepLength() {
return visTimeStepLength;
public synchronized double getTimeResolution() {
return timeResolution;
}
public synchronized void setVisTimeStepLength(final double visTimeStepLength) {
this.visTimeStepLength = visTimeStepLength;
public synchronized void setTimeResolution(final double visTimeStepLength) {
this.timeResolution = visTimeStepLength;
}
public synchronized double getSimTimeStepLength() {
......
......@@ -2,40 +2,37 @@ package org.vadere.gui.postvisualization.view;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import javax.swing.*;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.postvisualization.control.ActionSetTimeStep;
import org.vadere.gui.postvisualization.control.EJSliderAction;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.state.simulation.Step;
import javax.swing.*;
import java.awt.*;
import java.util.Locale;
import java.util.Observable;
import java.util.Observer;
import java.util.Optional;
public class AdjustPanel extends JPanel implements Observer {
private static Resources resources = Resources.getInstance("postvisualization");
private final JSlider slider;
private final JSpinner sStep;
private final JSpinner sVelocity;
private final JSpinner sVisTimeStepLength;
private final JSpinner sVelocity;
private final JSpinner sTime;
private final SpinnerModel sModelTime;
private final SpinnerModel sModelTimeStep;
private final JSpinner sStep;
private final JSpinner sTimeResolution;
private final SpinnerModel sModelVelocity;
// No "final" because if step size of "sTimeResolution" changes,
// this should also effect the step size of "sTime" and its underlying spinner model.
private SpinnerModel sModelTime;
private final SpinnerModel sModelTimeStep;
private final SpinnerModel sModelTimeResolution;
private final SpinnerModel sModelVisTimeStepLength;
private final PostvisualizationModel model;
public AdjustPanel(final PostvisualizationModel model) {
this.model = model;
if (!model.isEmpty()) {
slider = new JSlider(SwingConstants.HORIZONTAL, model.getFirstStep(),
model.getLastStep(), model.getFirstStep());
......@@ -44,28 +41,24 @@ public class AdjustPanel extends JPanel implements Observer {
}
slider.addMouseListener(new EJSliderAction(slider));
// sStep.setEditable(false);
sModelVelocity = new SpinnerNumberModel(model.config.getFps(), 1, 200, 1);
sModelTime = new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, model.getTimeResolution());
sModelTimeStep = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1);
sModelTime = new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, model.getVisTimeStepLength());
sModelVisTimeStepLength = new SpinnerNumberModel(model.config.getVisTimeStepLength(), 0.01, Double.MAX_VALUE, 0.01);
model.setVisTimeStepLength(model.config.getVisTimeStepLength());
sModelTimeResolution = new SpinnerNumberModel(model.config.getTimeResolution(), 0.01, Double.MAX_VALUE, 0.01);
model.setTimeResolution(model.config.getTimeResolution());
sVelocity = new JSpinner(sModelVelocity);
sTime = new JSpinner(sModelTime);
sStep = new JSpinner(sModelTimeStep);
sVisTimeStepLength = new JSpinner(sModelVisTimeStepLength);
sTimeResolution = new JSpinner(sModelTimeResolution);
//sTime.setEnabled(false);
// lTime.set
// lTime.setV
sStep.setPreferredSize(new Dimension(50, 30));
sVelocity.setPreferredSize(new Dimension(50, 30));
sTime.setPreferredSize(new Dimension(70, 30));
sVisTimeStepLength.setPreferredSize(new Dimension(70, 30));
// Layout definition!
sTimeResolution.setPreferredSize(new Dimension(70, 30));
// Arrange the GUI components according to a column-based layout
FormLayout layout = new FormLayout(
"2dlu, default:grow, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu", // col
"2dlu, default, 2dlu"); // rows
......@@ -78,8 +71,8 @@ public class AdjustPanel extends JPanel implements Observer {
add(sTime, cc.xy(10, 2));
add(new JLabel(Messages.getString("AdjustPanel.lblStep.text")), cc.xy(12, 2));
add(sStep, cc.xy(14, 2));
add(new JLabel(Messages.getString("AdjustPanel.lblVisTime.text")), cc.xy(16, 2));
add(sVisTimeStepLength, cc.xy(18, 2));
add(new JLabel(Messages.getString("AdjustPanel.lblTimeResolution.text")), cc.xy(16, 2));
add(sTimeResolution, cc.xy(18, 2));
sVelocity.addChangeListener(e -> {
model.config.setFps((int) sVelocity.getValue());
......@@ -98,10 +91,15 @@ public class AdjustPanel extends JPanel implements Observer {
}
});
sVisTimeStepLength.addChangeListener(e -> {
model.config.setVisTimeStepLength((double) sVisTimeStepLength.getValue());
model.setVisTimeStepLength(model.config.getVisTimeStepLength());
sTimeResolution.addChangeListener(e -> {
model.config.setTimeResolution((double) sTimeResolution.getValue());
model.setTimeResolution(model.config.getTimeResolution());
model.notifyObservers();
double currentTimeValue = (double)sModelTime.getValue();
double newStepSize = model.config.getTimeResolution();
sModelTime = new SpinnerNumberModel(currentTimeValue, 0.0, Double.MAX_VALUE, newStepSize);
sTime.setModel(sModelTime);
});
......@@ -123,7 +121,7 @@ public class AdjustPanel extends JPanel implements Observer {
slider.setValue(currentStepNumber);
sStep.setValue(currentStepNumber);
sTime.setValue(model.getSimTimeInSec());
sVisTimeStepLength.setValue(model.getVisTimeStepLength());
sTimeResolution.setValue(model.getTimeResolution());
sTime.setValue(model.getSimTimeInSec());
//((SpinnerNumberModel)sModelTime).setStepSize(model.getSimTimeInSec());
//slider.setValueIsAdjusting(false);
......
......@@ -245,7 +245,7 @@ public class VadereConfig {
defaultConfig.put("PostVis.maxNumberOfSaveDirectories", "5");
defaultConfig.put("PostVis.maxFramePerSecond", "40");
defaultConfig.put("PostVis.framesPerSecond", "20");
defaultConfig.put("PostVis.visTimeStepLength", "0.1");
defaultConfig.put("PostVis.timeResolution", "0.4");
defaultConfig.put("PostVis.cellWidth", "1.0");
defaultConfig.put("PostVis.minCellWidth", "0.01");
defaultConfig.put("PostVis.maxCellWidth", "10.0");
......
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