JAL-147 don't draw ScalePanel when in wrapped mode
[jalview.git] / src / jalview / gui / ScalePanel.java
index 3cdba8d..ec03681 100755 (executable)
@@ -29,6 +29,7 @@ import jalview.renderer.ScaleRenderer.ScaleMark;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
 
 import java.awt.Color;
 import java.awt.FontMetrics;
@@ -421,8 +422,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,
@@ -546,7 +554,16 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
   public void propertyChange(PropertyChangeEvent evt)
   {
     // Respond to viewport change events (e.g. alignment panel was scrolled)
-    repaint();
+    // Both scrolling and resizing change viewport ranges: scrolling changes
+    // both start and end points, but resize only changes end values.
+    // 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))
+    {
+      // scroll event, repaint panel
+      repaint();
+    }
   }
 
 }