Commit 245b20c7 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

In "DefaultModeAdapter.java", added "Ctrl + Alt + Mouse Wheel" shortcut to...

In "DefaultModeAdapter.java", added "Ctrl + Alt + Mouse Wheel" shortcut to zoom in/out with a smaller step size
parent 480f51d7
......@@ -81,14 +81,17 @@ public class DefaultModeAdapter implements IMode {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.isControlDown()) {
/* Use a smaller scale factor if the ALT key is pressed simultaneously */
double zoomFactor = e.isAltDown() ? 1.05 : 1.2;
if (e.getWheelRotation() > 0) {
if (panelModel.zoomOut()) {
if (panelModel.zoomOut(zoomFactor)) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
delay();
} else if (e.getWheelRotation() < 0) {
if (panelModel.zoomIn()) {
if (panelModel.zoomIn(zoomFactor)) {
panelModel.notifyScaleListeners();
panelModel.notifyObservers();
}
......
......@@ -130,12 +130,24 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
return setScale(scale);
}
@Override
public boolean zoomIn(double zoomFactor) {
double scale = scaleFactor * zoomFactor;
return setScale(scale);
}
@Override
public boolean zoomOut() {
double scale = scaleFactor / 1.2;
return setScale(scale);
}
@Override
public boolean zoomOut(double zoomFactor) {
double scale = scaleFactor / zoomFactor;
return setScale(scale);
}
@Override
public boolean setScale(final double scale) {
double oldScale = scaleFactor;
......
......@@ -38,11 +38,13 @@ public interface IDefaultModel<T extends DefaultConfig> extends Iterable<Scenari
* zoom by a fixed factor into the topography by changing the viewport.
*/
boolean zoomIn();
boolean zoomIn(double zoomFactor);
/**
* zoom by a fixed factor out of the topography by changing the viewport.
*/
boolean zoomOut();
boolean zoomOut(double zoomFactor);
/**
* Set the current mouse position. This helps to draw the cursor.
......
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