X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FBioJsHTMLOutput.java;h=11436d39d3c5cce2c2e6b02c98bc319fded00607;hb=86a9434feba170f5a91b0eb366d152262cc65ff8;hp=1be97f507c6004abdcb36cb395c880baff5c9e53;hpb=e60cacff9260c47c12cf34a7e191678cfc97d265;p=jalview.git diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 1be97f5..11436d3 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -20,7 +20,6 @@ */ package jalview.io; -import jalview.exceptions.NoFileSelectedException; import jalview.gui.AlignmentPanel; import jalview.gui.OOMWarning; import jalview.json.binding.biojs.BioJSReleasePojo; @@ -41,7 +40,6 @@ import java.util.TreeMap; public class BioJsHTMLOutput extends HTMLOutput { - private static File currentBJSTemplateFile; private static TreeMap bioJsMSAVersions; @@ -53,8 +51,7 @@ public class BioJsHTMLOutput extends HTMLOutput .getDefault("biojs_template_directory", DEFAULT_DIR); public static final String BJS_TEMPLATE_GIT_REPO = jalview.bin.Cache - .getDefault( - "biojs_template_git_repo", + .getDefault("biojs_template_git_repo", "https://raw.githubusercontent.com/jalview/exporter-templates/master/biojs/package.json"); public BioJsHTMLOutput(AlignmentPanel ap) @@ -62,51 +59,6 @@ public class BioJsHTMLOutput extends HTMLOutput super(ap); } - @Override - public void exportHTML(String outputFile) - { - 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) - { - System.out.println("########################\n" + "OUT OF MEMORY " - + outputFile + "\n" + "########################"); - new OOMWarning("Creating Image for " + outputFile, err); - } catch (Exception e) - { - setProgressMessage(MessageManager.formatMessage( - "info.error_creating_file", "HTML")); - e.printStackTrace(); - } - } - - - public static void refreshVersionInfo(String dirName) throws URISyntaxException { @@ -149,7 +101,8 @@ public class BioJsHTMLOutput extends HTMLOutput { try { - String gitRepoPkgJson = getURLContentAsString(BJS_TEMPLATE_GIT_REPO); + String gitRepoPkgJson = getURLContentAsString( + BJS_TEMPLATE_GIT_REPO); if (gitRepoPkgJson != null) { BioJSRepositoryPojo release = new BioJSRepositoryPojo( @@ -251,8 +204,8 @@ public class BioJsHTMLOutput extends HTMLOutput } } } - return responseStrBuilder == null ? null : responseStrBuilder - .toString(); + return responseStrBuilder == null ? null + : responseStrBuilder.toString(); } public static File getCurrentBJSTemplateFile() @@ -289,9 +242,43 @@ public class BioJsHTMLOutput extends HTMLOutput } @Override - public File getExportedFile() + 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", getDescription())); + 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", getDescription())); + e.printStackTrace(); + } + + } + + @Override + protected String getDescription() { - return generatedFile; + return "BioJS MSA"; } }