JAL-2621 Overview uses hand cursor in drag box, crosshair outside box
[jalview.git] / src / jalview / gui / OverviewPanel.java
index 9ddb751..ee478a5 100755 (executable)
@@ -112,7 +112,7 @@ public class OverviewPanel extends JPanel
 
     // without this the overview window does not size to fit the overview canvas
     setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
+    
     addComponentListener(new ComponentAdapter()
     {
       @Override
@@ -172,15 +172,21 @@ public class OverviewPanel extends JPanel
       {
         if (od.isPositionInBox(evt.getX(), evt.getY()))
         {
-          // display drag cursor at mouse position
-          setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
+          /*
+           * using HAND_CURSOR rather than DRAG_CURSOR 
+           * as the latter is not supported on Mac
+           */
+          getParent().setCursor(
+                  Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
         }
         else
         {
           // reset cursor
-          setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+          getParent().setCursor(
+                  Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
         }
       }
+
     });
 
     addMouseListener(new MouseAdapter()
@@ -206,6 +212,8 @@ public class OverviewPanel extends JPanel
             od.updateViewportFromMouse(evt.getX(), evt.getY(),
                     av.getAlignment().getHiddenSequences(),
                     av.getAlignment().getHiddenColumns());
+            getParent().setCursor(
+                    Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
           }
           else
           {
@@ -329,6 +337,22 @@ public class OverviewPanel extends JPanel
    * changed
    * 
    */
+  private void setBoxPositionOnly()
+  {
+    if (od != null)
+    {
+      int oldX = od.getBoxX();
+      int oldY = od.getBoxY();
+      int oldWidth = od.getBoxWidth();
+      int oldHeight = od.getBoxHeight();
+      od.setBoxPosition(av.getAlignment().getHiddenSequences(),
+              av.getAlignment().getHiddenColumns());
+      repaint(oldX - 1, oldY - 1, oldWidth + 2, oldHeight + 2);
+      repaint(od.getBoxX(), od.getBoxY(), od.getBoxWidth(),
+              od.getBoxHeight());
+    }
+  }
+
   private void setBoxPosition()
   {
     if (od != null)
@@ -342,7 +366,7 @@ public class OverviewPanel extends JPanel
   @Override
   public void propertyChange(PropertyChangeEvent evt)
   {
-    setBoxPosition();
+    setBoxPositionOnly();
   }
 
   /**