JAL-2975 Shift-arrow keys to rotate PCA incrementally
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 4 May 2018 15:14:27 +0000 (16:14 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 4 May 2018 15:14:27 +0000 (16:14 +0100)
src/jalview/appletgui/RotatableCanvas.java
src/jalview/gui/RotatableCanvas.java

index 2a49d0b..34f8ea5 100755 (executable)
@@ -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')
     {
index da48dd6..86fe483 100755 (executable)
@@ -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')
     {