From: gmungoc Date: Fri, 4 May 2018 15:14:27 +0000 (+0100) Subject: JAL-2975 Shift-arrow keys to rotate PCA incrementally X-Git-Tag: Release_2_11_1_0~78^2~9^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=36192ebcb63fc6f2a832b06121fb93976a2e6ca2;p=jalview.git JAL-2975 Shift-arrow keys to rotate PCA incrementally --- diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index 2a49d0b..34f8ea5 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -392,13 +392,37 @@ public class RotatableCanvas extends Panel implements MouseListener, @Override public void keyPressed(KeyEvent evt) { - if (evt.getKeyCode() == KeyEvent.VK_UP) + boolean shiftDown = evt.isShiftDown(); + int keyCode = evt.getKeyCode(); + if (keyCode == KeyEvent.VK_UP) { - zoom(1.1f); + if (shiftDown) + { + rotate(0f, -1f); + } + else + { + zoom(1.1f); + } + } + else if (keyCode == KeyEvent.VK_DOWN) + { + if (shiftDown) + { + rotate(0f, 1f); + } + else + { + zoom(0.9f); + } + } + else if (shiftDown && keyCode == KeyEvent.VK_LEFT) + { + rotate(1f, 0f); } - else if (evt.getKeyCode() == KeyEvent.VK_DOWN) + else if (shiftDown && keyCode == KeyEvent.VK_RIGHT) { - zoom(0.9f); + rotate(-1f, 0f); } else if (evt.getKeyChar() == 's') { diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index da48dd6..86fe483 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -475,14 +475,37 @@ public class RotatableCanvas extends JPanel implements MouseListener, public void keyPressed(KeyEvent evt) { int keyCode = evt.getKeyCode(); + boolean shiftDown = evt.isShiftDown(); if (keyCode == KeyEvent.VK_UP) { - zoom(ZOOM_IN); + if (shiftDown) + { + rotate(0f, -1f); + } + else + { + zoom(ZOOM_IN); + } } else if (keyCode == KeyEvent.VK_DOWN) { - zoom(ZOOM_OUT); + if (shiftDown) + { + rotate(0f, 1f); + } + else + { + zoom(ZOOM_OUT); + } + } + else if (shiftDown && keyCode == KeyEvent.VK_LEFT) + { + rotate(1f, 0f); + } + else if (shiftDown && keyCode == KeyEvent.VK_RIGHT) + { + rotate(-1f, 0f); } else if (evt.getKeyChar() == 's') {