JAL-1713 update from Jalview 2.11.3 develop
[jalview.git] / src / jalview / io / HtmlSvgOutput.java
index b8241c8..9fb3720 100644 (file)
  */
 package jalview.io;
 
-import jalview.bin.Cache;
-import jalview.gui.AlignmentPanel;
-import jalview.gui.LineartOptions;
-import jalview.gui.OOMWarning;
-import jalview.math.AlignmentDimension;
-import jalview.util.MessageManager;
-
 import java.awt.Graphics;
 import java.awt.print.PrinterException;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.jfree.graphics2d.svg.SVGGraphics2D;
 import org.jfree.graphics2d.svg.SVGHints;
 
+import jalview.bin.Cache;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.LineartOptions;
+import jalview.gui.OOMWarning;
+import jalview.math.AlignmentDimension;
+import jalview.util.MessageManager;
+
 public class HtmlSvgOutput extends HTMLOutput
 {
   public HtmlSvgOutput(AlignmentPanel ap)
@@ -58,8 +59,8 @@ public class HtmlSvgOutput extends HTMLOutput
     return ap.printWrappedAlignment(pwidth, pheight, pi, pg[0]);
   }
 
-  String getHtml(String titleSvg, String alignmentSvg,
-          String jsonData, boolean wrapped)
+  String getHtml(String titleSvg, String alignmentSvg, String jsonData,
+          boolean wrapped)
   {
     StringBuilder htmlSvg = new StringBuilder();
     htmlSvg.append("<html>\n");
@@ -188,8 +189,8 @@ public class HtmlSvgOutput extends HTMLOutput
   @Override
   public boolean isEmbedData()
   {
-    return Boolean.valueOf(
-            jalview.bin.Cache.getDefault("EXPORT_EMBBED_BIOJSON", "true"));
+    return Boolean
+            .valueOf(Cache.getDefault("EXPORT_EMBBED_BIOJSON", "true"));
   }
 
   @Override
@@ -211,13 +212,9 @@ public class HtmlSvgOutput extends HTMLOutput
       /*
        * configure the action to run on OK in the dialog
        */
-      Runnable okAction = new Runnable()
-      {
-        @Override
-        public void run()
-        {
-          doOutput(textOption.get());
-        }
+      Callable<Void> okAction = () -> {
+        doOutput(textOption.get());
+        return null;
       };
 
       /*
@@ -226,15 +223,11 @@ public class HtmlSvgOutput extends HTMLOutput
       if (renderStyle.equalsIgnoreCase("Prompt each time") && !isHeadless())
       {
         LineartOptions svgOption = new LineartOptions("HTML", textOption);
-        svgOption.setResponseAction(1, new Runnable()
-        {
-          @Override
-          public void run()
-          {
-            setProgressMessage(MessageManager.formatMessage(
-                    "status.cancelled_image_export_operation",
-                    getDescription()));
-          }
+        svgOption.setResponseAction(1, () -> {
+          setProgressMessage(MessageManager.formatMessage(
+                  "status.cancelled_image_export_operation",
+                  getDescription()));
+          return null;
         });
         svgOption.setResponseAction(0, okAction);
         svgOption.showDialog();
@@ -278,11 +271,9 @@ public class HtmlSvgOutput extends HTMLOutput
               aDimension.getWidth(), aDimension.getHeight());
       if (!textCharacters) // Lineart selected
       {
-        idPanelGraphics.setRenderingHint(
-                SVGHints.KEY_DRAW_STRING_TYPE,
+        idPanelGraphics.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
                 SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
-        alignPanelGraphics.setRenderingHint(
-                SVGHints.KEY_DRAW_STRING_TYPE,
+        alignPanelGraphics.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
                 SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
       }
       if (ap.av.getWrapAlignment())
@@ -292,15 +283,15 @@ public class HtmlSvgOutput extends HTMLOutput
       }
       else
       {
-        printUnwrapped(aDimension.getWidth(), aDimension.getHeight(),
-                0, idPanelGraphics, alignPanelGraphics);
+        printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+                idPanelGraphics, alignPanelGraphics);
       }
 
       String idPanelSvgData = idPanelGraphics.getSVGDocument();
       String alignPanelSvgData = alignPanelGraphics.getSVGDocument();
       String jsonData = getBioJSONData();
-      String htmlData = getHtml(idPanelSvgData, alignPanelSvgData,
-              jsonData, ap.av.getWrapAlignment());
+      String htmlData = getHtml(idPanelSvgData, alignPanelSvgData, jsonData,
+              ap.av.getWrapAlignment());
       FileOutputStream out = new FileOutputStream(generatedFile);
       out.write(htmlData.getBytes());
       out.flush();