Commit a00d5101 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

refactor ScenarioChecker

parent 930bc017
......@@ -2,6 +2,7 @@
target/
*.out
*.preferences.xml
swing-inspector-linux-1.2.3/
#Tools and build utils
bin/
......
......@@ -304,32 +304,35 @@ TopographyCreator.btnMakro.tooltip=Generate not set IDs.
select_shape_tooltip=Select Shape
# TopographyChecker
TopographyChecker.type.error=Error
TopographyChecker.type.warning=Warning
TopographyChecker.source.targetIdNotFound=The following target ids where not found in the scenario.
TopographyChecker.source.noTargetIdSet=No Target Ids set for Source.
TopographyChecker.source.noTargetIdAndNoSpawn=No Target Ids set for Source with SpawnNumber 0. This might be an error.
TopographyChecker.source.idNotUnique=Multiple Sources have the same ID.
TopographyChecker.stairs.wrongTreadDim=Stair treadDepth outside of allowed dimension.
TopographyChecker.target.unused=The target is not used in any source. Remove target to increase performance.
TopographyChecker.pedestrian.speedsetup=speedDistributionMean must be within min/max range.
TopographyChecker.pedestrian.speedNotLogical=Min or Max speed of pedestrian is bigger than world record.
TopographyChecker.pedestrian.speedIsNegative=Min or Max speed is negative.
TopographyChecker.overlap.stair.stair=Stairs cannot overlap.
TopographyChecker.overlap.target.stair=A target and a stairs element overlap in scenario.
TopographyChecker.overlap.source.stair=A source and a stairs element overlap in scenario.
TopographyChecker.overlap.source.target=A source and a target element overlap in scenario.
TopographyChecker.overlap.source.source=Two source overlap. This can cause overlapping when useFreeSpaceOnly is not set.
TopographyChecker.overlap.target.target=Two targets overlap.
TopographyChecker.overlap.obstacle.stairs.err=Stairs is completely contained in an obstacle.
TopographyChecker.overlap.obstacle.stairs.warn=Stairs contains an obstacle. This setup works put is not tested. Split in two stairs.
TopographyChecker.overlap.obstacle.target.err=Target is completely contained in an obstacle.
TopographyChecker.overlap.obstacle.target.warn=Target contains an obstacle. This setup works but reduces the actual size of the target.
TopographyChecker.overlap.obstacle.source=Obstacle overlaps with a source. This setup will spawn pedestrians within the obstacle.
TopographyChecker.overlap.obstacle.obstacle=Two obstacles overlap / is enclosed completely. Delete one for better performance.
# ScenarioChecker
ScenarioChecker.type.error=Error
ScenarioChecker.type.warning=Warning
ScenarioChecker.source.targetIdNotFound=The following target ids where not found in the scenario.
ScenarioChecker.source.noTargetIdSet=No Target Ids set for Source.
ScenarioChecker.source.noTargetIdAndNoSpawn=No Target Ids set for Source with SpawnNumber 0. This might be an error.
ScenarioChecker.source.idNotUnique=Multiple Sources have the same ID.
ScenarioChecker.stairs.wrongTreadDim=Stair treadDepth outside of allowed dimension. Change the thread numbers to compensate.
ScenarioChecker.target.unused=The target is not used in any source. Remove target to increase performance.
ScenarioChecker.pedestrian.speedsetup=speedDistributionMean must be within min/max range.
ScenarioChecker.pedestrian.speedNotLogical=Min or Max speed of pedestrian is bigger than world record.
ScenarioChecker.pedestrian.speedIsNegative=Min or Max speed is negative.
ScenarioChecker.overlap.stair.stair=Stairs cannot overlap.
ScenarioChecker.overlap.target.stair=A target and a stairs element overlap in scenario.
ScenarioChecker.overlap.source.stair=A source and a stairs element overlap in scenario.
ScenarioChecker.overlap.source.target=A source and a target element overlap in scenario.
ScenarioChecker.overlap.source.source=Two source overlap. This can cause overlapping when useFreeSpaceOnly is not set.
ScenarioChecker.overlap.target.target=Two targets overlap.
ScenarioChecker.overlap.obstacle.stairs.err=Stairs is completely contained in an obstacle.
ScenarioChecker.overlap.obstacle.stairs.warn=Stairs contains an obstacle. This setup works put is not tested. Split in two stairs.
ScenarioChecker.overlap.obstacle.target.err=Target is completely contained in an obstacle.
ScenarioChecker.overlap.obstacle.target.warn=Target contains an obstacle. This setup works but reduces the actual size of the target.
ScenarioChecker.overlap.obstacle.source=Obstacle overlaps with a source. This setup will spawn pedestrians within the obstacle.
ScenarioChecker.overlap.obstacle.obstacle=Two obstacles overlap / is enclosed completely. Delete one for better performance.
ScenarioChecker.msg.ok=Scenario ok.
ScenarioChecker.msg.warn=Scenario contains warnings.
ScenarioChecker.msg.err=Scenario contains errors.
# tab titles Topography creator / postvis
Tab.Simulation.title=Simulation
......
......@@ -296,31 +296,34 @@ TopographyCreator.btnRectangle.label=Rechteck
TopographyCreator.btnChecker.tooltip=Topography Linter Nachrichten
TopographyCreator.btnMakro.tooltip=Erzeuge nicht gesetzte IDs.
# TopographyChecker
TopographyChecker.type.error=Fehler
TopographyChecker.type.warning=Warnung
TopographyChecker.source.targetIdNotFound=Die folgenden Ziel-IDs wurden nicht im Szenario gefunden.
TopographyChecker.source.noTargetIdSet=In der Quelle wurden keine Ziel Ids vergeben.
TopographyChecker.source.noTargetIdAndNoSpawn=In der Quelle wurden keine Ziel Ids vergeben, aber die Spawn Anzahl ist bei 0.
TopographyChecker.source.idNotUnique=Quellen haben keine eindeutige ID.
TopographyChecker.stairs.wrongTreadDim=Stufentiefe ist au\u00dferhalb des Definitionsbereichs.
TopographyChecker.target.unused=Das Ziel wird von keiner Quelle verwendet. Entferne das Ziel um die Performance zu erh\u00f6hen
TopographyChecker.pedestrian.speedsetup=speedDistributionMean muss im Bereich min/max liegen.
TopographyChecker.pedestrian.speedNotLogical=Min or Max Geschwindigkeit ist gr\u00f6\u00dfer als Weltrekord.
TopographyChecker.pedestrian.speedIsNegative=Min or Max Geschwindigkeit ist negativ.
TopographyChecker.overlap.stair.stair=Treppen d\u00fcrfen nicht \u00fcberlappen.
TopographyChecker.overlap.target.stair=Ein Ziel und eine Treppen \u00fcberlappen im Scenario.
TopographyChecker.overlap.source.stair=Eine Quelle und eine Treppe \u00fcberlappen im Scenario.
TopographyChecker.overlap.source.target=Eine Quelle und eine Ziel \u00fcberappen im Scenario.
TopographyChecker.overlap.source.source=Zwei Quellen \u00fcberlappen. Wenn useFreeSpaceOnly nicht gesetzt ist kann dies zu \u00fcberlappungen von Pedestrians f\u00fchren.
TopographyChecker.overlap.target.target=Zwei Ziele \u00fcberlappen.
TopographyChecker.overlap.obstacle.stairs.err=Treppe ist komplett in einem Hinderniss eingeschossen.
TopographyChecker.overlap.obstacle.stairs.warn=Treppe hat ein Hinderiss in sich. Dies ist m\u00f6glich aber nicht getestet. Wenn m\u00f6glich in zwei treppen aufteilen.
TopographyChecker.overlap.obstacle.target.err=Ziel ist komplett in einem Hinderniss eingeschlossen
TopographyChecker.overlap.obstacle.target.warn=Ziel hat ein Hinderniss in sich. Dies ist m\u00f6glich reduziert aber die tats\u00c4chliche Fl\u00c4che des Ziels.
TopographyChecker.overlap.obstacle.source=Hinderniss \u00fcberdeckt Quelle. Die f\u00fchrt dazu, dass Pedestrians im Hinderniss erzeugt werden.
TopographyChecker.overlap.obstacle.obstacle=Zwei identische bzw. eingeschlossene Obstacles gefunden. L\u00f6sche eins f\u00fcr bessere Performance
# ScenarioChecker
ScenarioChecker.type.error=Fehler
ScenarioChecker.type.warning=Warnung
ScenarioChecker.source.targetIdNotFound=Die folgenden Ziel-IDs wurden nicht im Szenario gefunden.
ScenarioChecker.source.noTargetIdSet=In der Quelle wurden keine Ziel Ids vergeben.
ScenarioChecker.source.noTargetIdAndNoSpawn=In der Quelle wurden keine Ziel Ids vergeben, aber die Spawn Anzahl ist bei 0.
ScenarioChecker.source.idNotUnique=Quellen haben keine eindeutige ID.
ScenarioChecker.stairs.wrongTreadDim=Stufentiefe ist au\u00dferhalb des Definitionsbereichs. Passen Sie die Anzahl der Stufen entsprechend an.
ScenarioChecker.target.unused=Das Ziel wird von keiner Quelle verwendet. Entferne das Ziel um die Performance zu erh\u00f6hen
ScenarioChecker.pedestrian.speedsetup=speedDistributionMean muss im Bereich min/max liegen.
ScenarioChecker.pedestrian.speedNotLogical=Min or Max Geschwindigkeit ist gr\u00f6\u00dfer als Weltrekord.
ScenarioChecker.pedestrian.speedIsNegative=Min or Max Geschwindigkeit ist negativ.
ScenarioChecker.overlap.stair.stair=Treppen d\u00fcrfen nicht \u00fcberlappen.
ScenarioChecker.overlap.target.stair=Ein Ziel und eine Treppen \u00fcberlappen im Scenario.
ScenarioChecker.overlap.source.stair=Eine Quelle und eine Treppe \u00fcberlappen im Scenario.
ScenarioChecker.overlap.source.target=Eine Quelle und eine Ziel \u00fcberappen im Scenario.
ScenarioChecker.overlap.source.source=Zwei Quellen \u00fcberlappen. Wenn useFreeSpaceOnly nicht gesetzt ist kann dies zu \u00fcberlappungen von Pedestrians f\u00fchren.
ScenarioChecker.overlap.target.target=Zwei Ziele \u00fcberlappen.
ScenarioChecker.overlap.obstacle.stairs.err=Treppe ist komplett in einem Hinderniss eingeschossen.
ScenarioChecker.overlap.obstacle.stairs.warn=Treppe hat ein Hinderiss in sich. Dies ist m\u00f6glich aber nicht getestet. Wenn m\u00f6glich in zwei treppen aufteilen.
ScenarioChecker.overlap.obstacle.target.err=Ziel ist komplett in einem Hinderniss eingeschlossen
ScenarioChecker.overlap.obstacle.target.warn=Ziel hat ein Hinderniss in sich. Dies ist m\u00f6glich reduziert aber die tats\u00c4chliche Fl\u00c4che des Ziels.
ScenarioChecker.overlap.obstacle.source=Hinderniss \u00fcberdeckt Quelle. Die f\u00fchrt dazu, dass Pedestrians im Hinderniss erzeugt werden.
ScenarioChecker.overlap.obstacle.obstacle=Zwei identische bzw. eingeschlossene Obstacles gefunden. L\u00f6sche eins f\u00fcr bessere Performance
ScenarioChecker.msg.ok=Scenario ok.
ScenarioChecker.msg.warn=Scenario hat Warnungen.
ScenarioChecker.msg.err=Scenario ist Fehlerhaft.
# tab titles Topography creator / postvis
Tab.Simulation.title=Simulation
......
......@@ -83,7 +83,7 @@ public class Resources {
properties.load(in);
} catch (IOException e) {
e.printStackTrace();
logger.error("error while loading properties for application: " + applicationName);
logger.error("topographyError while loading properties for application: " + applicationName);
} finally {
try {
in.close();
......
package org.vadere.gui.components.view;
import org.vadere.gui.projectview.view.AttributeType;
import org.vadere.gui.projectview.view.TextView;
import org.vadere.state.scenario.ScenarioElement;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
public class ScenarioCheckerView extends JEditorPane {
}
\ No newline at end of file
......@@ -14,7 +14,6 @@ import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.gui.projectview.view.ScenarioPanel;
import org.vadere.gui.topographycreator.model.AgentWrapper;
import org.vadere.gui.topographycreator.model.TopographyCreatorModel;
import org.vadere.simulator.util.TopographyChecker;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.ScenarioElement;
......
......@@ -139,7 +139,7 @@ public class PotentialFieldContainer {
if (y < grid.getNumPointsY() && (x - 2) < grid.getNumPointsX()) {
grid.setValue(x - 2, y, state);
} else {
logger.warn("Index error " + "y=" + y + " rows=" + grid.getNumPointsY() + " x=" + x + " cols="
logger.warn("Index topographyError " + "y=" + y + " rows=" + grid.getNumPointsY() + " x=" + x + " cols="
+ grid.getNumPointsX());
}
}
......
......@@ -47,7 +47,7 @@ public abstract class ActionAbstractAddScenario extends AbstractAction {
return;
addScenario(vadere);
} catch (IOException e) {
logger.error(String.format("error during output load: '%s'", e.getLocalizedMessage()));
logger.error(String.format("topographyError during output load: '%s'", e.getLocalizedMessage()));
}
} else {
IOUtils.errorBox(Messages.getString("renameErrorDialog.text"),
......
package org.vadere.gui.projectview.view;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.topographycreator.control.ActionScenarioChecker;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.simulator.projects.Scenario;
import java.awt.*;
import javax.swing.*;
public class ScenarioCheckerPanel extends JPanel {
private final static ImageIcon iconRed = new ImageIcon(Resources.class.getResource("/icons/light_red1.png"));
private final static ImageIcon iconYellow = new ImageIcon(Resources.class.getResource("/icons/light_yellow1.png"));
private final static ImageIcon iconGreen = new ImageIcon(Resources.class.getResource("/icons/light_green1.png"));
private JLabel lblmsg;
private JButton btnChecker;
private ActionScenarioChecker action;
public ScenarioCheckerPanel(){
setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 0));
lblmsg = new JLabel();
add(lblmsg);
btnChecker = new JButton(iconGreen);
btnChecker.setText("");
add(btnChecker);
action = new ActionScenarioChecker("ScenarioChecker", this);
btnChecker.addActionListener(action);
setRed();
setMsgErr();
}
public void check(final Scenario scenario){
action.check(scenario);
}
public void setRed(){
btnChecker.setIcon(iconRed);
}
public void setYellow(){
btnChecker.setIcon(iconYellow);
}
public void setGreen(){
btnChecker.setIcon(iconGreen);
}
public void setMsgOK(){
lblmsg.setText(Messages.getString("ScenarioChecker.msg.ok"));
}
public void setMsgWarn(){
lblmsg.setText(Messages.getString("ScenarioChecker.msg.warn"));
}
public void setMsgErr(){
lblmsg.setText(Messages.getString("ScenarioChecker.msg.err"));
}
public void observerIDrawPanelModel(IDrawPanelModel model){
action.observerModel(model);
}
public void stopObserver(){
btnChecker.removeActionListener(action);
action = new ActionScenarioChecker("ScenarioChecker", this);
btnChecker.addActionListener(action);
}
private JButton addActionToToolbar(final JToolBar toolbar, final Action action,
final String toolTipProperty) {
JButton button = toolbar.add(action);
button.setBorderPainted(false);
button.setToolTipText(Messages.getString(toolTipProperty));
return button;
}
}
......@@ -43,6 +43,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
private DataProcessingView dataProcessingGUIview; // DataProcessing
private TopographyWindow topographyCreatorView; // Topography creator tab... OR:
private final PostvisualizationWindow postVisualizationView; // Post-Visualization tab, replaces Topography tab if output is selected
private ScenarioCheckerPanel scenarioCheckerPanel;
// during simulation-run, only this is shown instead of the tabs above:
private final OnlineVisualization onlineVisualization;
......@@ -64,7 +65,7 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
this.postVisualizationView = new PostvisualizationWindow(model.getCurrentProjectPath());
this.model = model;
setBorder(new EmptyBorder(5, 5, 5, 5));
setBorder(new EmptyBorder(0, 0, 0, 0));
setLayout(new CardLayout(0, 0));
setBounds(0, 0, 500, 100);
}
......@@ -75,25 +76,36 @@ public class ScenarioPanel extends JPanel implements IProjectChangeListener, Pro
// Edit card...
JPanel editCard = new JPanel();
editCard.setBorder(new EmptyBorder(5, 5, 5, 5));
editCard.setLayout(new BorderLayout(0, 0));
editCard.setBorder(new EmptyBorder(0, 0, 0, 0));
editCard.setLayout(new BorderLayout(0, 5));
editCard.setBounds(0, 0, 500, 100);
tabbedPane = new JTabbedPane(SwingConstants.TOP);
editCard.add(tabbedPane, BorderLayout.CENTER);
tabbedPane.addChangeListener(e -> { // TODO what's happening here? can this be simplified?
scenarioCheckerPanel = new ScenarioCheckerPanel();
editCard.add(scenarioCheckerPanel, BorderLayout.SOUTH);
tabbedPane.addChangeListener(e -> {
// remove ScenarioChecker listener if exists
scenarioCheckerPanel.stopObserver();
int index = tabbedPane.getSelectedIndex();
if (index >= 0 && topographyFileView != null
&& index == tabbedPane.indexOfTab(Messages.getString("Tab.Topography.title"))
&& scenario != null) {
topographyFileView.setVadereScenario(scenario);
}
if (index >= 0 && topographyFileView != null
} else if (index >= 0 && topographyCreatorView != null
&& index == tabbedPane.indexOfTab(Messages.getString("Tab.TopographyCreator.title"))
&& scenario != null) {
setTopography(scenario.getTopography());
scenarioCheckerPanel.observerIDrawPanelModel(topographyCreatorView.getPanelModel());
return;
}
scenarioCheckerPanel.check(scenario);
});
attributesSimulationView =
new TextView("/attributes", "default_directory_attributes", AttributeType.SIMULATION);
......
package org.vadere.gui.topographycreator.control;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import org.vadere.gui.projectview.view.JsonValidIndicator;
import org.vadere.gui.projectview.view.ScenarioCheckerPanel;
import org.vadere.gui.projectview.view.ScenarioPanel;
import org.vadere.gui.projectview.view.VDialogManager;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import org.vadere.simulator.util.TopographyChecker;
import org.vadere.simulator.util.TopographyCheckerMessage;
import org.vadere.simulator.util.TopographyCheckerMessageType;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.util.ScenarioChecker;
import org.vadere.simulator.util.ScenarioCheckerMessage;
import org.vadere.state.scenario.ScenarioElement;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.PriorityQueue;
......@@ -21,27 +19,25 @@ import java.util.PriorityQueue;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
public class ActionTopographyCheckerMenu extends TopographyAction implements Observer {
public class ActionScenarioChecker extends AbstractAction implements Observer {
private final static ImageIcon iconRed = new ImageIcon(Resources.class.getResource("/icons/light_red_icon.png"));
private final static ImageIcon iconYellow = new ImageIcon(Resources.class.getResource("/icons/light_yellow_icon.png"));
private final static ImageIcon iconGreen = new ImageIcon(Resources.class.getResource("/icons/light_green_icon.png"));
private final JsonValidIndicator jsonValidIndicator;
private PriorityQueue<TopographyCheckerMessage> errorMsg;
private PriorityQueue<TopographyCheckerMessage> warnMsg;
private PriorityQueue<ScenarioCheckerMessage> errorMsg;
private PriorityQueue<ScenarioCheckerMessage> warnMsg;
private MsgDocument msgDocument;
public ActionTopographyCheckerMenu(String name, IDrawPanelModel<?> panelModel, JsonValidIndicator jsonValidIndicator) {
super(name, iconYellow, panelModel);
this.jsonValidIndicator = jsonValidIndicator;
private IDrawPanelModel model;
private ScenarioCheckerPanel view;
public
ActionScenarioChecker(String name, ScenarioCheckerPanel view) {
super(name);
this.errorMsg = new PriorityQueue<>();
this.warnMsg = new PriorityQueue<>();
panelModel.addObserver(this);
this.view = view;
}
/**
* Handel click on traffic light icon and show all TopographyChecker messages generated for the
* Handel click on traffic light icon and show all ScenarioChecker messages generated for the
* current state of the topography.
*/
@Override
......@@ -54,29 +50,42 @@ public class ActionTopographyCheckerMenu extends TopographyAction implements Obs
);
}
public void observerModel(IDrawPanelModel model){
model.addObserver(this);
this.model = model;
}
/**
* After each change of the Topography which yields a valid json representation check run the
* {@link TopographyChecker} and change the icon respectively. This function also creates the
* {@link ScenarioChecker} and change the icon respectively. This function also creates the
* message document presented in various dialog windows.
*/
@Override
public void update(Observable o, Object arg) {
if (jsonValidIndicator.isValid()) {
TopographyChecker checker = new TopographyChecker(getScenarioPanelModel().getTopography());
errorMsg.clear();
warnMsg.clear();
ScenarioPanel.setActiveTopographyErrorMsg(null);
addMsg(checker.checkBuildingStep());
if(model != null){
check(model.getScenario());
}
}
putValue(Action.SMALL_ICON, iconGreen);
public void check(final Scenario scenario){
ScenarioChecker checker = new ScenarioChecker(scenario);
errorMsg.clear();
warnMsg.clear();
ScenarioPanel.setActiveTopographyErrorMsg(null);
addMsg(checker.checkBuildingStep());
if (warnMsg.size() > 0) {
putValue(Action.SMALL_ICON, iconYellow);
}
view.setGreen();
view.setMsgOK();
if (errorMsg.size() > 0) {
putValue(Action.SMALL_ICON, iconRed);
}
if (warnMsg.size() > 0) {
view.setYellow();
view.setMsgWarn();
}
if (errorMsg.size() > 0) {
view.setRed();
view.setMsgErr();
}
}
......@@ -107,7 +116,7 @@ public class ActionTopographyCheckerMenu extends TopographyAction implements Obs
}
private void msgToDocString(StringBuilder sb, TopographyCheckerMessage msg, MsgDocument doc) {
private void msgToDocString(StringBuilder sb, ScenarioCheckerMessage msg, MsgDocument doc) {
sb.append("[");
msg.getMsgTarget().getTargets().forEach(t -> {
doc.makeLink(t, sb);
......@@ -124,9 +133,9 @@ public class ActionTopographyCheckerMenu extends TopographyAction implements Obs
doc.setText(sb.toString());
}
private void addMsg(List<TopographyCheckerMessage> msg) {
private void addMsg(PriorityQueue<ScenarioCheckerMessage> msg) {
msg.forEach(m -> {
if (m.getMsgType().equals(TopographyCheckerMessageType.WARN)) {
if (m.getMsgType().getId() >= 500) {
warnMsg.add(m);
} else {
errorMsg.add(m);
......@@ -141,7 +150,7 @@ public class ActionTopographyCheckerMenu extends TopographyAction implements Obs
/**
* Simple {@link JEditorPane} wrapper which manages the links within the document to highlight
* the {@link ScenarioElement} producing the error / warning.
* the {@link ScenarioElement} producing the topographyError / topographyWarning.
*/
class MsgDocument extends JEditorPane {
HashMap<String, ScenarioElement> linkMap;
......@@ -156,7 +165,9 @@ public class ActionTopographyCheckerMenu extends TopographyAction implements Obs
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
ScenarioElement element = linkMap.getOrDefault(e.getDescription(), null);
if (element != null) {
getScenarioPanelModel().setSelectedElement(element);
if (model != null){
model.setSelectedElement(element);
}
}
}
});
......
......@@ -143,6 +143,8 @@ public interface IDrawPanelModel<T extends DefaultConfig> extends IDefaultModel<
ScenarioElementType getCurrentType();
Scenario getScenario();
void setTopography(Topography topography);
@Override
......
......@@ -94,7 +94,9 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
this.addObserver(scenarioObserver);
}
@Override
public Scenario getScenario() {
scenario.setTopography(topographyBuilder.build());
return scenario;
}
......@@ -120,16 +122,16 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
public void scaleTopography(final double scale) {
/*
* scalingFactor = scale;
* double error = boundaryWidth - (boundaryWidth * scalingFactor);
* double topographyError = boundaryWidth - (boundaryWidth * scalingFactor);
* Set<Entry<String, ShapeCategory<ScenarioShape>>> entrySet = shapes.entrySet();
* for (Entry<String, ShapeCategory<ScenarioShape>> entry : entrySet) {
* for (ScenarioShape ss : entry.getValue()) {
* if (entry.getKey().equals("pedestrians")
* || (entry.getKey().equals("sources") && ss.getShape() instanceof Ellipse2D.Double)) {
* ss.setPosition(ss.getX() * scalingFactor + error, ss.getY() * scalingFactor + error);
* ss.setPosition(ss.getX() * scalingFactor + topographyError, ss.getY() * scalingFactor + topographyError);
* } else {
* ss.scale(scalingFactor, scalingFactor);
* ss.setPosition(ss.getX() + error, ss.getY() + error);
* ss.setPosition(ss.getX() + topographyError, ss.getY() + topographyError);
* }
* }
* }
......@@ -137,8 +139,8 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
*
* setScenarioBound(new Rectangle2D.Double(scenarioBound.x * scalingFactor, scenarioBound.y
* * scalingFactor,
* scenarioBound.width * scalingFactor + 2 * error, scenarioBound.height * scalingFactor + 2
* * error));
* scenarioBound.width * scalingFactor + 2 * topographyError, scenarioBound.height * scalingFactor + 2
* * topographyError));
* // boundaryWidth *= scalingFactor; // not supported in vadere!
* setChanged();
*/
......
......@@ -29,7 +29,7 @@ import org.vadere.gui.topographycreator.control.ActionSelectCut;
import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import org.vadere.gui.topographycreator.control.ActionSwitchCategory;
import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode;
import org.vadere.gui.topographycreator.control.ActionTopographyCheckerMenu;
import org.vadere.gui.topographycreator.control.ActionScenarioChecker;
import org.vadere.gui.topographycreator.control.ActionTopographyMakroMenu;
import org.vadere.gui.topographycreator.control.ActionUndo;