Commit 9c6e3ce0 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Merge branch 'event_handling_add_bang'

parents 318187b0 b14b087c
Pipeline #92820 failed with stages
in 8 minutes and 41 seconds
......@@ -6,6 +6,9 @@
### Added
- Added new scenario element `AbsorbingArea` to absorb agents immediately.
* The new scenario element can be selected in `TopographyCreator` via the "emergency exit" button.
* The new scenario element is also taken into account by `SettingsDialaog` and `TikzGenerator`.
- Configured 1-click-deployment in ".gitlab-ci.yml".
* In short: Vadere is packaged as a single ZIP file containing following build artifacts: README.md VadereModelTests/ VadereGui/target/vadere.jar VadereSimulator/target/vadere-console.jar
* Vadere is packaged for GNU/Linux and Microsoft Windows.
......
......@@ -229,6 +229,7 @@ SettingsDialog.chbHideVoronoiDiagram.text=Hide VoronoiDiagram
SettingsDialog.chbShowObstacles.text=Show Obstacles
SettingsDialog.chbShowTargets.text=Show Targets
SettingsDialog.chbShowSources.text=Show Sources
SettingsDialog.chbShowAbsorbingAreas.text=Show Absorbing Areas
SettingsDialog.chbShowStairs.text=Show Stairs
ProjectView.btnSnapshot.tooltip=Snapshot
ProjectView.btnPNGSnapshot.tooltip=PNG Snapshot
......@@ -269,6 +270,7 @@ SettingsDialog.lblPedTrajColor.text=Pedestrians & Trajectories
SettingsDialog.lblCellWidth.text=Cell Width
SettingsDialog.btnClose.text=Close
SettingsDialog.lblDensityColor.text=Density
SettingsDialog.lblAbsorbingAreaColor.text=Absorbing Area
SettingsDialog.lblStair.text=Stair
SettingsDialog.lblPedestrianNoTarget.text=Without Target (-1)
ProjectView.menuOpenFloorFieldFile.title=Add Floor Field File...
......@@ -306,6 +308,7 @@ TopographyCreator.btnTranslation.tooltip=Translate topography
TopographyCreator.btnElementTranslation.tooltip=Translate topography elements
TopographyCreator.btnInsertObstacle.tooltip=Obstacle
TopographyCreator.btnInsertTarget.tooltip=Target
TopographyCreator.btnInsertAbsorbingArea.tooltip=Absorbing Area
TopographyCreator.btnInsertSource.tooltip=Source
TopographyCreator.btnInsertStairs.tooltip=Stairs
TopographyCreator.btnErase.tooltip=Eraser
......
......@@ -225,6 +225,7 @@ SettingsDialog.chbHideVoronoiDiagram.text=Voronoi-Diagramm nicht anzeigen
SettingsDialog.chbShowObstacles.text=Hindernisse anzeigen
SettingsDialog.chbShowTargets.text=Ziele anzeigen
SettingsDialog.chbShowSources.text=Quellen anzeigen
SettingsDialog.chbShowAbsorbingAreas.text=Absorbierende Bereiche anzeigen
SettingsDialog.chbShowStairs.text=Treppen anzeigen
ProjectView.btnSnapshot.tooltip=Snapshot
ProjectView.btnPNGSnapshot.tooltip=PNG-Snapshot
......@@ -265,6 +266,7 @@ SettingsDialog.lblPedTrajColor.text=Fu\u00dfg\u00e4nger & Trajektorien
SettingsDialog.lblCellWidth.text=Zellbreite
SettingsDialog.btnClose.text=Schlie\u00dfen
SettingsDialog.lblDensityColor.text=Dichte
SettingsDialog.lblAbsorbingAreaColor.text=Absorbierender Bereich
SettingsDialog.lblStair.text=Treppe
SettingsDialog.lblPedestrianNoTarget.text=Ohne Ziel (-1)
SettingsDialog.menuOpenFloorFieldFile.title=Floor Field-Datei hinzuf\u00fcgen...
......@@ -298,6 +300,7 @@ TopographyCreator.btnCutTopography.tooltip=Szenario ausschneiden
TopographyCreator.btnInsertPedestrian.tooltip=Fu\u00dfg\u00e4nger
TopographyCreator.btnInsertObstacle.tooltip=Hindernis
TopographyCreator.btnInsertTarget.tooltip=Ziel
TopographyCreator.btnInsertAbsorbingArea.tooltip=Absorbierender Bereich
TopographyCreator.btnTopographyBound.tooltip=Topographie Grenze
TopographyCreator.btnTranslation.tooltip=Topographie verschieben
TopographyCreator.btnElementTranslation.tooltip=Elemente der Topography verschieben
......
package org.vadere.gui.components.control.simulation;
import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel;
import javax.swing.*;
import java.awt.*;
public class ActionSetAbsorbingAreaColor extends ActionSetColor {
public ActionSetAbsorbingAreaColor(String name, SimulationModel<? extends DefaultSimulationConfig> model, JPanel coloredPanel) {
super(name, model, coloredPanel);
}
@Override
protected void saveColor(Color color) {
model.config.setAbsorbingAreaColor(color);
}
}
......@@ -6,6 +6,7 @@ public class DefaultConfig {
private Color obstacleColor = new Color(0.7f,0.7f,0.7f);
private Color sourceColor = new Color(0.3333333333333333f, 0.6588235294117647f, 0.40784313725490196f);
private Color targetColor = new Color(0.8666666666666667f, 0.51764705882352946f, 0.32156862745098042f);
private Color absorbingAreaColor = new Color(0.76863f,0.30588f, 0.32157f);
private Color densityColor = Color.RED;
private Color stairColor = new Color(0.5058823529411764f, 0.4470588235294118f, 0.6980392156862745f);
private Color pedestrianColor = new Color(0.2980392156862745f, 0.4470588235294118f, 0.7901960784313725f);
......@@ -16,6 +17,7 @@ public class DefaultConfig {
public DefaultConfig(final DefaultConfig config) {
this.sourceColor = config.sourceColor;
this.targetColor = config.targetColor;
this.absorbingAreaColor = config.absorbingAreaColor;
this.densityColor = config.densityColor;
this.obstacleColor = config.obstacleColor;
this.stairColor = config.stairColor;
......@@ -62,6 +64,15 @@ public class DefaultConfig {
setChanged();
}
public Color getAbsorbingAreaColor() {
return absorbingAreaColor;
}
public void setAbsorbingAreaColor(final Color absorbingAreaColor) {
this.absorbingAreaColor = absorbingAreaColor;
setChanged();
}
public void setDensityColor(final Color densityColor) {
this.densityColor = densityColor;
setChanged();
......
......@@ -102,6 +102,9 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
case TARGET:
c = getConfig().getTargetColor();
break;
case ABSORBING_AREA:
c = getConfig().getAbsorbingAreaColor();
break;
default:
c = Color.RED;
}
......
......@@ -20,6 +20,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private boolean useRandomPedestrianColors = false;
private boolean showPedestrianIds = false;
private boolean showTargets = true;
private boolean showAbsorbingAreas = true;
private boolean showSources = true;
private boolean showObstacles = true;
private boolean showStairs = true;
......@@ -112,6 +113,10 @@ public class DefaultSimulationConfig extends DefaultConfig {
return showTargets;
}
public boolean isShowAbsorbingAreas() {
return showAbsorbingAreas;
}
public void setShowTargetPotentielFieldMesh(final boolean showTargetPotentielFieldMesh) {
this.showTargetPotentielFieldMesh = showTargetPotentielFieldMesh;
setChanged();
......@@ -135,6 +140,11 @@ public class DefaultSimulationConfig extends DefaultConfig {
setChanged();
}
public void setShowAbsorbingAreas(boolean showAbsorbingAreas) {
this.showAbsorbingAreas = showAbsorbingAreas;
setChanged();
}
public boolean isShowObstacles() {
return showObstacles;
}
......
......@@ -3,14 +3,7 @@ package org.vadere.gui.components.view;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import org.vadere.gui.components.control.simulation.ActionSetDensityColor;
import org.vadere.gui.components.control.simulation.ActionSetObstacleColor;
import org.vadere.gui.components.control.simulation.ActionSetPedestrianColor;
import org.vadere.gui.components.control.simulation.ActionSetPedestrianWithoutTargetColor;
import org.vadere.gui.components.control.simulation.ActionSetSnapshotDirectory;
import org.vadere.gui.components.control.simulation.ActionSetSourceColor;
import org.vadere.gui.components.control.simulation.ActionSetStairsColor;
import org.vadere.gui.components.control.simulation.ActionSetTargetColor;
import org.vadere.gui.components.control.simulation.*;
import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.components.utils.Messages;
......@@ -94,9 +87,9 @@ public class SettingsDialog extends JDialog {
// Layout definition for sub panels
FormLayout additionalLayout = new FormLayout("5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu", // col
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"); // rows
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"); // rows
FormLayout colorLayout = new FormLayout("5dlu, pref, 2dlu, pref:grow, 2dlu, pref, 2dlu, pref, 5dlu", // col
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"); // rows
"5dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 5dlu"); // rows
colorLayeredPane.setLayout(colorLayout);
additionalLayeredPane.setLayout(additionalLayout);
......@@ -113,6 +106,7 @@ public class SettingsDialog extends JDialog {
JCheckBox chShowObstacles = new JCheckBox((Messages.getString("SettingsDialog.chbShowObstacles.text")));
JCheckBox chShowTargets = new JCheckBox((Messages.getString("SettingsDialog.chbShowTargets.text")));
JCheckBox chShowSources = new JCheckBox((Messages.getString("SettingsDialog.chbShowSources.text")));
JCheckBox chShowAbsorbingAreas = new JCheckBox((Messages.getString("SettingsDialog.chbShowAbsorbingAreas.text")));
JCheckBox chShowStairs = new JCheckBox((Messages.getString("SettingsDialog.chbShowStairs.text")));
JCheckBox chShowPedIds = new JCheckBox((Messages.getString("SettingsDialog.chbShowPedestrianIds.text")));
......@@ -147,6 +141,12 @@ public class SettingsDialog extends JDialog {
model.notifyObservers();
});
chShowAbsorbingAreas.setSelected(model.config.isShowAbsorbingAreas());
chShowAbsorbingAreas.addItemListener(e -> {
model.config.setShowAbsorbingAreas(!model.config.isShowAbsorbingAreas());
model.notifyObservers();
});
chShowStairs.setSelected(model.config.isShowSources());
chShowStairs.addItemListener(e -> {
model.config.setShowStairs(!model.config.isShowStairs());
......@@ -177,8 +177,9 @@ public class SettingsDialog extends JDialog {
colorLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblSource.text") + ":"), cc.xy(2, 6));
colorLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblStair.text") + ":"), cc.xy(2, 8));
colorLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblDensityColor.text") + ":"), cc.xy(2, 10));
colorLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblAbsorbingAreaColor.text") + ":"), cc.xy(2, 12));
colorLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblPedestrianNoTarget.text") + ":"),
cc.xy(2, 18));
cc.xy(2, 20));
final JButton bObstColor = new JButton(Messages.getString("SettingsDialog.btnEditColor.text"));
final JPanel pObstacleColor = new JPanel();
......@@ -220,12 +221,20 @@ public class SettingsDialog extends JDialog {
colorLayeredPane.add(pDensityColor, cc.xy(4, 10));
colorLayeredPane.add(bDensityColor, cc.xy(6, 10));
colorLayeredPane.add(new JSeparator(), cc.xyw(1, 12, 9));
final JButton bAbsorbingAreaColor = new JButton(Messages.getString("SettingsDialog.btnEditColor.text"));
final JPanel pAbsorbingAreaColor = new JPanel();
pAbsorbingAreaColor.setBackground(model.config.getAbsorbingAreaColor());
pAbsorbingAreaColor.setPreferredSize(new Dimension(130, 20));
bAbsorbingAreaColor.addActionListener(new ActionSetAbsorbingAreaColor("Set Absorbing Area Color", model, pAbsorbingAreaColor));
colorLayeredPane.add(pAbsorbingAreaColor, cc.xy(4, 12));
colorLayeredPane.add(bAbsorbingAreaColor, cc.xy(6, 12));
colorLayeredPane.add(new JSeparator(), cc.xyw(1, 14, 9));
colorLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblPedTrajColor.text") + ":"),
cc.xyw(2, 14, 5));
colorLayeredPane.add(jComoboTargetIds, cc.xy(2, 16));
colorLayeredPane.add(pPedestrian, cc.xy(4, 16));
colorLayeredPane.add(bChange, cc.xy(6, 16));
cc.xyw(2, 16, 5));
colorLayeredPane.add(jComoboTargetIds, cc.xy(2, 18));
colorLayeredPane.add(pPedestrian, cc.xy(4, 18));
colorLayeredPane.add(bChange, cc.xy(6, 18));
final JButton bPedestrianNoTarget = new JButton(Messages.getString("SettingsDialog.btnEditColor.text"));
final JPanel pPedestrianNoTarget = new JPanel();
......@@ -234,8 +243,8 @@ public class SettingsDialog extends JDialog {
pPedestrianNoTarget.setPreferredSize(new Dimension(130, 20));
bPedestrianNoTarget.addActionListener(new ActionSetPedestrianWithoutTargetColor(
"Set Pedestrian without Target Color", model, pPedestrianNoTarget));
colorLayeredPane.add(pPedestrianNoTarget, cc.xy(4, 18));
colorLayeredPane.add(bPedestrianNoTarget, cc.xy(6, 18));
colorLayeredPane.add(pPedestrianNoTarget, cc.xy(4, 20));
colorLayeredPane.add(bPedestrianNoTarget, cc.xy(6, 20));
// 20 is free
......@@ -245,7 +254,7 @@ public class SettingsDialog extends JDialog {
model.config.setUseRandomPedestrianColors(!model.config.isUseRandomPedestrianColors());
model.notifyObservers();
});
colorLayeredPane.add(chRandomColors, cc.xyw(2, 22, 8));
colorLayeredPane.add(chRandomColors, cc.xyw(2, 24, 8));
additionalLayeredPane.add(chHideVoronoiDiagram, cc.xyw(2, 2, 5));
......@@ -253,19 +262,28 @@ public class SettingsDialog extends JDialog {
additionalLayeredPane.add(chShowTargets, cc.xyw(2, 6, 5));
additionalLayeredPane.add(chShowSources, cc.xyw(2, 8, 5));
additionalLayeredPane.add(chShowStairs, cc.xyw(2, 10, 5));
additionalLayeredPane.add(chShowPedIds, cc.xyw(2, 12, 5));
additionalLayeredPane.add(chShowAbsorbingAreas, cc.xyw(2, 12, 5));
additionalLayeredPane.add(chShowPedIds, cc.xyw(2, 14, 5));
JCheckBox chChowLogo = new JCheckBox(Messages.getString("SettingsDialog.chbLogo.text"));
chChowLogo.setSelected(model.config.isShowLogo());
chChowLogo.addItemListener(e -> {
model.config.setShowLogo(!model.config.isShowLogo());
model.notifyObservers();
});
additionalLayeredPane.add(chChowLogo, cc.xyw(2, 16, 5));
additionalLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblSnapshotDir.text") + ":"),
cc.xy(2, 14));
cc.xy(2, 18));
JTextField tSnapshotDir = new JTextField(
Preferences.userNodeForPackage(PostVisualisation.class).get("SettingsDialog.snapshotDirectory.path", "."));
tSnapshotDir.setEditable(false);
tSnapshotDir.setPreferredSize(new Dimension(130, 20));
additionalLayeredPane.add(tSnapshotDir, cc.xy(4, 14));
additionalLayeredPane.add(tSnapshotDir, cc.xy(4, 18));
final JButton bSnapshotDir = new JButton(Messages.getString("SettingsDialog.btnEditSnapshot.text"));
bSnapshotDir.addActionListener(new ActionSetSnapshotDirectory("Set Snapshot Directory", model, tSnapshotDir));
additionalLayeredPane.add(bSnapshotDir, cc.xy(6, 14));
additionalLayeredPane.add(bSnapshotDir, cc.xy(6, 18));
final JSpinner spinnerCellWidth = new JSpinner();
final SpinnerNumberModel sModelCellWidth = new SpinnerNumberModel(model.config.getGridWidth(),
......@@ -278,17 +296,8 @@ public class SettingsDialog extends JDialog {
});
additionalLayeredPane.add(new JLabel(Messages.getString("SettingsDialog.lblCellWidth.text") + ":"),
cc.xy(2, 16));
additionalLayeredPane.add(spinnerCellWidth, cc.xy(4, 16));
JCheckBox chChowLogo = new JCheckBox(Messages.getString("SettingsDialog.chbLogo.text"));
chChowLogo.setSelected(model.config.isShowLogo());
chChowLogo.addItemListener(e -> {
model.config.setShowLogo(!model.config.isShowLogo());
model.notifyObservers();
});
additionalLayeredPane.add(chChowLogo, cc.xyw(2, 18, 5));
cc.xy(2, 20));
additionalLayeredPane.add(spinnerCellWidth, cc.xy(4, 20));
mainPanel.add(getAdditionalOptionPanel(), cc.xy(2, 6));
......
......@@ -87,6 +87,10 @@ public abstract class SimulationRenderer extends DefaultRenderer {
renderScenarioElement(model.getTopography().getTargets(), graphics, model.config.getTargetColor());
}
if (model.config.isShowAbsorbingAreas()) {
renderScenarioElement(model.getTopography().getAbsorbingAreas(), graphics, model.config.getAbsorbingAreaColor());
}
if (model.config.isShowSources()) {
renderScenarioElement(model.getTopography().getSources(), graphics, model.config.getSourceColor());
}
......
......@@ -7,14 +7,7 @@ import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.components.view.DefaultRenderer;
import org.vadere.gui.components.view.SimulationRenderer;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Source;
import org.vadere.state.scenario.Stairs;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
import org.vadere.state.scenario.*;
import org.vadere.state.simulation.Step;
import org.vadere.state.simulation.Trajectory;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -125,6 +118,9 @@ public class TikzGenerator {
Color targetColor = model.getConfig().getTargetColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "TargetColor", targetColor.getRed(), targetColor.getGreen(), targetColor.getBlue());
Color absorbingAreaColor = model.getConfig().getAbsorbingAreaColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "AbsorbingAreaColor", absorbingAreaColor.getRed(), absorbingAreaColor.getGreen(), absorbingAreaColor.getBlue());
Color obstacleColor = model.getConfig().getObstacleColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "ObstacleColor", obstacleColor.getRed(), obstacleColor.getGreen(), obstacleColor.getBlue());
......@@ -197,6 +193,15 @@ public class TikzGenerator {
generatedCode += "% Targets (not enabled in config)\n";
}
if (config.isShowAbsorbingAreas()) {
generatedCode += "% Absorbing Areas\n";
for (AbsorbingArea absorbingArea : topography.getAbsorbingAreas()) {
generatedCode += String.format(Locale.US, "\\fill[AbsorbingAreaColor] %s;\n", generatePathForScenarioElement(absorbingArea));
}
} else {
generatedCode += "% Absorbing Areas (not enabled in config)\n";
}
if (config.isShowObstacles()) {
generatedCode += "% Obstacles\n";
for (Obstacle obstacle : topography.getObstacles()) {
......
......@@ -50,7 +50,7 @@ public class SettingsDialog extends org.vadere.gui.components.view.SettingsDialo
additionalLayeredPane.add(chCleanSnapshot, cc.xy(2, 6));
JCheckBox chShowEvacTimeColor = new JCheckBox(Messages.getString("PostVis.chShowEvacTimeColor.text"));
getColorLayeredPane().add(chShowEvacTimeColor, cc.xyw(2, 24, 8));
getColorLayeredPane().add(chShowEvacTimeColor, cc.xyw(2, 26, 8));
chShowEvacTimeColor.addItemListener(e -> {
model.config.setUseEvacuationTimeColor(!model.config.isUseEvacuationTimeColor());
......@@ -58,7 +58,7 @@ public class SettingsDialog extends org.vadere.gui.components.view.SettingsDialo
});
PedestrianColorPanel pedestrianColorPanel = new PedestrianColorPanel(model.getPedestrianColorTableModel());
getColorLayeredPane().add(pedestrianColorPanel, cc.xyw(2, 20, 8));
getColorLayeredPane().add(pedestrianColorPanel, cc.xyw(2, 22, 8));
......
......@@ -12,14 +12,7 @@ import org.vadere.gui.topographycreator.control.AttributeModifier;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.attributes.scenario.AttributesCar;
import org.vadere.state.attributes.scenario.AttributesTopography;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Source;
import org.vadere.state.scenario.Stairs;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Teleporter;
import org.vadere.state.scenario.Topography;
import org.vadere.state.scenario.*;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
......@@ -42,6 +35,7 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
private LinkedList<Stairs> stairs;
private LinkedList<Source> sources;
private LinkedList<Target> targets;
private LinkedList<AbsorbingArea> absorbingAreas;
private Teleporter teleporter;
private LinkedList<ScenarioElement> topographyElements;
private AttributesTopography attributes;
......@@ -57,6 +51,7 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
stairs = new LinkedList<>();
sources = new LinkedList<>();
targets = new LinkedList<>();
absorbingAreas = new LinkedList<>();
topographyElements = new LinkedList<>();
attributes = new AttributesTopography();
}
......@@ -77,6 +72,7 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
}
sources = new LinkedList<>(topography.getSources());
targets = new LinkedList<>(topography.getTargets());
absorbingAreas = new LinkedList<>(topography.getAbsorbingAreas());
teleporter = topography.getTeleporter();
} catch (SecurityException | IllegalArgumentException e) {
e.printStackTrace();
......@@ -90,6 +86,7 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
topographyElements.addAll(pedestrians);
topographyElements.addAll(sources);
topographyElements.addAll(targets);
topographyElements.addAll(absorbingAreas);
}
/**
......@@ -133,6 +130,9 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
for (Target target : targets)
topography.addTarget(target);
for (AbsorbingArea absorbingArea : absorbingAreas)
topography.addAbsorbingArea(absorbingArea);
for (AgentWrapper pedestrian : pedestrians)
topography.addInitialElement(pedestrian.getAgentInitialStore());
......@@ -167,6 +167,8 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
return pedestrians.remove(element);
case TARGET:
return targets.remove(element);
case ABSORBING_AREA:
return absorbingAreas.remove(element);
case SOURCE:
return sources.remove(element);
default:
......@@ -222,12 +224,23 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
this.targets.add(target);
}
public void addAbsorbingArea(final AbsorbingArea absorbingArea) {
this.topographyElements.add(absorbingArea);
this.absorbingAreas.add(absorbingArea);
}
public Target removeLastTarget() {
Target target = targets.removeLast();
topographyElements.remove(target);
return target;
}
public AbsorbingArea removeLastAbsorbingArea() {
AbsorbingArea absorbingArea = absorbingAreas.removeLast();
topographyElements.remove(absorbingArea);
return absorbingArea;
}
public Source removeLastSource() {
Source source = sources.removeLast();
topographyElements.remove(source);
......@@ -274,6 +287,10 @@ public class TopographyBuilder implements Iterable<ScenarioElement> {
return targets.iterator();
}
public Iterator<AbsorbingArea> getAbsorbingAreaIterator() {
return absorbingAreas.iterator();
}
public Iterator<Source> getSourceIterator() {
return sources.iterator();
}
......
......@@ -196,6 +196,9 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
case TARGET:
element = topographyBuilder.removeLastTarget();
break;
case ABSORBING_AREA:
element = topographyBuilder.removeLastAbsorbingArea();
break;
case TELEPORTER:
element = topographyBuilder.removeTeleporter();
break;
......@@ -294,6 +297,9 @@ public class TopographyCreatorModel extends DefaultModel implements IDrawPanelMo
case TARGET:
topographyBuilder.addTarget((org.vadere.state.scenario.Target) shape);
break;
case ABSORBING_AREA:
topographyBuilder.addAbsorbingArea((org.vadere.state.scenario.AbsorbingArea) shape);
break;
case TELEPORTER:
topographyBuilder.setTeleporter((org.vadere.state.scenario.Teleporter) shape);
break;
......
package org.vadere.gui.topographycreator.model;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.scenario.AttributesObstacle;
import org.vadere.state.attributes.scenario.AttributesSource;
import org.vadere.state.attributes.scenario.AttributesStairs;
import org.vadere.state.attributes.scenario.AttributesTarget;
import org.vadere.state.attributes.scenario.*;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.types.ScenarioElementType;
import org.vadere.util.geometry.shapes.Vector2D;
......@@ -35,6 +32,8 @@ public class TopographyElementFactory {
return new org.vadere.state.scenario.Source(new AttributesSource(-1, shape));
case TARGET:
return new org.vadere.state.scenario.Target(new AttributesTarget(shape));
case ABSORBING_AREA:
return new org.vadere.state.scenario.AbsorbingArea(new AttributesAbsorbingArea(shape));
case PEDESTRIAN:
return new AgentWrapper(((VCircle) shape).getCenter());
default:
......@@ -51,6 +50,8 @@ public class TopographyElementFactory {
return new org.vadere.state.scenario.Source((AttributesSource) attributes);
} else if (attributes instanceof AttributesTarget) {
return new org.vadere.state.scenario.Target((AttributesTarget) attributes);
} else if (attributes instanceof AttributesAbsorbingArea) {
return new org.vadere.state.scenario.AbsorbingArea((AttributesAbsorbingArea) attributes);
} else {
throw new IllegalArgumentException("unsupported Attributes.");
}
......
......@@ -37,6 +37,7 @@ public class TopographyCreatorRenderer extends DefaultRenderer {
renderers[ScenarioElementType.PEDESTRIAN.ordinal()] = this::renderFilledShape;
renderers[ScenarioElementType.SOURCE.ordinal()] = this::renderFilledShape;
renderers[ScenarioElementType.TARGET.ordinal()] = this::renderFilledShape;
renderers[ScenarioElementType.ABSORBING_AREA.ordinal()] = this::renderFilledShape;
renderers[ScenarioElementType.STAIRS.ordinal()] = this::renderStair;
renderers[ScenarioElementType.TELEPORTER.ordinal()] = this::renderFilledShape;
renderers[ScenarioElementType.CAR.ordinal()] = this::renderFilledShape;
......
......@@ -229,6 +229,10 @@ public class TopographyWindow extends JPanel {
TopographyAction switchToTargetAction = new ActionSwitchCategory("switch to targets", panelModel,
ScenarioElementType.TARGET, selectRectangleAction);
/* switch category to absorbing areas action */
TopographyAction switchToAbsorbingAreaAction = new ActionSwitchCategory("switch to absorbing areas", panelModel,
ScenarioElementType.ABSORBING_AREA, selectRectangleAction);
/* switch category to stairs action */
TopographyAction switchToStairsAction = new ActionSwitchCategory("switch to stairs", panelModel,
ScenarioElementType.STAIRS, selectRectangleAction);
......@@ -255,6 +259,7 @@ public class TopographyWindow extends JPanel {
List<Action> obstacleAndTargetDrawModes = new ArrayList<>();
List<Action> sourceDrawModes = new ArrayList<>();
List<Action> absorbingAreaDrawModes = new ArrayList<>();
obstacleAndTargetDrawModes.add(rectangle);
obstacleAndTargetDrawModes.add(pen);
......@@ -265,6 +270,10 @@ public class TopographyWindow extends JPanel {
sourceDrawModes.add(pen2);
sourceDrawModes.add(dot);
absorbingAreaDrawModes.add(rectangle);
absorbingAreaDrawModes.add(pen);
absorbingAreaDrawModes.add(pen2);
/* open obstacle paint method dialog action */
JButton obsButton = new JButton();
TopographyAction openObstacleDialog = new ActionOpenDrawOptionMenu(
......@@ -278,6 +287,12 @@ public class TopographyWindow extends JPanel {
.getResource("/icons/target_icon.png")), panelModel, switchToTargetAction, targetButton,
obstacleAndTargetDrawModes);
/* open absorbing area paint method dialog action */
JButton absorbingAreaButton = new JButton();
TopographyAction openAbsorbingAreaDialog = new ActionOpenDrawOptionMenu("AbsorbingArea", new ImageIcon(Resources.class
.getResource("/icons/emergency_exit.png")), panelModel, switchToAbsorbingAreaAction, absorbingAreaButton,
absorbingAreaDrawModes);
/* open stairs paint method dialog action */
JButton stairsButton = new JButton();
TopographyAction openStairsDialog = new ActionOpenDrawOptionMenu("Stairs", new ImageIcon(Resources.class
......@@ -345,6 +360,8 @@ public class TopographyWindow extends JPanel {
toolbar.addSeparator(new Dimension(5, 50));
addActionToToolbar(toolbar, openObstacleDialog, "TopographyCreator.btnInsertObstacle.tooltip",