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

Added zooming and scrolling shortcuts to "DefaultModeAdapter" for topography creator

VadereGui/src/org/vadere/gui/onlinevisualization/view/OnlineVisualisationWindow.java:
- Fixed bug: The scroll pane was not added to the underlying model.
  Therefore, it was not possible to capture mouse wheel events.
parent 98212d94
Pipeline #167827 passed with stages
in 126 minutes and 48 seconds
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
- `FootStepProcessor` interpolates the pedestrian's foot step to obtain a more precise position. - `FootStepProcessor` interpolates the pedestrian's foot step to obtain a more precise position.
Was previously known as `PedestrianFootStepProcessor` Was previously known as `PedestrianFootStepProcessor`
- Use following shortcuts for zooming and scrolling in the topography creator:
* Ctrl + Mouse Wheel Scroll: Zoom in/out.
* Mouse Wheel Scroll: Scroll vertically.
* Shift + Mouse Wheel Scroll: Scroll horizontally.
* Use Alt key to decrease the step size while scrolling.
# v1.4 (2019-09-05) # v1.4 (2019-09-05)
......
...@@ -68,23 +68,70 @@ public class DefaultModeAdapter implements IMode { ...@@ -68,23 +68,70 @@ public class DefaultModeAdapter implements IMode {
panelModel.notifyObservers(); panelModel.notifyObservers();
} }
/**
* Use following shortcuts for zooming and scrolling:
* <ul>
* <li>Ctrl + Mouse Wheel Scroll: Zoom in/out.</li>
* <li>Mouse Wheel Scroll: Scroll vertically.</li>
* <li>Shift + Mouse Wheel Scroll: Scroll horizontally.</li>
* <li>Use Alt key to decrease the step size while scrolling.</li>
* </ul>
* @param e
*/
@Override @Override
public void mouseWheelMoved(MouseWheelEvent e) { public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getWheelRotation() > 0) { if (e.isControlDown()) {
if (panelModel.zoomOut()) { if (e.getWheelRotation() > 0) {
panelModel.notifyScaleListeners(); if (panelModel.zoomOut()) {
panelModel.notifyObservers(); panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
} else if (e.getWheelRotation() < 0) {
if (panelModel.zoomIn()) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
} }
delay(); } else {
} else if (e.getWheelRotation() < 0) { MouseWheelEvent scrollEvent = (e.isAltDown()) ? getSmallStepScrollEvent(e) : getBigStepScrollEvent(e);
if (panelModel.zoomIn()) { panelModel.getScrollPane().dispatchEvent(scrollEvent);
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
} }
} }
private MouseWheelEvent getSmallStepScrollEvent(MouseWheelEvent baseEvent) {
MouseWheelEvent smallScrollEvent = new MouseWheelEvent(
(Component) baseEvent.getSource(),
baseEvent.getID(),
baseEvent.getWhen(),
baseEvent.getModifiersEx(),
baseEvent.getX(),
baseEvent.getY(),
baseEvent.getClickCount(),
baseEvent.isPopupTrigger(),
MouseWheelEvent.WHEEL_UNIT_SCROLL,
baseEvent.getScrollAmount(),
baseEvent.getWheelRotation());
return smallScrollEvent;
}
private MouseWheelEvent getBigStepScrollEvent(MouseWheelEvent baseEvent) {
MouseWheelEvent smallScrollEvent = new MouseWheelEvent(
(Component) baseEvent.getSource(),
baseEvent.getID(),
baseEvent.getWhen(),
baseEvent.getModifiersEx(),
baseEvent.getX(),
baseEvent.getY(),
baseEvent.getClickCount(),
baseEvent.isPopupTrigger(),
MouseWheelEvent.WHEEL_BLOCK_SCROLL,
baseEvent.getScrollAmount(),
baseEvent.getWheelRotation());
return smallScrollEvent;
}
private void delay() { private void delay() {
try { try {
Thread.sleep(10); Thread.sleep(10);
......
...@@ -48,6 +48,7 @@ public class OnlineVisualisationWindow extends JPanel implements Observer { ...@@ -48,6 +48,7 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
mainPanel.setScrollPane(scrollPane); mainPanel.setScrollPane(scrollPane);
scrollPane.getViewport() scrollPane.getViewport()
.addChangeListener(new JViewportChangeListener(model, scrollPane.getVerticalScrollBar())); .addChangeListener(new JViewportChangeListener(model, scrollPane.getVerticalScrollBar()));
model.addScrollPane(scrollPane);
IViewportChangeListener viewportChangeListener = new ViewportChangeListener(model, scrollPane); IViewportChangeListener viewportChangeListener = new ViewportChangeListener(model, scrollPane);
model.addViewportChangeListener(viewportChangeListener); model.addViewportChangeListener(viewportChangeListener);
......
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