JAL-2775 added repaint clipping
[jalview.git] / src / jalview / gui / ScalePanel.java
index e5f2be8..1db4051 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;
 
@@ -169,10 +169,6 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
           av.showColumn(reveal[0]);
           reveal = null;
           ap.paintAlignment(true);
-          if (ap.overviewPanel != null)
-          {
-            ap.overviewPanel.updateOverviewImage();
-          }
           av.sendSelection();
         }
       });
@@ -189,10 +185,6 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
             av.showAllHiddenColumns();
             reveal = null;
             ap.paintAlignment(true);
-            if (ap.overviewPanel != null)
-            {
-              ap.overviewPanel.updateOverviewImage();
-            }
             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();
-          }
           av.sendSelection();
         }
       });
@@ -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);
         }
       }
     }