JAL-3184 restore group visibility on Cancel in Feature Settings
[jalview.git] / src / jalview / gui / ScalePanel.java
index c8040de..6abee08 100755 (executable)
@@ -276,7 +276,9 @@ public class ScalePanel extends JPanel
   {
     mouseDragging = false;
 
-    int res = (evt.getX() / av.getCharWidth())
+    int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates
+
+    int res = (xCords / av.getCharWidth())
             + av.getRanges().getStartRes();
 
     if (av.hasHiddenColumns())
@@ -410,6 +412,8 @@ public class ScalePanel extends JPanel
   @Override
   public void paintComponent(Graphics g)
   {
+    super.paintComponent(g);
+
     /*
      * shouldn't get called in wrapped mode as the scale above is
      * drawn instead by SeqCanvas.drawNorthScale
@@ -488,7 +492,7 @@ public class ScalePanel extends JPanel
 
       if (av.getShowHiddenMarkers())
       {
-        Iterator<Integer> it = hidden.getBoundedStartIterator(startx,
+        Iterator<Integer> it = hidden.getStartRegionIterator(startx,
                 startx + widthx + 1);
         while (it.hasNext())
         {
@@ -550,7 +554,11 @@ public class ScalePanel extends JPanel
             || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
     {
       // scroll event, repaint panel
-      repaint();
+       
+       // Call repaint on alignment panel so that repaints from other alignment
+    // panel components can be aggregated. Otherwise performance of the overview
+    // window and others may be adversely affected.
+      av.getAlignPanel().repaint();
     }
   }