JAL-3208 re-enable the setprop CLI arg, but only in JalviewJS
[jalview.git] / src / jalview / gui / ScalePanel.java
index ea4b42b..6912a02 100755 (executable)
@@ -132,8 +132,9 @@ public class ScalePanel extends JPanel
     if (evt.isPopupTrigger()) // Mac: mousePressed
     {
       rightMouseButtonPressed(evt, res);
+      return;
     }
-    else if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
+    if (Platform.isWinRightButton(evt))
     {
       /*
        * defer right-mouse click handling to mouse up on Windows
@@ -142,10 +143,7 @@ public class ScalePanel extends JPanel
        */
       return;
     }
-    else
-    {
-      leftMouseButtonPressed(evt, res);
-    }
+    leftMouseButtonPressed(evt, res);
   }
 
   /**
@@ -267,10 +265,10 @@ public class ScalePanel extends JPanel
   }
 
   /**
-   * DOCUMENT ME!
+   * Action on mouseUp is to set the limit of the current selection group (if
+   * there is one) and broadcast the selection
    * 
    * @param evt
-   *          DOCUMENT ME!
    */
   @Override
   public void mouseReleased(MouseEvent evt)
@@ -278,7 +276,10 @@ public class ScalePanel extends JPanel
     mouseDragging = false;
     ap.getSeqPanel().stopScrolling();
 
-    int res = (evt.getX() / av.getCharWidth())
+    // todo res calculation should be a method on AlignViewport
+    int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates
+
+    int res = (xCords / av.getCharWidth())
             + av.getRanges().getStartRes();
 
     if (av.hasHiddenColumns())
@@ -286,7 +287,6 @@ public class ScalePanel extends JPanel
       res = av.getAlignment().getHiddenColumns()
               .visibleToAbsoluteColumn(res);
     }
-
     res = Math.min(res, av.getAlignment().getWidth() - 1);
 
     if (!stretchingGroup)
@@ -355,6 +355,7 @@ public class ScalePanel extends JPanel
   {
     if (mouseDragging)
     {
+      mouseDragging = false;
       ap.getSeqPanel().stopScrolling();
     }
   }
@@ -415,7 +416,7 @@ public class ScalePanel extends JPanel
   @Override
   public void paintComponent(Graphics g)
   {
-    super.paintComponent(g);
+    //super.paintComponent(g);  // BH 2019
 
     /*
      * shouldn't get called in wrapped mode as the scale above is