JAL-3253 temporary branch SwingJS upgrade with testNG fixes Java 8
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index 72a074d..1c2e91c 100644 (file)
@@ -67,8 +67,6 @@ import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.List;
 
-import javax.swing.SwingUtilities;
-
 /**
  * The main panel of an AlignFrame, containing holders for the IdPanel,
  * SeqPanel, AnnotationLabels (a JPanel), and AnnotationPanel.
@@ -802,7 +800,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
       // This is only called if file loaded is a jar file that
       // was wrapped when saved and user has wrap alignment true
       // as preference setting
-      SwingUtilities.invokeLater(new Runnable()
+      Jalview.execRunnable(new Runnable()
       {
         @Override
         public void run()
@@ -1079,6 +1077,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   public int printWrappedAlignment(int pageWidth, int pageHeight, int pageNumber,
           Graphics g) throws PrinterException
   {
+
     int annotationHeight = 0;
     if (av.isShowAnnotation())
     {
@@ -1103,6 +1102,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
 
     int totalHeight = cHeight * (maxwidth / resWidth + 1);
 
+    g = g.create();
+
     g.setColor(Color.white);
     g.fillRect(0, 0, pageWidth, pageHeight);
     g.setFont(av.getFont());
@@ -1116,7 +1117,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
      */
     g.translate(0, -pageNumber * pageHeight);
 
-    g.setClip(0, pageNumber * pageHeight, pageWidth, pageHeight);
+    // BH 2020.03.19 avoiding g.setClip
+    g.clipRect(0, pageNumber * pageHeight, pageWidth, pageHeight);
 
     /*
      * draw sequence ids and annotation labels (if shown)
@@ -1129,6 +1131,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
     getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth,
             totalHeight, 0);
 
+    g.dispose();
     if ((pageNumber * pageHeight) < totalHeight)
     {
       return Printable.PAGE_EXISTS;