+ public void run()
+ {
+ try
+ {
+ setProgressMessage(null);
+ setProgressMessage(MessageManager.formatMessage(
+ "status.exporting_alignment_as_x_file", getDescription()));
+
+ String renderStyle = Cache.getDefault("HTML_RENDERING",
+ "Prompt each time");
+ AtomicBoolean textOption = new AtomicBoolean(
+ !"Lineart".equals(renderStyle));
+
+ /*
+ * configure the action to run on OK in the dialog
+ */
+ RunResponse okAction = new RunResponse(JOptionPane.OK_OPTION)
+ {
+ @Override
+ public void run()
+ {
+ doOutput(textOption.get());
+ }
+ };
+
+ /*
+ * Prompt for character rendering style if preference is not set
+ */
+ if (renderStyle.equalsIgnoreCase("Prompt each time") && !isHeadless())
+ {
+ LineartOptions svgOption = new LineartOptions("HTML", textOption);
+ svgOption.setResponseAction(new RunResponse(JOptionPane.NO_OPTION)
+ {
+ @Override
+ public void run()
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation",
+ getDescription()));
+ }
+ });
+ svgOption.setResponseAction(okAction);
+ svgOption.showDialog();
+ /* no code here - JalviewJS cannot execute it */
+ }
+ else
+ {
+ /*
+ * else (if preference set) just do the export action
+ */
+ doOutput(textOption.get());
+ }
+ } catch (OutOfMemoryError err)
+ {
+ System.out.println("########################\n" + "OUT OF MEMORY "
+ + generatedFile + "\n" + "########################");
+ new OOMWarning("Creating Image for " + generatedFile, err);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ setProgressMessage(MessageManager
+ .formatMessage("info.error_creating_file", getDescription()));
+ }
+ }
+
+ /**
+ * Builds and writes the image to the file specified by field
+ * <code>generatedFile</code>
+ *
+ * @param textCharacters
+ * true for Text character rendering, false for Lineart
+ */
+ protected void doOutput(boolean textCharacters)
+ {
+ try
+ {
+ AlignmentDimension aDimension = ap.getAlignmentDimension();
+ SVGGraphics2D idPanelGraphics = new SVGGraphics2D(
+ aDimension.getWidth(), aDimension.getHeight());
+ SVGGraphics2D alignPanelGraphics = new SVGGraphics2D(
+ aDimension.getWidth(), aDimension.getHeight());
+ if (!textCharacters) // Lineart selected
+ {
+ idPanelGraphics.setRenderingHint(
+ SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ alignPanelGraphics.setRenderingHint(
+ SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ }
+ if (ap.av.getWrapAlignment())
+ {
+ printWrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+ alignPanelGraphics);
+ }
+ else
+ {
+ 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());
+ FileOutputStream out = new FileOutputStream(generatedFile);
+ out.write(htmlData.getBytes());
+ out.flush();
+ out.close();
+ setProgressMessage(MessageManager
+ .formatMessage("status.export_complete", getDescription()));
+ exportCompleted();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ setProgressMessage(MessageManager
+ .formatMessage("info.error_creating_file", getDescription()));
+ }
+ }
+
+ @Override
+ protected String getDescription()