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

Commit 099bea46 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Use same button ordering in "OnlineVisualisationWindow.java" and...

Use same button ordering in "OnlineVisualisationWindow.java" and "PostvisualizationWindow.java" and slightly adapted code in "PostvisualizationRenderer.java"
parent e4fafdba
Pipeline #258443 passed with stages
in 147 minutes and 47 seconds
...@@ -222,27 +222,22 @@ public class OnlineVisualisationWindow extends JPanel implements Observer { ...@@ -222,27 +222,22 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
mainPanel.addRendererChangeListener(generateINETenv); mainPanel.addRendererChangeListener(generateINETenv);
mainPanel.addRendererChangeListener(showPotentialField); mainPanel.addRendererChangeListener(showPotentialField);
// Pedestrian-related options
SwingUtils.addActionToToolbar(toolbar, paintPedestriansAction, SwingUtils.addActionToToolbar(toolbar, paintPedestriansAction, Messages.getString("ProjectView.btnShowPedestrian.tooltip"));
Messages.getString("ProjectView.btnShowPedestrian.tooltip")); SwingUtils.addActionToToolbar(toolbar, paintTrajectories, Messages.getString("ProjectView.btnShowTrajectories.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintTrajectories, SwingUtils.addActionToToolbar(toolbar, paintArrowAction, Messages.getString("ProjectView.btnShowWalkingDirection.tooltip"));
Messages.getString("ProjectView.btnShowTrajectories.tooltip")); SwingUtils.addActionToToolbar(toolbar, showGroupInformationAction, Messages.getString("ProjectView.btnShowGroupInformation.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintArrowAction,
Messages.getString("ProjectView.btnShowWalkingDirection.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showGroupInformationAction,
Messages.getString("ProjectView.btnShowGroupInformation.tooltip"));
SwingUtils.addActionToToolbar(toolbar, drawVoronoiDiagram,
Messages.getString("ProjectView.btnDrawVoronoiDiagram.tooltip"));
SwingUtils.addActionToToolbar(toolbar, drawMesh,
Messages.getString("ProjectView.btnDrawMesh.tooltip"));
toolbar.addSeparator(); toolbar.addSeparator();
// "Measuring" tools
SwingUtils.addActionToToolbar(toolbar, drawVoronoiDiagram, Messages.getString("ProjectView.btnDrawVoronoiDiagram.tooltip"));
SwingUtils.addActionToToolbar(toolbar, drawMesh, Messages.getString("ProjectView.btnDrawMesh.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintGridAction, Messages.getString("ProjectView.btnShowGrid.tooltip")); SwingUtils.addActionToToolbar(toolbar, paintGridAction, Messages.getString("ProjectView.btnShowGrid.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintDensity, Messages.getString("ProjectView.btnShowDensity.tooltip")); SwingUtils.addActionToToolbar(toolbar, paintDensity, Messages.getString("ProjectView.btnShowDensity.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
toolbar.addSeparator(); toolbar.addSeparator();
// Snapshot options
ArrayList<Action> imgOptions = new ArrayList<>(); ArrayList<Action> imgOptions = new ArrayList<>();
imgOptions.add(generatePNG); imgOptions.add(generatePNG);
imgOptions.add(generateSVG); imgOptions.add(generateSVG);
...@@ -253,16 +248,12 @@ public class OnlineVisualisationWindow extends JPanel implements Observer { ...@@ -253,16 +248,12 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
ActionOnlineVisMenu imgDialog = new ActionOnlineVisMenu( ActionOnlineVisMenu imgDialog = new ActionOnlineVisMenu(
"camera_menu", "camera_menu",
resources.getIcon("camera.png", iconWidth, iconHeight), imgOptions); resources.getIcon("camera.png", iconWidth, iconHeight), imgOptions);
JButton imgMenuBtn = JButton imgMenuBtn = SwingUtils.addActionToToolbar(toolbar, imgDialog, Messages.getString("ProjectView.btnSnapshot.tooltip"));
SwingUtils.addActionToToolbar(toolbar, imgDialog, Messages.getString("ProjectView.btnSnapshot.tooltip"));
imgDialog.setParent(imgMenuBtn); imgDialog.setParent(imgMenuBtn);
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
toolbar.add(Box.createHorizontalGlue()); toolbar.add(Box.createHorizontalGlue());
SwingUtils.addActionToToolbar(toolbar, openSettingsDialog, SwingUtils.addActionToToolbar(toolbar, openSettingsDialog, Messages.getString("ProjectView.btnSettings.tooltip"));
Messages.getString("ProjectView.btnSettings.tooltip"));
splitPaneForTopographyAndJsonPane = new JSplitPane(); splitPaneForTopographyAndJsonPane = new JSplitPane();
splitPaneForTopographyAndJsonPane.setResizeWeight(0.8); splitPaneForTopographyAndJsonPane.setResizeWeight(0.8);
......
...@@ -50,12 +50,9 @@ public class PostvisualizationRenderer extends SimulationRenderer { ...@@ -50,12 +50,9 @@ public class PostvisualizationRenderer extends SimulationRenderer {
renderTrajectories(g, slice, pedestrianColors); renderTrajectories(g, slice, pedestrianColors);
renderPedestrians(g, pedestrians, pedestrianColors); renderPedestrians(g, pedestrians, pedestrianColors);
renderConnectingLinesByContact(g);
g.setColor(savedColor); g.setColor(savedColor);
if (model.config.isShowContacts() && model.getContactData() != null) {
renderConnectingLinesByContact(g);
}
} }
} }
...@@ -163,35 +160,41 @@ public class PostvisualizationRenderer extends SimulationRenderer { ...@@ -163,35 +160,41 @@ public class PostvisualizationRenderer extends SimulationRenderer {
} }
private void renderConnectingLinesByContact(Graphics2D g) { private void renderConnectingLinesByContact(Graphics2D g) {
if (!model.config.isShowAllTrajectories()) return; boolean showContacts = model.config.isShowContacts() &&
Color color = g.getColor(); model.getContactData() != null &&
Stroke stroke = g.getStroke(); model.config.isShowAllTrajectories(); // TODO Why do "showContacts" depend on "showAllTrajectories"?
g.setStroke(new BasicStroke(getLineWidth() / 4.0f));
g.setColor(Color.red); if (showContacts) {
Color savedColor = g.getColor();
Collection<Pedestrian> agents = model.getPedestrians(); Stroke savedStroke = g.getStroke();
Map<Integer, VPoint> pedPositions = new HashMap<>();
agents.forEach(a -> pedPositions.put(a.getId(), a.getPosition())); g.setStroke(new BasicStroke(getLineWidth() / 4.0f));
Table pairs = model.getContactData().getPairsOfPedestriansInContactAt(model.getSimTimeInSec()); g.setColor(Color.red);
for (Row row: pairs) { Collection<Pedestrian> agents = model.getPedestrians();
int id1 = row.getInt(0); Map<Integer, VPoint> pedPositions = new HashMap<>();
int id2 = row.getInt(1); agents.forEach(a -> pedPositions.put(a.getId(), a.getPosition()));
VPoint ped1Pos = pedPositions.get(id1); Table pairs = model.getContactData().getPairsOfPedestriansInContactAt(model.getSimTimeInSec());
VPoint ped2Pos = pedPositions.get(id2);
Path2D.Double path = new Path2D.Double(); for (Row row : pairs) {
path.moveTo(ped1Pos.x, ped1Pos.y); int id1 = row.getInt(0);
path.lineTo(ped2Pos.x, ped2Pos.y); int id2 = row.getInt(1);
draw(path, g); VPoint ped1Pos = pedPositions.get(id1);
VPoint ped2Pos = pedPositions.get(id2);
// paint agents in contact red Path2D.Double path = new Path2D.Double();
if (model.config.isShowPedestrians()) { path.moveTo(ped1Pos.x, ped1Pos.y);
agents.stream().filter(a -> a.getId() == id1 || a.getId() == id2).forEach(a -> getAgentRender().render(a, Color.red, g)); path.lineTo(ped2Pos.x, ped2Pos.y);
draw(path, g);
// paint agents in contact red
if (model.config.isShowPedestrians()) {
agents.stream().filter(a -> a.getId() == id1 || a.getId() == id2).forEach(a -> getAgentRender().render(a, Color.red, g));
}
} }
}
g.setStroke(stroke); g.setStroke(savedStroke);
g.setColor(color); g.setColor(savedColor);
}
} }
} }
\ No newline at end of file
...@@ -161,6 +161,8 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -161,6 +161,8 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
int iconHeight = VadereConfig.getConfig().getInt("ProjectView.icon.height.value"); int iconHeight = VadereConfig.getConfig().getInt("ProjectView.icon.height.value");
int iconWidth = VadereConfig.getConfig().getInt("ProjectView.icon.width.value"); int iconWidth = VadereConfig.getConfig().getInt("ProjectView.icon.width.value");
// Player controls
playButton = addActionToToolbar(toolbar, playButton = addActionToToolbar(toolbar,
new ActionPlay("play", resources.getIcon("play.png", iconWidth, iconHeight), model), new ActionPlay("play", resources.getIcon("play.png", iconWidth, iconHeight), model),
"PostVis.btnPlay.tooltip"); "PostVis.btnPlay.tooltip");
...@@ -172,6 +174,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -172,6 +174,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
"PostVis.btnStop.tooltip"); "PostVis.btnStop.tooltip");
toolbar.addSeparator(new Dimension(5, 50)); toolbar.addSeparator(new Dimension(5, 50));
// Pedestrian-related options
addActionToToolbar(toolbar, addActionToToolbar(toolbar,
new ActionVisualization("show_pedestrian", resources.getIcon("pedestrian.png", iconWidth, iconHeight), new ActionVisualization("show_pedestrian", resources.getIcon("pedestrian.png", iconWidth, iconHeight),
model) { model) {
...@@ -179,27 +182,8 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -179,27 +182,8 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
model.config.setShowPedestrians(!model.config.isShowPedestrians()); model.config.setShowPedestrians(!model.config.isShowPedestrians());
model.notifyObservers(); model.notifyObservers();
} }
}, "ProjectView.btnShowPedestrian.tooltip"); }, "ProjectView.btnShowPedestrian.tooltip");
addActionToToolbar(toolbar,
new ActionVisualization("show_contacts", resources.getIcon("contacts.png", iconWidth, iconHeight),
model) {
@Override
public void actionPerformed(ActionEvent e) {
if (!model.config.isContactsRecorded()) {
JOptionPane.showMessageDialog(ProjectView.getMainWindow(),
Messages.getString("PostVis.ShowContactsErrorMessage.text"));
} else {
model.config.setShowContacts(!model.config.isShowContacts());
model.notifyObservers();
}
}
}, "ProjectView.btnShowContacts.tooltip");
addActionToToolbar(toolbar, addActionToToolbar(toolbar,
new ActionVisualization("show_trajectory", new ActionVisualization("show_trajectory",
resources.getIcon("trajectories.png", iconWidth, iconHeight), model) { resources.getIcon("trajectories.png", iconWidth, iconHeight), model) {
...@@ -208,10 +192,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -208,10 +192,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowTrajectories(!model.config.isShowTrajectories()); model.config.setShowTrajectories(!model.config.isShowTrajectories());
model.notifyObservers(); model.notifyObservers();
} }
}, "ProjectView.btnShowTrajectories.tooltip"); }, "ProjectView.btnShowTrajectories.tooltip");
addActionToToolbar(toolbar, addActionToToolbar(toolbar,
new ActionVisualization("show_direction", new ActionVisualization("show_direction",
resources.getIcon("walking_direction.png", iconWidth, iconHeight), model) { resources.getIcon("walking_direction.png", iconWidth, iconHeight), model) {
...@@ -220,34 +201,37 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -220,34 +201,37 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowWalkdirection(!model.config.isShowWalkdirection()); model.config.setShowWalkdirection(!model.config.isShowWalkdirection());
model.notifyObservers(); model.notifyObservers();
} }
}, "ProjectView.btnShowWalkingDirection.tooltip"); }, "ProjectView.btnShowWalkingDirection.tooltip");
addActionToToolbar(toolbar, addActionToToolbar(toolbar,
new ActionVisualization("show_groups", new ActionVisualization("show_groups",
resources.getIcon("group.png", iconWidth, iconHeight), model) { resources.getIcon("group.png", iconWidth, iconHeight), model) {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
model.config.setShowGroups(!model.config.isShowGroups()); model.config.setShowGroups(!model.config.isShowGroups());
model.notifyObservers(); model.notifyObservers();
} }
}, "ProjectView.btnShowGroupInformation.tooltip"); }, "ProjectView.btnShowGroupInformation.tooltip");
addActionToToolbar(toolbar,
new ActionVisualization("show_contacts", resources.getIcon("contacts.png", iconWidth, iconHeight),
model) {
@Override
public void actionPerformed(ActionEvent e) {
if (!model.config.isContactsRecorded()) {
JOptionPane.showMessageDialog(ProjectView.getMainWindow(),
Messages.getString("PostVis.ShowContactsErrorMessage.text"));
} else {
model.config.setShowContacts(!model.config.isShowContacts());
model.notifyObservers();
}
}
}, "ProjectView.btnShowContacts.tooltip");
toolbar.addSeparator(new Dimension(5, 50));
// "Measuring" tools
addActionToToolbar(toolbar, addActionToToolbar(toolbar,
new ActionSwapSelectionMode("draw_voronoi_diagram", new ActionSwapSelectionMode("draw_voronoi_diagram",
resources.getIcon("voronoi.png", iconWidth, iconHeight), model), resources.getIcon("voronoi.png", iconWidth, iconHeight), model),
"ProjectView.btnDrawVoronoiDiagram.tooltip"); "ProjectView.btnDrawVoronoiDiagram.tooltip");
toolbar.addSeparator(new Dimension(5, 50));
addActionToToolbar(
toolbar,
new ActionShowPotentialField("show_potentialField", resources.getIcon("potentialField.png", iconWidth,
iconHeight), model),
"ProjectView.btnShowPotentialfield.tooltip");
addActionToToolbar(toolbar, addActionToToolbar(toolbar,
new ActionVisualization("show_grid", resources.getIcon("grid.png", iconWidth, iconHeight), model) { new ActionVisualization("show_grid", resources.getIcon("grid.png", iconWidth, iconHeight), model) {
@Override @Override
...@@ -255,10 +239,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -255,10 +239,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowGrid(!model.config.isShowGrid()); model.config.setShowGrid(!model.config.isShowGrid());
model.notifyObservers(); model.notifyObservers();
} }
}, "ProjectView.btnShowGrid.tooltip"); }, "ProjectView.btnShowGrid.tooltip");
addActionToToolbar( addActionToToolbar(
toolbar, toolbar,
new ActionVisualization("show_density", resources.getIcon("density.png", iconWidth, iconHeight), new ActionVisualization("show_density", resources.getIcon("density.png", iconWidth, iconHeight),
...@@ -268,19 +249,20 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -268,19 +249,20 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowDensity(!model.config.isShowDensity()); model.config.setShowDensity(!model.config.isShowDensity());
model.notifyObservers(); model.notifyObservers();
} }
}, "ProjectView.btnShowDensity.tooltip"); }, "ProjectView.btnShowDensity.tooltip");
addActionToToolbar(
toolbar,
new ActionShowPotentialField("show_potentialField", resources.getIcon("potentialField.png", iconWidth,
iconHeight), model),
"ProjectView.btnShowPotentialfield.tooltip");
toolbar.addSeparator(new Dimension(5, 50));
// Recording and snapshot options
// toolbar.addSeparator(new Dimension(5, 50));
ActionRecording recordAction = new ActionRecording("record", resources.getIcon("record.png", iconWidth, ActionRecording recordAction = new ActionRecording("record", resources.getIcon("record.png", iconWidth,
iconHeight), renderer); iconHeight), renderer);
JButton recordButton = addActionToToolbar(toolbar, recordAction, "PostVis.btnRecord.tooltip"); JButton recordButton = addActionToToolbar(toolbar, recordAction, "PostVis.btnRecord.tooltip");
recordAction.setButton(recordButton); recordAction.setButton(recordButton);
toolbar.addSeparator(new Dimension(5, 50));
ArrayList<Action> imgOptions = new ArrayList<>(); ArrayList<Action> imgOptions = new ArrayList<>();
AbstractAction pngImg = new ActionGeneratePNG(Messages.getString("ProjectView.btnPNGSnapshot.tooltip"), resources.getIcon("camera_png.png", iconWidth, iconHeight), AbstractAction pngImg = new ActionGeneratePNG(Messages.getString("ProjectView.btnPNGSnapshot.tooltip"), resources.getIcon("camera_png.png", iconWidth, iconHeight),
renderer, model); renderer, model);
...@@ -294,15 +276,11 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar ...@@ -294,15 +276,11 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
AbstractAction polyImg = new ActionGeneratePoly(Messages.getString("ProjectView.btnPolySnapshot.tooltip"), resources.getIcon("camera_poly.png", iconWidth, iconHeight), AbstractAction polyImg = new ActionGeneratePoly(Messages.getString("ProjectView.btnPolySnapshot.tooltip"), resources.getIcon("camera_poly.png", iconWidth, iconHeight),
model); model);
// add new ImageGenerator Action ...
imgOptions.add(pngImg); imgOptions.add(pngImg);
imgOptions.add(svgImg); imgOptions.add(svgImg);
imgOptions.add(tikzImg); imgOptions.add(tikzImg);
imgOptions.add(inetImg); imgOptions.add(inetImg);
imgOptions.add(polyImg); imgOptions.add(polyImg);
// add Action to List ....
ActionVisualizationMenu imgDialog = new ActionVisualizationMenu( ActionVisualizationMenu imgDialog = new ActionVisualizationMenu(
"camera_menu", "camera_menu",
......
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