22.1.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 7dc0825d authored by Marion Goedel's avatar Marion Goedel

Merge branch 'develop' of https://gitlab.lrz.de/vadere/vadere into develop

parents b35edd82 9f043451
Pipeline #59498 passed with stage
in 47 seconds
......@@ -106,12 +106,14 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
}
@Override
public void removeUpdate(DocumentEvent e) {
public void removeUpdate(DocumentEvent e)
{
updateModel();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateModel();
}
};
......@@ -126,7 +128,7 @@ public class ScenarioElementView extends JPanel implements ISelectScenarioElemen
ScenarioElement element = panelModel.getSelectedElement();
if (element != null) {
String json = txtrTextfiletextarea.getText();
//logger.info(json);
if (json.length() == 0)
return;
......
......@@ -6,6 +6,7 @@ import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.state.attributes.models.AttributesBHM;
import org.vadere.util.io.IOUtils;
import java.awt.*;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
import java.util.prefs.InvalidPreferencesFormatException;
......
......@@ -109,12 +109,14 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
// ##################
@Override
public void postProjectRun(final VadereProject scenario) {
scenariosRunning = false;
model.refreshOutputTable();
setScenariosRunning(false);
progressPanel.setData(Messages.getString("ProgressPanelDone.text"), 100);
scenarioJPanel.showEditScenario();
selectCurrentScenarioRunManager();
EventQueue.invokeLater(() -> {
scenariosRunning = false;
model.refreshOutputTable();
setScenariosRunning(false);
progressPanel.setData(Messages.getString("ProgressPanelDone.text"), 100);
scenarioJPanel.showEditScenario();
selectCurrentScenarioRunManager();
});
}
private void selectCurrentScenarioRunManager() {
......@@ -127,58 +129,71 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
@Override
public void preProjectRun(final VadereProject project) {
setScenariosRunning(true);
progressPanel.setData(Messages.getString("ProgressPanelWorking.text"), 0);
EventQueue.invokeLater(() -> {
setScenariosRunning(true);
progressPanel.setData(Messages.getString("ProgressPanelWorking.text"), 0);
});
}
@Override
public void preScenarioRun(final Scenario scenario, final int scenariosLeft) {
model.setScenarioNameLabel(scenario.getName());
repaint();
EventQueue.invokeLater(() -> {
model.setScenarioNameLabel(scenario.getName());
repaint();
});
}
@Override
public void postScenarioRun(final Scenario cloneScenario, final int scenarioLeft) {
// take the original!
replace(cloneScenario, VadereState.INITIALIZED);
// model.refreshOutputTable();
// find index of scenario
int totalScenariosCount = model.getProject().getScenarios().size();
int doneScenariosCount = totalScenariosCount - scenarioLeft;
progressPanel.setData(Messages.getString("ProgressPanelWorking.text"), 100 * doneScenariosCount
/ totalScenariosCount);
logger.info(String.format("scenario %s finished", cloneScenario.getName()));
EventQueue.invokeLater(() -> {
replace(cloneScenario, VadereState.INITIALIZED);
// model.refreshOutputTable();
// find index of scenario
int totalScenariosCount = model.getProject().getScenarios().size();
int doneScenariosCount = totalScenariosCount - scenarioLeft;
progressPanel.setData(Messages.getString("ProgressPanelWorking.text"), 100 * doneScenariosCount
/ totalScenariosCount);
logger.info(String.format("scenario %s finished", cloneScenario.getName()));
});
}
@Override
public void scenarioStarted(final Scenario cloneScenario, final int scenariosLeft) {
// take the original!
replace(cloneScenario, VadereState.RUNNING);
EventQueue.invokeLater(() -> {
replace(cloneScenario, VadereState.RUNNING);
});
}
@Override
public void scenarioPaused(final Scenario cloneScenario, final int scenariosLeft) {
// take the original!
replace(cloneScenario, VadereState.PAUSED);
EventQueue.invokeLater(() -> {
replace(cloneScenario, VadereState.PAUSED);
});
}
@Override
public void scenarioInterrupted(final Scenario scenario, final int scenariosLeft) {
replace(scenario, VadereState.INTERRUPTED);
setScenariosRunning(false);
selectCurrentScenarioRunManager();
logger.info(String.format("all running scenarios interrupted"));
EventQueue.invokeLater(() -> {
replace(scenario, VadereState.INTERRUPTED);
setScenariosRunning(false);
selectCurrentScenarioRunManager();
logger.info(String.format("all running scenarios interrupted"));
});
}
@Override
public void error(final Scenario scenario, final int scenarioLefts, final Throwable throwable) {
replace(scenario, VadereState.INTERRUPTED);
new Thread(
() -> {
IOUtils.errorBox(Messages.getString("ProjectView.simulationRunErrorDialog.text") + " " + scenario
+ ": " + throwable, Messages.getString("ProjectView.simulationRunErrorDialog.title"));
}).start();
EventQueue.invokeLater(() -> {
replace(scenario, VadereState.INTERRUPTED);
new Thread(
() -> {
IOUtils.errorBox(Messages.getString("ProjectView.simulationRunErrorDialog.text") + " " + scenario
+ ": " + throwable, Messages.getString("ProjectView.simulationRunErrorDialog.title"));
}).start();
});
}
private void replace(final Scenario scenarioRM, final VadereState state) {
......@@ -190,21 +205,27 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
@Override
public void preRefresh() {
outputTable.setEnabled(false);
EventQueue.invokeLater(() -> {
outputTable.setEnabled(false);
});
}
@Override
public void postRefresh() {
if (!scenariosRunning)
outputTable.setEnabled(true);
EventQueue.invokeLater(() -> {
if (!scenariosRunning)
outputTable.setEnabled(true);
});
}
@Override
public void projectChanged(final VadereProject project) {
setTitle();
model.getProject().addProjectFinishedListener(this);
model.getProject().addSingleScenarioFinishedListener(this);
model.getProject().addProjectFinishedListener(scenarioJPanel);
EventQueue.invokeLater(() -> {
setTitle();
model.getProject().addProjectFinishedListener(this);
model.getProject().addSingleScenarioFinishedListener(this);
model.getProject().addProjectFinishedListener(scenarioJPanel);
});
}
@Override
......@@ -217,21 +238,23 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
* Launch the application.
*/
public static void start() {
try {
// Set Java L&F from system
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
| IllegalAccessException e) {
IOUtils.errorBox("The system look and feel could not be loaded.", "Error setLookAndFeel");
}
// show GUI
ProjectViewModel model = new ProjectViewModel();
ProjectView frame = new ProjectView(model);
frame.setProjectSpecificActionsEnabled(false);
frame.setVisible(true);
frame.setSize(1200, 800);
frame.openLastUsedProject(model);
EventQueue.invokeLater(() -> {
try {
// Set Java L&F from system
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
| IllegalAccessException e) {
IOUtils.errorBox("The system look and feel could not be loaded.", "Error setLookAndFeel");
}
// show GUI
ProjectViewModel model = new ProjectViewModel();
ProjectView frame = new ProjectView(model);
frame.setProjectSpecificActionsEnabled(false);
frame.setVisible(true);
frame.setSize(1200, 800);
frame.openLastUsedProject(model);
});
}
private void openLastUsedProject(final ProjectViewModel model) {
......
......@@ -71,7 +71,7 @@
"finishTime" : 70.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"writeSimulationData" : false,
"visualizationEnabled" : true,
"printFPS" : false,
"needsBoundary" : false,
......
......@@ -76,10 +76,10 @@ public class Simulation {
this.mainModel = mainModel;
this.scenarioStore = scenarioStore;
this.attributesSimulation = scenarioStore.attributesSimulation;
this.attributesAgent = scenarioStore.topography.getAttributesPedestrian();
this.attributesAgent = scenarioStore.getTopography().getAttributesPedestrian();
this.sourceControllers = new LinkedList<>();
this.targetControllers = new LinkedList<>();
this.topography = scenarioStore.topography;
this.topography = scenarioStore.getTopography();
this.runTimeInSec = attributesSimulation.getFinishTime();
this.startTimeInSec = startTimeInSec;
this.simTimeInSec = startTimeInSec;
......
......@@ -66,20 +66,20 @@ public class ScenarioBuilder {
store.attributesSimulation = (AttributesSimulation) builder.build();
}
else if(AttributesAgent.class == clazz){
builder = new AttributesBuilder<>((E)store.topography.getAttributesPedestrian());
builder = new AttributesBuilder<>((E)store.getTopography().getAttributesPedestrian());
builder.setField(fieldName, value);
setAttributesAgent((AttributesAgent) builder.build());
}
else if(AttributesCar.class == clazz){
builder = new AttributesBuilder<>((E)store.topography.getAttributesCar());
builder = new AttributesBuilder<>((E)store.getTopography().getAttributesCar());
builder.setField(fieldName, value);
setAttributesCar((AttributesCar) builder.build());
}
else if(AttributesTopography.class == clazz){
builder = new AttributesBuilder<>((E)store.topography.getAttributes());
builder = new AttributesBuilder<>((E)store.getTopography().getAttributes());
builder.setField(fieldName, value);
ReflectionAttributeModifier reflectionAttributeModifier = new ReflectionAttributeModifier();
reflectionAttributeModifier.setAttributes(store.topography, builder.build());
reflectionAttributeModifier.setAttributes(store.getTopography(), builder.build());
}
else {
builder = new AttributesBuilder<>(store.getAttributes(clazz));
......@@ -92,9 +92,9 @@ public class ScenarioBuilder {
private void setAttributesCar(@NotNull final AttributesCar attributesCar) {
Field field;
try {
field = store.topography.getClass().getDeclaredField("attributesCar");
field = store.getTopography().getClass().getDeclaredField("attributesCar");
field.setAccessible(true);
field.set(store.topography, attributesCar);
field.set(store.getTopography(), attributesCar);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
logger.error(e);
......@@ -104,9 +104,9 @@ public class ScenarioBuilder {
private void setAttributesAgent(@NotNull final AttributesAgent attributesAgent) {
Field field;
try {
field = store.topography.getClass().getDeclaredField("attributesPedestrian");
field = store.getTopography().getClass().getDeclaredField("attributesPedestrian");
field.setAccessible(true);
field.set(store.topography, attributesAgent);
field.set(store.getTopography(), attributesAgent);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
logger.error(e);
......
......@@ -48,8 +48,8 @@ public class MainModelBuilder {
String mainModelName = scenarioStore.mainModel;
DynamicClassInstantiator<MainModel> instantiator = new DynamicClassInstantiator<>();
MainModel mainModel = instantiator.createObject(mainModelName);
mainModel.initialize(scenarioStore.attributesList, scenarioStore.topography,
scenarioStore.topography.getAttributesPedestrian(), random);
mainModel.initialize(scenarioStore.attributesList, scenarioStore.getTopography(),
scenarioStore.getTopography().getAttributesPedestrian(), random);
return mainModel;
}
......
......@@ -4,9 +4,11 @@
package org.vadere.simulator.models.osm.stairOptimization;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.simulator.models.osm.optimization.StepCircleOptimizer;
import org.vadere.simulator.projects.io.JsonConverter;
import org.vadere.state.scenario.Stairs;
import org.vadere.state.scenario.Stairs.Tread;
import org.vadere.util.geometry.Vector2D;
......@@ -27,6 +29,8 @@ public class StairStepOptimizer implements StepCircleOptimizer {
private Stairs stairs;
private Logger logger = LogManager.getLogger(StairStepOptimizer.class);
private final double tol_equal_values = 1E-4;
public StairStepOptimizer(Stairs s) {
......@@ -35,7 +39,7 @@ public class StairStepOptimizer implements StepCircleOptimizer {
@Override
public VPoint getNextPosition(PedestrianOSM pedestrian, Shape reachableArea) {
//logger.info(stairs.getAttributes().getUpwardDirection());
if (!isOnActualStairs(pedestrian)) {
Logger.getLogger(this.getClass())
.error("Only pedestrians should get in here that are on actual Stairs -> Bug in code.");
......
......@@ -100,7 +100,7 @@ public class Scenario {
}
public AttributesAgent getAttributesPedestrian() {
return scenarioStore.topography.getAttributesPedestrian();
return scenarioStore.getTopography().getAttributesPedestrian();
}
public AttributesSimulation getAttributesSimulation() {
......@@ -108,7 +108,7 @@ public class Scenario {
}
public Topography getTopography() {
return scenarioStore.topography;
return scenarioStore.getTopography();
}
public void setName(String name) {
......@@ -124,7 +124,7 @@ public class Scenario {
}
public void setTopography(final Topography topography) {
scenarioStore.topography = topography;
scenarioStore.setTopography(topography);
}
@Override
......
......@@ -69,8 +69,7 @@ public class ScenarioRun implements Runnable {
public void run() {
try {
logger.info(String.format("Initializing scenario. Start of scenario '%s'...", scenario.getName()));
scenarioStore.topography.reset();
scenarioStore.getTopography().reset();
MainModelBuilder modelBuilder = new MainModelBuilder(scenarioStore);
modelBuilder.createModelAndRandom();
......
......@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.projects.io.JsonConverter;
import org.vadere.state.attributes.Attributes;
......@@ -25,12 +27,13 @@ import com.fasterxml.jackson.core.JsonProcessingException;
*/
public class ScenarioStore {
private static Logger logger = LogManager.getLogger(ScenarioStore.class);
public String name;
public String description;
public String mainModel;
public List<Attributes> attributesList;
public AttributesSimulation attributesSimulation;
public Topography topography;
private Topography topography;
public ScenarioStore(final String name, final String description, final String mainModel, final List<Attributes> attributesModel,
final AttributesSimulation attributesSimulation, final Topography topography) {
......@@ -42,6 +45,15 @@ public class ScenarioStore {
this.topography = topography;
}
public synchronized Topography getTopography() {
return topography;
}
public synchronized void setTopography(final Topography topography) {
//logger.info("setTopography:" + topography + ", thread:" + Thread.currentThread());
this.topography = topography;
}
public ScenarioStore(final String name) {
this(name, "", null, new ArrayList<>(), new AttributesSimulation(), new Topography());
}
......
......@@ -107,7 +107,7 @@ public class JsonConverter {
vadereNode.set("attributesSimulation", StateJsonConverter.convertValue(scenarioStore.attributesSimulation, JsonNode.class));
// vadere > topography
ObjectNode topographyNode = StateJsonConverter.serializeTopographyToNode(scenarioStore.topography);
ObjectNode topographyNode = StateJsonConverter.serializeTopographyToNode(scenarioStore.getTopography());
vadereNode.set("topography", topographyNode);
return vadereNode;
......@@ -121,7 +121,7 @@ public class JsonConverter {
public static ScenarioStore cloneScenarioStore(ScenarioStore scenarioStore) throws IOException {
JsonNode attributesSimulationNode = StateJsonConverter.convertValue(scenarioStore.attributesSimulation, JsonNode.class);
ObjectNode attributesModelNode = StateJsonConverter.serializeAttributesModelToNode(scenarioStore.attributesList);
ObjectNode topographyNode = StateJsonConverter.serializeTopographyToNode(scenarioStore.topography);
ObjectNode topographyNode = StateJsonConverter.serializeTopographyToNode(scenarioStore.getTopography());
return new ScenarioStore(scenarioStore.name, scenarioStore.description, scenarioStore.mainModel,
StateJsonConverter.deserializeAttributesListFromNode(attributesModelNode),
StateJsonConverter.deserializeAttributesSimulationFromNode(attributesSimulationNode),
......
......@@ -5,6 +5,8 @@ import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.state.attributes.scenario.AttributesStairs;
import org.vadere.state.types.ScenarioElementType;
import org.vadere.util.geometry.shapes.VLine;
......@@ -14,6 +16,7 @@ import org.vadere.util.geometry.shapes.VShape;
public class Stairs extends ScenarioElement {
private static Logger logger = LogManager.getLogger(Stairs.class);
public static class Tread {
public final VLine treadline;
......
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