JAL-2464 fix cancel tree print behaviour
[jalview.git] / src / jalview / gui / TreeCanvas.java
index 9fa98ee..9a38d4c 100755 (executable)
@@ -549,7 +549,16 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
   public void run()
   {
     PrinterJob printJob = PrinterJob.getPrinterJob();
-    PageFormat pf = printJob.pageDialog(printJob.defaultPage());
+    PageFormat defaultPage = printJob.defaultPage();
+    PageFormat pf = printJob.pageDialog(defaultPage);
+
+    if (defaultPage == pf)
+    {
+      /*
+       * user cancelled
+       */
+      return;
+    }
 
     printJob.setPrintable(this, pf);
 
@@ -1010,7 +1019,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       }
       sg.setColourScheme(cs);
       sg.getGroupColourScheme().setThreshold(
-              av.getViewportColourScheme().getThreshold(),
+              av.getResidueShading().getThreshold(),
               av.isIgnoreGapsConsensus());
       // sg.recalcConservation();
       sg.setName("JTreeGroup:" + sg.hashCode());
@@ -1019,7 +1028,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       for (int a = 0; a < aps.length; a++)
       {
         if (aps[a].av.getGlobalColourScheme() != null
-                && aps[a].av.getViewportColourScheme()
+                && aps[a].av.getResidueShading()
                         .conservationApplied())
         {
           Conservation c = new Conservation("Group", sg.getSequences(null),