exportStarted();
try
{
-
if (outputFile == null)
{
outputFile = getOutputFile();
}
generatedFile = new File(outputFile);
-
- String bioJSON = getBioJSONData();
- String bioJSTemplateString = HTMLOutput.readFileAsString(getCurrentBJSTemplateFile());
- String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
- .replaceAll("#sequenceData#", bioJSON).toString();
-
- PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
- generatedFile));
- out.print(generatedBioJsWithJalviewAlignmentAsJson);
- out.flush();
- out.close();
- exportCompleted();
- setProgressMessage(MessageManager.formatMessage(
- "status.export_complete", "BioJS"));
-
- } catch (NoFileSelectedException ex)
- {
- // do noting if no file was selected
- } catch (OutOfMemoryError err)
+ } catch (NoFileSelectedException e)
{
- System.out.println("########################\n" + "OUT OF MEMORY "
- + outputFile + "\n" + "########################");
- new OOMWarning("Creating Image for " + outputFile, err);
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "BioJS MSA"));
+ return;
} catch (Exception e)
{
setProgressMessage(MessageManager.formatMessage(
- "info.error_creating_file", "HTML"));
+ "info.error_creating_file", "BioJS MSA"));
e.printStackTrace();
+ return;
}
+ new Thread(this).start();
+
}
return generatedFile;
}
+ @Override
+ public void run()
+ {
+ try
+ {
+ String bioJSON = getBioJSONData();
+ String bioJSTemplateString = HTMLOutput
+ .readFileAsString(getCurrentBJSTemplateFile());
+ String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
+ .replaceAll("#sequenceData#", bioJSON).toString();
+
+ PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
+ generatedFile));
+ out.print(generatedBioJsWithJalviewAlignmentAsJson);
+ out.flush();
+ out.close();
+ setProgressMessage(MessageManager.formatMessage(
+ "status.export_complete", "BioJS"));
+ exportCompleted();
+
+ } catch (OutOfMemoryError err)
+ {
+ System.out.println("########################\n" + "OUT OF MEMORY "
+ + generatedFile + "\n" + "########################");
+ new OOMWarning("Creating Image for " + generatedFile, err);
+ } catch (Exception e)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "info.error_creating_file", "HTML"));
+ e.printStackTrace();
+ }
+
+ }
+
}
import java.util.Objects;
-public abstract class HTMLOutput
+public abstract class HTMLOutput implements Runnable
{
protected AlignmentPanel ap;
}
}
-
public String getBioJSONData()
{
+ return getBioJSONData(null);
+ }
+
+ public String getBioJSONData(AlignExportSettingI exportSettings)
+ {
if (!isEmbedData())
{
return null;
}
- AlignExportSettingI exportSettings = new AlignExportSettingI()
+ if (exportSettings == null)
{
- @Override
- public boolean isExportHiddenSequences()
+ exportSettings = new AlignExportSettingI()
{
- return true;
- }
-
- @Override
- public boolean isExportHiddenColumns()
- {
- return true;
- }
+ @Override
+ public boolean isExportHiddenSequences()
+ {
+ return true;
+ }
- @Override
- public boolean isExportAnnotations()
- {
- return true;
- }
+ @Override
+ public boolean isExportHiddenColumns()
+ {
+ return true;
+ }
- @Override
- public boolean isExportFeatures()
- {
- return true;
- }
+ @Override
+ public boolean isExportAnnotations()
+ {
+ return true;
+ }
- @Override
- public boolean isExportGroups()
- {
- return true;
- }
+ @Override
+ public boolean isExportFeatures()
+ {
+ return true;
+ }
- @Override
- public boolean isCancelled()
- {
- return false;
- }
+ @Override
+ public boolean isExportGroups()
+ {
+ return true;
+ }
- };
+ @Override
+ public boolean isCancelled()
+ {
+ return false;
+ }
+ };
+ }
AlignmentExportData exportData = jalview.gui.AlignFrame
.getAlignmentForExport(JSONFile.FILE_DESC,
ap.getAlignViewport(), exportSettings);
jvFileChooser.setFileView(new JalviewFileView());
jvFileChooser.setDialogTitle(MessageManager
- .getString("label.save_as_biojs_html"));
+ .getString("label.save_as_html"));
jvFileChooser.setToolTipText(MessageManager.getString("action.save"));
int fileChooserOpt = jvFileChooser.showSaveDialog(null);
}
else
{
- pIndicator.setProgressBar(MessageManager.formatMessage(
- "status.cancelled_image_export_operation", "BioJS"),
- pSessionId);
throw new NoFileSelectedException("No file was selected.");
}
return selectedFile;
*/
package jalview.io;
+import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
import jalview.gui.HTMLOptions;
import jalview.gui.OOMWarning;
public class HtmlSvgOutput extends HTMLOutput
{
- private File generatedFile;
public HtmlSvgOutput(AlignmentPanel ap)
{
}
@Override
- public void exportHTML(String file)
+ public void exportHTML(String outputFile)
{
exportStarted();
try
{
- if (file == null)
+ if (outputFile == null)
{
- file = getOutputFile();
+ outputFile = getOutputFile();
}
- generatedFile = new File(file);
+ generatedFile = new File(outputFile);
+ } catch (NoFileSelectedException e)
+ {
+ setProgressMessage(MessageManager.formatMessage(
+ "status.cancelled_image_export_operation", "HTML"));
+ return;
} catch (Exception e)
{
setProgressMessage(MessageManager.formatMessage(
e.printStackTrace();
return;
}
- new Thread()
- {
- @Override
- public void run()
- {
- try
- {
- setProgressMessage(null);
- setProgressMessage(MessageManager.formatMessage(
- "status.exporting_alignment_as_x_file", "HTML"));
- AlignmentDimension aDimension = ap.getAlignmentDimension();
- SVGGraphics2D idPanelGraphics = new SVGGraphics2D(
- aDimension.getWidth(),
- aDimension.getHeight());
- SVGGraphics2D alignPanelGraphics = 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")
- && !isHeadless())
- {
- 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"))
- {
- 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();
- exportCompleted();
- } 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", "HTML"));
- }
- setProgressMessage(MessageManager.formatMessage(
- "status.export_complete", "HTML"));
- }
- }.start();
-
+ new Thread(this).start();
}
.append(alignmentSvg).append("</div>");
htmlSvg.append("<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js\"></script>\n"
+ "<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js\"></script>\n");
-
}
// javascript for launching file in Jalview
-
htmlSvg.append("<script language=\"JavaScript\">\n");
htmlSvg.append("function openJalviewUsingCurrentUrl(){\n");
htmlSvg.append(" var json = JSON.parse(document.getElementById(\"seqData\").innerHTML);\n");
htmlSvg.append(" document.body.removeChild(myForm);\n");
htmlSvg.append("}\n");
- // jquery facebox for displaying raw BioJSON data");
if (jsonData != null)
{
+ // JQuery FaceBox for displaying raw BioJSON data");
File faceBoxJsFile = new File("examples/javascript/facebox-1.3.js");
try
{
{
return generatedFile;
}
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ setProgressMessage(null);
+ setProgressMessage(MessageManager.formatMessage(
+ "status.exporting_alignment_as_x_file", "HTML"));
+ AlignmentDimension aDimension = ap.getAlignmentDimension();
+ SVGGraphics2D idPanelGraphics = new SVGGraphics2D(
+ aDimension.getWidth(), aDimension.getHeight());
+ SVGGraphics2D alignPanelGraphics = 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") && !isHeadless())
+ {
+ 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"))
+ {
+ 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", "HTML"));
+ exportCompleted();
+ } 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", "HTML"));
+ }
+ }
}