JAL-2780 JAL-2781 JAL-2902 refactor ‘OK’ action to optionally blocking method for...
[jalview.git] / src / jalview / gui / ScalePanel.java
index e5f2be8..798c833 100755 (executable)
@@ -54,8 +54,8 @@ import javax.swing.ToolTipManager;
  * The panel containing the sequence ruler (when not in wrapped mode), and
  * supports a range of mouse operations to select, hide or reveal columns.
  */
-public class ScalePanel extends JPanel implements MouseMotionListener,
-        MouseListener, ViewportListenerI
+public class ScalePanel extends JPanel
+        implements MouseMotionListener, MouseListener, ViewportListenerI
 {
   protected int offy = 4;
 
@@ -168,11 +168,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
         {
           av.showColumn(reveal[0]);
           reveal = null;
-          ap.paintAlignment(true);
-          if (ap.overviewPanel != null)
-          {
-            ap.overviewPanel.updateOverviewImage();
-          }
+          ap.paintAlignment(true, true);
           av.sendSelection();
         }
       });
@@ -188,11 +184,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
           {
             av.showAllHiddenColumns();
             reveal = null;
-            ap.paintAlignment(true);
-            if (ap.overviewPanel != null)
-            {
-              ap.overviewPanel.updateOverviewImage();
-            }
+            ap.paintAlignment(true, true);
             av.sendSelection();
           }
         });
@@ -210,18 +202,13 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
         public void actionPerformed(ActionEvent e)
         {
           av.hideColumns(res, res);
-          if (av.getSelectionGroup() != null
-                  && av.getSelectionGroup().getSize() == av.getAlignment()
-                          .getHeight())
+          if (av.getSelectionGroup() != null && av.getSelectionGroup()
+                  .getSize() == av.getAlignment().getHeight())
           {
             av.setSelectionGroup(null);
           }
 
-          ap.paintAlignment(true);
-          if (ap.overviewPanel != null)
-          {
-            ap.overviewPanel.updateOverviewImage();
-          }
+          ap.paintAlignment(true, true);
           av.sendSelection();
         }
       });
@@ -273,7 +260,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       sg.setEndRes(max);
     }
     av.setSelectionGroup(sg);
-    ap.paintAlignment(false);
+    ap.paintAlignment(false, false);
     av.sendSelection();
   }
 
@@ -310,7 +297,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       }
       else
       {
-        ap.paintAlignment(false);
+        ap.paintAlignment(false, false);
       }
       return;
     }
@@ -329,7 +316,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       }
     }
     stretchingGroup = false;
-    ap.paintAlignment(false);
+    ap.paintAlignment(false, false);
     av.sendSelection();
   }
 
@@ -359,7 +346,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
     {
       stretchingGroup = true;
       cs.stretchGroup(res, sg, min, max);
-      ap.paintAlignment(false);
+      ap.paintAlignment(false, false);
     }
   }
 
@@ -422,8 +409,15 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
   @Override
   public void paintComponent(Graphics g)
   {
-    drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
-            getWidth(), getHeight());
+    /*
+     * shouldn't get called in wrapped mode as the scale above is
+     * drawn instead by SeqCanvas.drawNorthScale
+     */
+    if (!av.getWrapAlignment())
+    {
+      drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
+              getWidth(), getHeight());
+    }
   }
 
   // scalewidth will normally be screenwidth,
@@ -503,10 +497,13 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
             continue;
           }
 
-          gg.fillPolygon(new int[] {
-              -1 + res * avCharWidth - avCharHeight / 4,
-              -1 + res * avCharWidth + avCharHeight / 4,
-              -1 + res * avCharWidth }, new int[] { y, y, y + 2 * yOf }, 3);
+          gg.fillPolygon(
+                  new int[]
+                  { -1 + res * avCharWidth - avCharHeight / 4,
+                      -1 + res * avCharWidth + avCharHeight / 4,
+                      -1 + res * avCharWidth },
+                  new int[]
+                  { y, y, y + 2 * yOf }, 3);
         }
       }
     }
@@ -552,7 +549,9 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
     // Here we only want to fastpaint on a scroll, with resize using a normal
     // paint, so scroll events are identified as changes to the horizontal or
     // vertical start value.
-    if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
+    if (evt.getPropertyName().equals(ViewportRanges.STARTRES)
+            || evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ)
+            || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
     {
       // scroll event, repaint panel
       repaint();