JAL-3253 temporary branch SwingJS upgrade with testNG fixes Java 8
[jalview.git] / src / jalview / appletgui / SeqCanvas.java
index 96eb6b9..ecb0888 100755 (executable)
@@ -40,6 +40,7 @@ import java.awt.Panel;
 import java.beans.PropertyChangeEvent;
 import java.util.Iterator;
 
+@SuppressWarnings("serial")
 public class SeqCanvas extends Panel implements ViewportListenerI
 {
   FeatureRenderer fr;
@@ -491,15 +492,17 @@ public class SeqCanvas extends Panel implements ViewportListenerI
                   { ypos - (avcharHeight / 2), ypos - (avcharHeight / 2), ypos - (avcharHeight / 2) + 8 }, 3);
         }
       }
-  
+      // BH 2020.03.19 avoiding g.setClip at all costs
+      g = g.create();
       if (g.getClip() == null)
       {
-        g.setClip(0, 0, cWidth * avcharWidth, canvasHeight);
+        g.clipRect(0, 0, cWidth * avcharWidth, canvasHeight);
       }
   
       drawPanel(g, startRes, endx, 0, al.getHeight() - 1, ypos);
-      g.setClip(null);
+      // g.setClip(null);
   
+      g.dispose();
       if (av.isShowAnnotation())
       {
         g.translate(0, cHeight + ypos + 4);
@@ -905,4 +908,19 @@ public class SeqCanvas extends Panel implements ViewportListenerI
     }
   }
 
+  /**
+   * Ensure that a full paint is done next, for whatever reason. This was
+   * necessary for JavaScript; apparently in Java the timing is just right on
+   * multiple threads (EventQueue-0, Consensus, Conservation) that we can get
+   * away with one fast paint before the others, but this ensures that in the
+   * end we get a full paint. Problem arose in relation to copy/paste, where the
+   * paste was not finalized with a full paint.
+   * 
+   * @author hansonr 2019.04.17
+   */
+  public void clearFastPaint()
+  {
+    fastPaint = false;
+  }
+
 }