JAL-4020 Added search for PyMOLWinWithConsole.bat (and PyMOLWin.exe) in likely places...
[jalview.git] / src / jalview / appletgui / RotatableCanvas.java
index 2a49d0b..a870ca4 100755 (executable)
@@ -331,8 +331,10 @@ public class RotatableCanvas extends Panel implements MouseListener,
     for (int i = 0; i < 3; i++)
     {
       g.drawLine(getSize().width / 2, getSize().height / 2,
-              (int) (axisEndPoints[i].x * scale * max[0] + getSize().width / 2),
-              (int) (axisEndPoints[i].y * scale * max[1] + getSize().height / 2));
+              (int) (axisEndPoints[i].x * scale * max[0]
+                      + getSize().width / 2),
+              (int) (axisEndPoints[i].y * scale * max[1]
+                      + getSize().height / 2));
     }
   }
 
@@ -353,8 +355,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
               sequenceColour == Color.black ? Color.white : sequenceColour);
       if (av.getSelectionGroup() != null)
       {
-        if (av.getSelectionGroup().getSequences(null)
-                .contains(sequence))
+        if (av.getSelectionGroup().getSequences(null).contains(sequence))
         {
           g.setColor(Color.gray);
         }
@@ -392,13 +393,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 (evt.getKeyCode() == KeyEvent.VK_DOWN)
+    else if (keyCode == KeyEvent.VK_DOWN)
     {
-      zoom(0.9f);
+      if (shiftDown)
+      {
+        rotate(0f, 1f);
+      }
+      else
+      {
+        zoom(0.9f);
+      }
+    }
+    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')
     {
@@ -525,8 +550,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
       {
         if (av != null)
         {
-          if (!av.getSelectionGroup().getSequences(null)
-                  .contains(sequence))
+          if (!av.getSelectionGroup().getSequences(null).contains(sequence))
           {
             av.getSelectionGroup().addSequence(sequence, true);
           }
@@ -555,10 +579,8 @@ public class RotatableCanvas extends Panel implements MouseListener,
     {
 
       SequencePoint sp = points.get(i);
-      int px = (int) ((sp.coord.x - centre.x) * scale)
-              + halfwidth;
-      int py = (int) ((sp.coord.y - centre.y) * scale)
-              + halfheight;
+      int px = (int) ((sp.coord.x - centre.x) * scale) + halfwidth;
+      int py = (int) ((sp.coord.y - centre.y) * scale) + halfheight;
 
       if (Math.abs(px - x) < 3 && Math.abs(py - y) < 3)
       {
@@ -603,12 +625,12 @@ public class RotatableCanvas extends Panel implements MouseListener,
     {
       return;
     }
-  
+
     /*
      * get the identity transformation...
      */
     RotatableMatrix rotmat = new RotatableMatrix();
-  
+
     /*
      * rotate around the X axis for change in Y
      * (mouse movement up/down); note we are equating a
@@ -618,7 +640,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
     {
       rotmat.rotate(y, Axis.X);
     }
-  
+
     /*
      * rotate around the Y axis for change in X
      * (mouse movement left/right)
@@ -627,7 +649,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
     {
       rotmat.rotate(x, Axis.Y);
     }
-  
+
     /*
      * apply the composite transformation to sequence points
      */
@@ -642,7 +664,7 @@ public class RotatableCanvas extends Panel implements MouseListener,
       // Now translate back again
       sp.translate(centre.x, centre.y, centre.z);
     }
-  
+
     /*
      * rotate the x/y/z axis positions
      */