Merge branch 'develop' into features/JAL-2349_matrixvis
[jalview.git] / src / jalview / appletgui / AnnotationPanel.java
index e2d7e82..b3c97f2 100755 (executable)
@@ -30,6 +30,7 @@ import jalview.util.Comparison;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
 
 import java.awt.Color;
 import java.awt.Dimension;
@@ -118,13 +119,15 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
 
     // ap.annotationScroller.getVAdjustable().addAdjustmentListener( this );
     renderer = new AnnotationRenderer();
+
+    av.getRanges().addPropertyChangeListener(this);
   }
 
   public AnnotationPanel(AlignViewport av)
   {
     this.av = av;
     renderer = new AnnotationRenderer();
-    av.getRanges().addPropertyChangeListener(this);
+
   }
 
   @Override
@@ -758,8 +761,12 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI,
   public void propertyChange(PropertyChangeEvent evt)
   {
     // Respond to viewport range changes (e.g. alignment panel was scrolled)
-    if (evt.getPropertyName().equals("startres")
-            || evt.getPropertyName().equals("endres"))
+    // 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))
     {
       fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
     }