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 {
mainPanel.addRendererChangeListener(generateINETenv);
mainPanel.addRendererChangeListener(showPotentialField);
SwingUtils.addActionToToolbar(toolbar, paintPedestriansAction,
Messages.getString("ProjectView.btnShowPedestrian.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintTrajectories,
Messages.getString("ProjectView.btnShowTrajectories.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"));
// Pedestrian-related options
SwingUtils.addActionToToolbar(toolbar, paintPedestriansAction, Messages.getString("ProjectView.btnShowPedestrian.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintTrajectories, Messages.getString("ProjectView.btnShowTrajectories.tooltip"));
SwingUtils.addActionToToolbar(toolbar, paintArrowAction, Messages.getString("ProjectView.btnShowWalkingDirection.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showGroupInformationAction, Messages.getString("ProjectView.btnShowGroupInformation.tooltip"));
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, paintDensity, Messages.getString("ProjectView.btnShowDensity.tooltip"));
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
toolbar.addSeparator();
// Snapshot options
ArrayList<Action> imgOptions = new ArrayList<>();
imgOptions.add(generatePNG);
imgOptions.add(generateSVG);
......@@ -253,16 +248,12 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
ActionOnlineVisMenu imgDialog = new ActionOnlineVisMenu(
"camera_menu",
resources.getIcon("camera.png", iconWidth, iconHeight), imgOptions);
JButton imgMenuBtn =
SwingUtils.addActionToToolbar(toolbar, imgDialog, Messages.getString("ProjectView.btnSnapshot.tooltip"));
JButton imgMenuBtn = SwingUtils.addActionToToolbar(toolbar, imgDialog, Messages.getString("ProjectView.btnSnapshot.tooltip"));
imgDialog.setParent(imgMenuBtn);
SwingUtils.addActionToToolbar(toolbar, showPotentialField, Messages.getString("OnlineVis.btnShowPotentialfield.tooltip"));
toolbar.add(Box.createHorizontalGlue());
SwingUtils.addActionToToolbar(toolbar, openSettingsDialog,
Messages.getString("ProjectView.btnSettings.tooltip"));
SwingUtils.addActionToToolbar(toolbar, openSettingsDialog, Messages.getString("ProjectView.btnSettings.tooltip"));
splitPaneForTopographyAndJsonPane = new JSplitPane();
splitPaneForTopographyAndJsonPane.setResizeWeight(0.8);
......
......@@ -50,12 +50,9 @@ public class PostvisualizationRenderer extends SimulationRenderer {
renderTrajectories(g, slice, pedestrianColors);
renderPedestrians(g, pedestrians, pedestrianColors);
renderConnectingLinesByContact(g);
g.setColor(savedColor);
if (model.config.isShowContacts() && model.getContactData() != null) {
renderConnectingLinesByContact(g);
}
}
}
......@@ -163,9 +160,14 @@ public class PostvisualizationRenderer extends SimulationRenderer {
}
private void renderConnectingLinesByContact(Graphics2D g) {
if (!model.config.isShowAllTrajectories()) return;
Color color = g.getColor();
Stroke stroke = g.getStroke();
boolean showContacts = model.config.isShowContacts() &&
model.getContactData() != null &&
model.config.isShowAllTrajectories(); // TODO Why do "showContacts" depend on "showAllTrajectories"?
if (showContacts) {
Color savedColor = g.getColor();
Stroke savedStroke = g.getStroke();
g.setStroke(new BasicStroke(getLineWidth() / 4.0f));
g.setColor(Color.red);
......@@ -174,7 +176,7 @@ public class PostvisualizationRenderer extends SimulationRenderer {
agents.forEach(a -> pedPositions.put(a.getId(), a.getPosition()));
Table pairs = model.getContactData().getPairsOfPedestriansInContactAt(model.getSimTimeInSec());
for (Row row: pairs) {
for (Row row : pairs) {
int id1 = row.getInt(0);
int id2 = row.getInt(1);
VPoint ped1Pos = pedPositions.get(id1);
......@@ -190,8 +192,9 @@ public class PostvisualizationRenderer extends SimulationRenderer {
}
}
g.setStroke(stroke);
g.setColor(color);
g.setStroke(savedStroke);
g.setColor(savedColor);
}
}
}
\ No newline at end of file
......@@ -161,6 +161,8 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
int iconHeight = VadereConfig.getConfig().getInt("ProjectView.icon.height.value");
int iconWidth = VadereConfig.getConfig().getInt("ProjectView.icon.width.value");
// Player controls
playButton = addActionToToolbar(toolbar,
new ActionPlay("play", resources.getIcon("play.png", iconWidth, iconHeight), model),
"PostVis.btnPlay.tooltip");
......@@ -172,6 +174,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
"PostVis.btnStop.tooltip");
toolbar.addSeparator(new Dimension(5, 50));
// Pedestrian-related options
addActionToToolbar(toolbar,
new ActionVisualization("show_pedestrian", resources.getIcon("pedestrian.png", iconWidth, iconHeight),
model) {
......@@ -179,27 +182,8 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
public void actionPerformed(ActionEvent e) {
model.config.setShowPedestrians(!model.config.isShowPedestrians());
model.notifyObservers();
}
}, "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,
new ActionVisualization("show_trajectory",
resources.getIcon("trajectories.png", iconWidth, iconHeight), model) {
......@@ -208,10 +192,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowTrajectories(!model.config.isShowTrajectories());
model.notifyObservers();
}
}, "ProjectView.btnShowTrajectories.tooltip");
addActionToToolbar(toolbar,
new ActionVisualization("show_direction",
resources.getIcon("walking_direction.png", iconWidth, iconHeight), model) {
......@@ -220,34 +201,37 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowWalkdirection(!model.config.isShowWalkdirection());
model.notifyObservers();
}
}, "ProjectView.btnShowWalkingDirection.tooltip");
addActionToToolbar(toolbar,
new ActionVisualization("show_groups",
resources.getIcon("group.png", iconWidth, iconHeight), model) {
@Override
public void actionPerformed(ActionEvent e) {
model.config.setShowGroups(!model.config.isShowGroups());
model.notifyObservers();
}
}, "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,
new ActionSwapSelectionMode("draw_voronoi_diagram",
resources.getIcon("voronoi.png", iconWidth, iconHeight), model),
"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,
new ActionVisualization("show_grid", resources.getIcon("grid.png", iconWidth, iconHeight), model) {
@Override
......@@ -255,10 +239,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowGrid(!model.config.isShowGrid());
model.notifyObservers();
}
}, "ProjectView.btnShowGrid.tooltip");
addActionToToolbar(
toolbar,
new ActionVisualization("show_density", resources.getIcon("density.png", iconWidth, iconHeight),
......@@ -268,19 +249,20 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model.config.setShowDensity(!model.config.isShowDensity());
model.notifyObservers();
}
}, "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));
// toolbar.addSeparator(new Dimension(5, 50));
// Recording and snapshot options
ActionRecording recordAction = new ActionRecording("record", resources.getIcon("record.png", iconWidth,
iconHeight), renderer);
JButton recordButton = addActionToToolbar(toolbar, recordAction, "PostVis.btnRecord.tooltip");
recordAction.setButton(recordButton);
toolbar.addSeparator(new Dimension(5, 50));
ArrayList<Action> imgOptions = new ArrayList<>();
AbstractAction pngImg = new ActionGeneratePNG(Messages.getString("ProjectView.btnPNGSnapshot.tooltip"), resources.getIcon("camera_png.png", iconWidth, iconHeight),
renderer, model);
......@@ -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),
model);
// add new ImageGenerator Action ...
imgOptions.add(pngImg);
imgOptions.add(svgImg);
imgOptions.add(tikzImg);
imgOptions.add(inetImg);
imgOptions.add(polyImg);
// add Action to List ....
ActionVisualizationMenu imgDialog = new ActionVisualizationMenu(
"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