Add mousewheel listener
authoramwaterhouse <Andrew Waterhouse>
Thu, 10 Nov 2005 17:53:14 +0000 (17:53 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 10 Nov 2005 17:53:14 +0000 (17:53 +0000)
src/MCview/PDBCanvas.java

index ccb1643..7b6021d 100755 (executable)
@@ -159,6 +159,27 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe
         addMouseMotionListener(this);\r
         addMouseListener(this);\r
 \r
+        addMouseWheelListener(new MouseWheelListener()\r
+        {\r
+          public void mouseWheelMoved(MouseWheelEvent e)\r
+          {\r
+            if (e.getWheelRotation() > 0)\r
+            {\r
+              scale = (float) (scale * 1.1);\r
+              redrawneeded = true;\r
+              repaint();\r
+            }\r
+\r
+            else\r
+            {\r
+              scale = (float) (scale * 0.9);\r
+              redrawneeded = true;\r
+              repaint();\r
+            }\r
+          }\r
+       });\r
+\r
+\r
         findCentre();\r
         findWidth();\r
 \r
@@ -504,8 +525,8 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe
         return prefsize;\r
     }\r
 \r
-    public void keyPressed(KeyEvent evt) {\r
-      int key = evt.getKeyChar();\r
+    public void keyPressed(KeyEvent evt)\r
+    {\r
       if (evt.getKeyCode() == KeyEvent.VK_UP)\r
       {\r
         scale = (float) (scale * 1.1);\r