From 36192ebcb63fc6f2a832b06121fb93976a2e6ca2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 4 May 2018 16:14:27 +0100 Subject: [PATCH] JAL-2975 Shift-arrow keys to rotate PCA incrementally --- src/jalview/appletgui/RotatableCanvas.java | 32 ++++++++++++++++++++++++---- src/jalview/gui/RotatableCanvas.java | 27 +++++++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) 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') { -- 1.7.10.2