Commit d20d5126 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

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 @@
- `FootStepProcessor` interpolates the pedestrian's foot step to obtain a more precise position.
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)
......
......@@ -68,23 +68,70 @@ public class DefaultModeAdapter implements IMode {
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
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getWheelRotation() > 0) {
if (panelModel.zoomOut()) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
if (e.isControlDown()) {
if (e.getWheelRotation() > 0) {
if (panelModel.zoomOut()) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
} else if (e.getWheelRotation() < 0) {
if (panelModel.zoomIn()) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
}
delay();
} else if (e.getWheelRotation() < 0) {
if (panelModel.zoomIn()) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
} else {
MouseWheelEvent scrollEvent = (e.isAltDown()) ? getSmallStepScrollEvent(e) : getBigStepScrollEvent(e);
panelModel.getScrollPane().dispatchEvent(scrollEvent);
}
}
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() {
try {
Thread.sleep(10);
......
......@@ -48,6 +48,7 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
mainPanel.setScrollPane(scrollPane);
scrollPane.getViewport()
.addChangeListener(new JViewportChangeListener(model, scrollPane.getVerticalScrollBar()));
model.addScrollPane(scrollPane);
IViewportChangeListener viewportChangeListener = new ViewportChangeListener(model, scrollPane);
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