JAL-3446 from applet -- reload; also fixes some repaint issues
[jalview.git] / src / jalview / gui / SeqCanvas.java
index f62507a..59a6cb1 100755 (executable)
@@ -99,6 +99,8 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
 
   private int availHeight;
 
+  private boolean allowFastPaint;
+
   // Don't do this! Graphics handles are supposed to be transient
   // private Graphics2D gg;
 
@@ -363,7 +365,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
       // 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.
-      // System.out.println("SeqCanvas fastPaint() repaint() request...");
       av.getAlignPanel().repaint();
     } finally
     {
@@ -385,7 +386,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     {
       return;
     }
-
     ViewportRanges ranges = av.getRanges();
     int startRes = ranges.getStartRes();
     int startSeq = ranges.getStartSeq();
@@ -415,11 +415,9 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     // }
 
     Rectangle vis, clip;
-    if (img != null
-            && (fastPaint
-                    || (vis = getVisibleRect()).width != (clip = g
-                            .getClipBounds()).width
-                    || vis.height != clip.height))
+    if (allowFastPaint  && img != null
+            && (fastPaint || (vis = getVisibleRect()).width != (clip = g.getClipBounds()).width
+                          || vis.height != clip.height))
     {
       g.drawImage(img, 0, 0, this);
       drawSelectionGroup((Graphics2D) g, startRes, endRes, startSeq,
@@ -428,6 +426,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
     }
     else
     {
+      allowFastPaint = true;
       // img is a cached version of the last view we drew.
       // If we have no img or the size has changed, make a new one.
       //
@@ -1744,9 +1743,6 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
               - ((int[]) evt.getOldValue())[0];
       scrollY = ((int[]) evt.getNewValue())[1]
               - ((int[]) evt.getOldValue())[1];
-
-      // System.out.println("SC dx dy " + scrollX + " " + scrollY);
-
       if (scrollX != 0 && scrollY != 0)
       {
         // all sorts of problems in JavaScript if this is commented out.
@@ -2274,7 +2270,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
    */
   public void setNoFastPaint()
   {
-    fastPaint = false;
+    allowFastPaint = false;
   }
 
 }