Skip to content

Commit

Permalink
Merge pull request #41 from movsim/issue-#38
Browse files Browse the repository at this point in the history
Fixes viewer initialization. Project gets parsed just once instead tw…
  • Loading branch information
akegermany committed Aug 24, 2018
2 parents 18bd468 + aec8f91 commit 711c71f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
8 changes: 0 additions & 8 deletions core/src/main/java/org/movsim/simulator/Simulator.java
Expand Up @@ -232,14 +232,6 @@ public SimulationRunnable getSimulationRunnable() {
return simulationRunnable;
}

// TODO Apparently the viewer needs a second initialization to work. Investigate and remove!
public void loadScenarioFromXml(String scenario, String path) throws JAXBException, SAXException {
roadNetwork.clear();
ProjectMetaData.getInstance().setProjectName(scenario);
ProjectMetaData.getInstance().setPathToProjectXmlFile(path);
initialize();
}

private void matchRoadSegmentsAndRoadInput(List<Road> roads,
MicroscopicBoundaryConditions microBoundaryConditions) {
for (Road roadInput : roads) {
Expand Down
Expand Up @@ -287,23 +287,9 @@ protected void toogleDrawRoadId() {
drawRoadId = !drawRoadId;
}

/**
* Sets up the given traffic scenario.
*
* @param scenario
* @throws SAXException
* @throws JAXBException
*/
public void setupTrafficScenario(String scenario, String path) {
reset();
try {
simulator.loadScenarioFromXml(scenario, path);
} catch (JAXBException | SAXException e) {
throw new IllegalArgumentException(e.toString());
}
properties = ViewProperties.loadProperties(scenario, path);
initGraphicSettings();
forceRepaintBackground();
reset();
}

private void initGraphicSettings() {
Expand Down
3 changes: 1 addition & 2 deletions viewer/src/main/java/org/movsim/viewer/ui/AppFrame.java
Expand Up @@ -84,8 +84,7 @@ public void componentResized(ComponentEvent e) {
initFrameSize(properties);

if (projectMetaData.hasProjectName()) {
trafficCanvas
.setupTrafficScenario(projectMetaData.getProjectName(), projectMetaData.getPathToProjectFile());
trafficCanvas.setupTrafficScenario(projectMetaData.getProjectName(), projectMetaData.getPathToProjectFile());
} else {
System.out.println("Please provide scenario via -f option");
}
Expand Down

0 comments on commit 711c71f

Please sign in to comment.