Commit 2e889fef authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Add keyboard shortcuts to play, pause and stop animation in post visualization

parent f86292a8
#builds, log/preferences files
target/
# Build artifacts, log and preference files
*.out
*.preferences.xml
bin/
swing-inspector-linux-1.2.3/
#Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
**/venv/
Tools/VadereAnalysisTools/VadereAnalysisTool/vadereanalysistool.egg-info/
Tools/VadereAnalysisTools/VadereAnalysisTool/build/
Tools/VadereAnalysisTools/VadereAnalysisTool/dist/
Tools/VadereAnalysisTools/VadereAnalysisTool/vadereanalysistool**/output
Tools/ContinuousIntegration/**/output
target/
# C extensions
*.so
vadereanalysistool/build
vadere_analysis_tool/build
#Tools and build utils
bin/
#IntelliJ
# IDEs
.idea/
*.iml
#Eclipse
.settings/
.metadata/
.classpath
.project
#package specific
# Package specific
VadereGui/*.png
VadereGui/*.svg
VadereGui/*.mov
......@@ -43,18 +26,20 @@ VadereUtils/testreports/*.txt
VadereSimulator/resources/current_commit_hash.txt
VadereSimulator/testResources/**/*.legacy
#Java runtime files generated with "jdeps" and "jlink"
java-runtime/*
#model test output
VadereModelTests/**/output
VadereModelTests/*_private
VadereModelCalibration/**/output
VadereModelTests/**/legacy
VadereUtils/output/**
# Python (byte-compiled, optimized, DLL files etc.)
__pycache__/
*.py[cod]
*$py.class
**/venv/
Tools/VadereAnalysisTools/VadereAnalysisTool/vadereanalysistool.egg-info/
Tools/VadereAnalysisTools/VadereAnalysisTool/build/
Tools/VadereAnalysisTools/VadereAnalysisTool/dist/
#mac osx files
# Operating system files
.DS_Store
#linux files
**/.directory
# Vadere output directories
**/output/
**/legacy/
**/*_private/
......@@ -213,9 +213,9 @@ SettingsDialog.chbShowPedestrianIds.text=Show PedestrianIds
PostVis.chShowEvacTimeColor.text=Color Pedestrians regarding to Evacuation Times
PostVis.additional.border.text=PostVis
PostVis.btnPlay.tooltip=Play
PostVis.btnPause.tooltip=Pause
PostVis.btnStop.tooltip=Stop
PostVis.btnPlay.tooltip=Play (Space)
PostVis.btnPause.tooltip=Pause (Space)
PostVis.btnStop.tooltip=Stop (Backspace)
PostVis.btnRecord.tooltip=Start Recording
PostVis.btnAbout.tooltip=About
PostVis.about.title=About
......
......@@ -214,9 +214,9 @@ ProjectView.mntmCopyOutputDir.text=Kopiere Output Pfad in Zwischenablage
SettingsDialog.chbShowPedestrianIds.text=Fu\u00dfg\u00E4nger-Ids anzeigen
PostVis.additional.border.text=PostVis
PostVis.chShowEvacTimeColor.text=F\u00e4rbe Fu\u00dfg\u00E4nger nach ihrer Evakuierungszeit
PostVis.btnPlay.tooltip=Start
PostVis.btnPause.tooltip=Pause
PostVis.btnStop.tooltip=Stopp
PostVis.btnPlay.tooltip=Start (Leertaste)
PostVis.btnPause.tooltip=Pause (Leertaste)
PostVis.btnStop.tooltip=Stopp (Backspace-Taste)
PostVis.btnRecord.tooltip=Starte Aufnahme
PostVis.chbHidePedAtTarget.text=Fu\u00dfg\u00E4nger im Ziel nicht anzeigen
......
......@@ -2,16 +2,11 @@ package org.vadere.gui.postvisualization.view;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import org.vadere.gui.components.control.IViewportChangeListener;
import org.vadere.gui.components.control.JViewportChangeListener;
import org.vadere.gui.components.control.PanelResizeListener;
import org.vadere.gui.components.control.ViewportChangeListener;
import org.vadere.gui.components.control.simulation.ActionGeneratePNG;
import org.vadere.gui.components.control.simulation.ActionGenerateSVG;
import org.vadere.gui.components.control.simulation.ActionGenerateTikz;
import org.vadere.gui.components.control.simulation.ActionSwapSelectionMode;
import org.vadere.gui.components.control.simulation.ActionVisualization;
import org.vadere.gui.components.control.simulation.*;
import org.vadere.gui.components.model.IDefaultModel;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
......@@ -23,21 +18,18 @@ import org.vadere.gui.postvisualization.control.*;
import org.vadere.gui.postvisualization.model.PostvisualizationModel;
import org.vadere.gui.projectview.control.ActionDeselect;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.io.HashGenerator;
import org.vadere.simulator.projects.io.IOOutput;
import org.vadere.util.io.IOUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Observer;
import java.util.prefs.Preferences;
import javax.swing.*;
/**
* Main Window of the new post visualization.
*
......@@ -54,6 +46,9 @@ public class PostvisualizationWindow extends JPanel implements Observer {
private JMenuBar menuBar;
private static Resources resources = Resources.getInstance("postvisualization");
private final ScenarioElementView textView;
private JButton playButton;
private JButton pauseButton;
private JButton stopButton;
public PostvisualizationWindow(final String projectPath) {
this(false, projectPath);
......@@ -132,14 +127,14 @@ public class PostvisualizationWindow extends JPanel implements Observer {
int iconHeight = Integer.valueOf(resources.getProperty("ProjectView.icon.height.value"));
int iconWidth = Integer.valueOf(resources.getProperty("ProjectView.icon.width.value"));
addActionToToolbar(toolbar,
playButton = addActionToToolbar(toolbar,
new ActionPlay("play", resources.getIcon("play.png", iconWidth, iconHeight), model),
"PostVis.btnPlay.tooltip");
addActionToToolbar(toolbar,
pauseButton = addActionToToolbar(toolbar,
new ActionPause("pause", resources.getIcon("pause.png", iconWidth, iconHeight), model),
"PostVis.btnPause.tooltip");
addActionToToolbar(toolbar,
new ActionStop("play", resources.getIcon("stop.png", iconWidth, iconHeight), model),
stopButton = addActionToToolbar(toolbar,
new ActionStop("stop", resources.getIcon("stop.png", iconWidth, iconHeight), model),
"PostVis.btnStop.tooltip");
toolbar.addSeparator(new Dimension(5, 50));
......@@ -299,6 +294,7 @@ public class PostvisualizationWindow extends JPanel implements Observer {
}
}
buildKeyboardShortcuts();
miGlobalSettings.addActionListener(e -> DialogFactory.createSettingsDialog(model).setVisible(true));
......@@ -318,6 +314,24 @@ public class PostvisualizationWindow extends JPanel implements Observer {
revalidate();
}
private void buildKeyboardShortcuts() {
Action spaceKeyReaction = new ActionVisualization("Typed Space Key Reaction", model){
boolean isRunning = false;
@Override
public void actionPerformed(ActionEvent e){
(isRunning ? pauseButton : playButton).getAction().actionPerformed(null);
isRunning = !isRunning;
}
};
addKeyboardShortcut("SPACE","Typed Space", spaceKeyReaction);
addKeyboardShortcut("BACK_SPACE","Typed Backspace", stopButton.getAction());
}
private void addKeyboardShortcut(String key, String actionKey, Action action) {
getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), actionKey);
getActionMap().put(actionKey, action);
}
private JMenuBar getMenu() {
return menuBar;
}
......
......@@ -5,34 +5,7 @@ import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.postvisualization.control.Player;
import org.vadere.gui.projectview.VadereApplication;
import org.vadere.gui.projectview.control.ActionAddScenario;
import org.vadere.gui.projectview.control.ActionCloneScenario;
import org.vadere.gui.projectview.control.ActionCloseApplication;
import org.vadere.gui.projectview.control.ActionCreateProject;
import org.vadere.gui.projectview.control.ActionDeleteOutputDirectories;
import org.vadere.gui.projectview.control.ActionDeleteScenarios;
import org.vadere.gui.projectview.control.ActionEditScenarioDescription;
import org.vadere.gui.projectview.control.ActionGenerateScenarioFromOutputFile;
import org.vadere.gui.projectview.control.ActionInterruptScenarios;
import org.vadere.gui.projectview.control.ActionLoadProject;
import org.vadere.gui.projectview.control.ActionLoadRecentProject;
import org.vadere.gui.projectview.control.ActionOpenInExplorer;
import org.vadere.gui.projectview.control.ActionOutputToScenario;
import org.vadere.gui.projectview.control.ActionPauseScenario;
import org.vadere.gui.projectview.control.ActionRenameOutputFile;
import org.vadere.gui.projectview.control.ActionRenameProject;
import org.vadere.gui.projectview.control.ActionRenameScenario;
import org.vadere.gui.projectview.control.ActionRunAllScenarios;
import org.vadere.gui.projectview.control.ActionRunOutput;
import org.vadere.gui.projectview.control.ActionRunSelectedScenarios;
import org.vadere.gui.projectview.control.ActionSaveAsProject;
import org.vadere.gui.projectview.control.ActionSaveProject;
import org.vadere.gui.projectview.control.ActionSeeDiscardChanges;
import org.vadere.gui.projectview.control.ActionShowAboutDialog;
import org.vadere.gui.projectview.control.ActionToClipboard;
import org.vadere.gui.projectview.control.IOutputFileRefreshListener;
import org.vadere.gui.projectview.control.IProjectChangeListener;
import org.vadere.gui.projectview.control.ShowResultDialogAction;
import org.vadere.gui.projectview.control.*;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.model.ProjectViewModel.OutputBundle;
import org.vadere.gui.projectview.model.ProjectViewModel.ScenarioBundle;
......@@ -47,6 +20,9 @@ import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import org.vadere.util.opencl.CLUtils;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
......@@ -61,10 +37,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.prefs.Preferences;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
/**
* Main view of the Vadere GUI.
*
......@@ -365,7 +337,17 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
pack();
}
private void buildMenuBar(ActionCloseApplication closeApplicationAction, ActionAddScenario addScenarioAction) {
private void buildKeyboardShortcuts(ActionPauseScenario pauseScenarioAction, Action interruptScenariosAction) {
addKeyboardShortcut("SPACE", "Typed Space", btnPauseRunningScenarios.getAction());
addKeyboardShortcut("BACK_SPACE", "Typed Backspace", btnStopRunningScenarios.getAction());
}
private void addKeyboardShortcut(String key, String actionKey, Action action) {
controlPanel.getInputMap().put(KeyStroke.getKeyStroke(key), actionKey);
controlPanel.getActionMap().put(actionKey, action);
}
private void buildMenuBar(ActionCloseApplication closeApplicationAction, ActionAddScenario addScenarioAction) {
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
......@@ -728,6 +710,8 @@ public class ProjectView extends JFrame implements ProjectFinishedListener, Sing
toolBar.getInputMap().put(
KeyStroke.getKeyStroke(Messages.getString("ProjectView.pauseTests.shortcut").charAt(0)), "pauseTests");
toolBar.getActionMap().put("pauseTests", pauseScenarioAction);
buildKeyboardShortcuts(pauseScenarioAction, interruptScenariosAction);
}
private void buildRightSidePanel() {
......
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