AlignmentPanel ap;
+ private IProgressIndicator pIndicator;
+
+ private long pSessionId;
+
+ private boolean headless;
+
+
public HtmlSvgOutput(File file, AlignmentPanel ap)
{
this.av = ap.av;
public void generateHtmlSvgOutput(File file)
{
- IProgressIndicator pIndicator = ap.alignFrame;
- long pSessionId = System.currentTimeMillis();
+ pIndicator = ap.alignFrame;
+ pSessionId = System.currentTimeMillis();
try
{
- boolean headless = (System.getProperty("java.awt.headless") != null && System
+ headless = (System.getProperty("java.awt.headless") != null && System
.getProperty("java.awt.headless").equals("true"));
if (file == null)
{
- if (pIndicator != null && !headless)
- {
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "status.waiting_for_user_to_select_output_file", "HTML"),
- pSessionId);
- }
+ setProgressMessage(MessageManager.formatMessage(
+ "status.waiting_for_user_to_select_output_file", "HTML"));
JalviewFileChooser chooser = getHTMLChooser();
chooser.setFileView(new jalview.io.JalviewFileView());
chooser.setDialogTitle(ap.alignFrame.getTitle());
jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
.getSelectedFile().getParent());
file = chooser.getSelectedFile();
+ ap.alignFrame.repaint();
}
else
{
-
- if (pIndicator != null && !headless)
- {
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "HTML"),
- pSessionId);
- }
- return;
- }
- }
-
- AlignmentDimension aDimension = ap.getAlignmentDimension();
- SVGGraphics2D g1 = new SVGGraphics2D(aDimension.getWidth(),
- aDimension.getHeight());
- SVGGraphics2D g2 = new SVGGraphics2D(aDimension.getWidth(),
- aDimension.getHeight());
-
- String renderStyle = jalview.bin.Cache.getDefault("HTML_RENDERING",
- "Prompt each time");
-
- // If we need to prompt, and if the GUI is visible then
- // Prompt for rendering style
- if (renderStyle.equalsIgnoreCase("Prompt each time")
- && !(System.getProperty("java.awt.headless") != null && System
- .getProperty("java.awt.headless").equals("true")))
- {
- HTMLOptions svgOption = new HTMLOptions();
- renderStyle = svgOption.getValue();
-
- if (renderStyle == null || svgOption.cancelled)
- {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "HTML"));
return;
}
}
-
- if (renderStyle.equalsIgnoreCase("Lineart"))
- {
- g1.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
- SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
- g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
- SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
- }
- printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, g1,
- g2);
-
- String titleSvgData = g1.getSVGDocument();
- String alignSvgData = g2.getSVGDocument();
- String jsonData = null;
- boolean isEmbbedBioJSON = Boolean.valueOf(jalview.bin.Cache
- .getDefault("EXPORT_EMBBED_BIOJSON", "true"));
- if (isEmbbedBioJSON)
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ final File fileX = file;
+ new Thread()
+ {
+ @Override
+ public void run()
{
- AlignExportSettingI exportSettings = new AlignExportSettingI()
+ try
{
- @Override
- public boolean isExportHiddenSequences()
+ setProgressMessage(null);
+ setProgressMessage(MessageManager
+.formatMessage(
+ "status.exporting_alignment_as_x_file", "HTML"));
+ AlignmentDimension aDimension = ap.getAlignmentDimension();
+ SVGGraphics2D g1 = new SVGGraphics2D(aDimension.getWidth(),
+ aDimension.getHeight());
+ SVGGraphics2D g2 = new SVGGraphics2D(aDimension.getWidth(),
+ aDimension.getHeight());
+
+ String renderStyle = jalview.bin.Cache.getDefault(
+ "HTML_RENDERING", "Prompt each time");
+
+ // If we need to prompt, and if the GUI is visible then
+ // Prompt for rendering style
+ if (renderStyle.equalsIgnoreCase("Prompt each time")
+ && !(System.getProperty("java.awt.headless") != null && System
+ .getProperty("java.awt.headless").equals("true")))
{
- return true;
- }
+ HTMLOptions svgOption = new HTMLOptions();
+ renderStyle = svgOption.getValue();
- @Override
- public boolean isExportHiddenColumns()
- {
- return true;
+ if (renderStyle == null || svgOption.cancelled)
+ {
+ return;
+ }
}
- @Override
- public boolean isExportAnnotations()
+ if (renderStyle.equalsIgnoreCase("Lineart"))
{
- return true;
+ g1.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
+ g2.setRenderingHint(SVGHints.KEY_DRAW_STRING_TYPE,
+ SVGHints.VALUE_DRAW_STRING_TYPE_VECTOR);
}
-
- @Override
- public boolean isExportFeatures()
+ printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
+ g1, g2);
+
+ String titleSvgData = g1.getSVGDocument();
+ String alignSvgData = g2.getSVGDocument();
+ String jsonData = null;
+ boolean isEmbbedBioJSON = Boolean.valueOf(jalview.bin.Cache
+ .getDefault("EXPORT_EMBBED_BIOJSON", "true"));
+ if (isEmbbedBioJSON)
{
- return true;
+ AlignExportSettingI exportSettings = new AlignExportSettingI()
+ {
+ @Override
+ public boolean isExportHiddenSequences()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportHiddenColumns()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportAnnotations()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportFeatures()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportGroups()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isCancelled()
+ {
+ return false;
+ }
+
+ };
+ AlignmentExportData exportData = jalview.gui.AlignFrame
+ .getAlignmentForExport(JSONFile.FILE_DESC, av,
+ exportSettings);
+ jsonData = new FormatAdapter(ap, exportData.getSettings())
+ .formatSequences(JSONFile.FILE_DESC,
+ exportData.getAlignment(),
+ exportData.getOmitHidden(),
+ exportData.getStartEndPostions(),
+ av.getColumnSelection());
}
-
- @Override
- public boolean isExportGroups()
+ String htmlData = getHtml(titleSvgData, alignSvgData, jsonData);
+ FileOutputStream out = new FileOutputStream(fileX);
+ out.write(htmlData.getBytes());
+ out.flush();
+ out.close();
+ if (!(System.getProperty("java.awt.headless") != null && System
+ .getProperty("java.awt.headless").equals("true")))
{
- return true;
+ jalview.util.BrowserLauncher.openURL("file:///" + fileX);
}
+ } catch (OutOfMemoryError err)
+ {
+ System.out.println("########################\n"
+ + "OUT OF MEMORY " + fileX + "\n"
+ + "########################");
+ new OOMWarning("Creating Image for " + fileX, err);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ pIndicator.setProgressBar(MessageManager.formatMessage(
+ "info.error_creating_file", "HTML"), pSessionId);
+ }
+ setProgressMessage(MessageManager.formatMessage(
+ "status.export_complete", "HTML"));
+ }
+ }.start();
- @Override
- public boolean isCancelled()
- {
- return false;
- }
+ }
- };
- AlignmentExportData exportData = jalview.gui.AlignFrame
- .getAlignmentForExport(JSONFile.FILE_DESC, av,
- exportSettings);
- jsonData = new FormatAdapter(ap, exportData.getSettings())
- .formatSequences(JSONFile.FILE_DESC,
- exportData.getAlignment(),
- exportData.getOmitHidden(),
- exportData.getStartEndPostions(),
- av.getColumnSelection());
- }
- String htmlData = getHtml(titleSvgData, alignSvgData, jsonData);
- FileOutputStream out = new FileOutputStream(file);
- out.write(htmlData.getBytes());
- out.flush();
- out.close();
- if (!(System.getProperty("java.awt.headless") != null && System
- .getProperty("java.awt.headless").equals("true")))
- {
- jalview.util.BrowserLauncher.openURL("file:///" + file);
- }
- if (pIndicator != null && !headless)
- {
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "status.export_complete", "HTML"), pSessionId);
- }
- } catch (OutOfMemoryError err)
+ private void setProgressMessage(String message)
+ {
+ if (pIndicator != null && !headless)
{
- System.out.println("########################\n" + "OUT OF MEMORY "
- + file + "\n" + "########################");
- new OOMWarning("Creating Image for " + file, err);
- } catch (Exception e)
+ pIndicator.setProgressBar(message, pSessionId);
+ }
+ else
{
- e.printStackTrace();
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "info.error_creating_file", "HTML"), pSessionId);
+ System.out.println(message);
}
}