Commit e176991b authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

In "SettingsDialog.java", added option "chShowPedestrianInOutGroup" to...

In "SettingsDialog.java", added option "chShowPedestrianInOutGroup" to visualize "pedestrian.getGroupMembership()"
parent 501aae32
......@@ -222,6 +222,7 @@ ProjectView.mntmCopyOutputDir.text=Copy output path to clipboard
SettingsDialog.chbInterpolatePositions.text=Interpolate Positions
SettingsDialog.chbShowPedestrianIds.text=Show PedestrianIds
SettingsDialog.chbShowPedestrianInOutGroup.text=Show Pedestrian In/Outgroup
PostVis.chShowEvacTimeColor.text=Coloring by Evacuation Times
PostVis.chShowCriteriaColor.text=Coloring by Predicate
......
......@@ -224,6 +224,7 @@ ProjectView.mntmCopyOutputDir.text=Kopiere Output Pfad in Zwischenablage
SettingsDialog.chbInterpolatePositions.text=Interpoliere Positionen
SettingsDialog.chbShowPedestrianIds.text=Fu\u00dfg\u00E4nger-Ids anzeigen
SettingsDialog.chbShowPedestrianInOutGroup.text=Zeige \"In/Outgroup\" von Fu\u00dfg\u00E4ngern
PostVis.additional.border.text=PostVis
PostVis.chShowEvacTimeColor.text=F\u00e4rbe nach Evakuierungszeit
PostVis.chShowCriteriaColor.text=F\u00e4rbung nach Bedingung
......
......@@ -23,6 +23,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private boolean interpolatePositions = true;
private boolean showPedestrianIds = false;
private boolean showPedestrianInOutGroup = false;
private boolean showTargets = true;
private boolean showTargetChangers = true;
private boolean showAbsorbingAreas = true;
......@@ -65,6 +66,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
}
this.showPedestrianIds = config.showPedestrianIds;
this.showPedestrianInOutGroup = config.showPedestrianInOutGroup;
this.gridWidth = config.gridWidth;
this.showDensity = config.showDensity;
this.showTargetPotentialField = config.showTargetPotentialField;
......@@ -332,10 +334,16 @@ public class DefaultSimulationConfig extends DefaultConfig {
return showPedestrianIds;
}
public boolean isShowPedestrianInOutGroup() { return showPedestrianInOutGroup; }
public void setShowPedestrianIds(final boolean showPedestrianIds) {
this.showPedestrianIds = showPedestrianIds;
}
public void setShowPedestrianInOutGroup(final boolean showPedestrianInOutGroup) {
this.showPedestrianInOutGroup = showPedestrianInOutGroup;
}
public boolean isShowFaydedPedestrians() {
return false;
}
......
......@@ -4,10 +4,8 @@ import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.meshing.mesh.gen.MeshRenderer;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Stairs;
import org.vadere.state.psychology.cognition.GroupMembership;
import org.vadere.state.scenario.*;
import org.vadere.util.config.VadereConfig;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.geometry.shapes.Vector2D;
......@@ -359,6 +357,13 @@ public abstract class DefaultRenderer {
g.setColor(c);
}
protected void renderPedestrianInOutGroup(final Graphics2D g, Pedestrian pedestrian) {
Color groupMembershipColor = GroupMembership.getColor(pedestrian.getGroupMembership());
g.setColor(groupMembershipColor);
g.setStroke(new BasicStroke(getSelectedShapeBorderLineWidth()));
draw(pedestrian.getShape(), g);
}
protected static void drawArrow(Graphics2D g2, double theta, double x0, double y0) {
float barb = 0.3f;
......
......@@ -372,7 +372,7 @@ public class SettingsDialog extends JDialog {
BorderFactory.createTitledBorder(Messages.getString("SettingsDialog.additional.border.text")));
FormLayout otherSettingsLayout = new FormLayout(createCellsWithSeparators(4), // col
createCellsWithSeparators(16)); // rows
createCellsWithSeparators(18)); // rows
otherSettingsPane.setLayout(otherSettingsLayout);
// For each scenario element, add a checkbox to toggle its visibility.
......@@ -385,6 +385,7 @@ public class SettingsDialog extends JDialog {
JCheckBox chShowStairs = new JCheckBox((Messages.getString("SettingsDialog.chbShowStairs.text")));
JCheckBox chShowTargetChangers = new JCheckBox((Messages.getString("SettingsDialog.chbShowTargetChangers.text")));
JCheckBox chShowPedIds = new JCheckBox((Messages.getString("SettingsDialog.chbShowPedestrianIds.text")));
JCheckBox chShowPedestrianInOutGroup = new JCheckBox((Messages.getString("SettingsDialog.chbShowPedestrianInOutGroup.text")));
JCheckBox chHideVoronoiDiagram = new JCheckBox((Messages.getString("SettingsDialog.chbHideVoronoiDiagram.text")));
chInterpolatePositions.setSelected(model.config.isInterpolatePositions());
......@@ -452,6 +453,12 @@ public class SettingsDialog extends JDialog {
model.notifyObservers();
});
chShowPedestrianInOutGroup.setSelected(model.config.isShowPedestrianInOutGroup());
chShowPedestrianInOutGroup.addItemListener(e -> {
model.config.setShowPedestrianInOutGroup(!model.config.isShowPedestrianInOutGroup());
model.notifyObservers();
});
int row = 0;
int column = 2;
int colSpan = 5;
......@@ -467,6 +474,7 @@ public class SettingsDialog extends JDialog {
otherSettingsPane.add(chShowMeasurementAreas, cc.xyw(column, row += NEXT_CELL, colSpan));
otherSettingsPane.add(chShowTargetChangers, cc.xyw(column, row += NEXT_CELL, colSpan));
otherSettingsPane.add(chShowPedIds, cc.xyw(column, row += NEXT_CELL, colSpan));
otherSettingsPane.add(chShowPedestrianInOutGroup, cc.xyw(column, row += NEXT_CELL, colSpan));
JCheckBox chChowLogo = new JCheckBox(Messages.getString("SettingsDialog.chbLogo.text"));
chChowLogo.setSelected(model.config.isShowLogo());
......
......@@ -109,6 +109,7 @@ public class ThreatCognitionModel implements ICognitionModel {
* accelerate and search for a safe zone.
*/
private void imitateThreatenedPedestrianIfPresent(Pedestrian pedestrian) {
// TODO: Use only pedestrians with GroupMembership.IN_GROUP!
// TODO: Maybe, alse look for "SelfCategory.INSIDE_THREAT_AREA".
List<Pedestrian> threatenedPedestrians = getClosestPedestriansWithSelfCategory(pedestrian, SelfCategory.OUTSIDE_THREAT_AREA);
......@@ -116,7 +117,7 @@ public class ThreatCognitionModel implements ICognitionModel {
Pedestrian threatenedPedestrian = threatenedPedestrians.get(0);
Threat latestThreat = threatenedPedestrian.getThreatMemory().getLatestThreat();
assert latestThreat != null;
assert latestThreat != null;
handleThreat(pedestrian, latestThreat);
} else {
......
package org.vadere.state.psychology.cognition;
import java.awt.*;
/**
* According to the self-categorization theory ("reicher-2010"), people define
* themselves as a member of social categories (see{@link SelfCategory}). When
......@@ -43,5 +45,24 @@ public enum GroupMembership {
OUT_GROUP,
OUT_GROUP_FRIENDLY,
OUT_GROUP_NEUTRAL,
OUT_GROUP_HOSTILE
OUT_GROUP_HOSTILE;
/** Use this color palette: https://www.color-hex.com/color-palette/38840 */
public static Color getColor(GroupMembership groupMembership) {
Color color = Color.BLACK;
if (groupMembership == IN_GROUP) {
color = new Color(213,94,0);
} else if (groupMembership == OUT_GROUP) {
color = new Color(0,0,0);
} else if (groupMembership == OUT_GROUP_FRIENDLY) {
color = new Color(0,135,98);
} else if (groupMembership == OUT_GROUP_NEUTRAL) {
color = new Color(153,153,153);
} else if (groupMembership == OUT_GROUP_HOSTILE) {
color = new Color(229,229,0);
}
return color;
}
}
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