X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FBioJsHTMLOutput.java;h=528ba090df58ce38ba79dfb14ef874f0fc53766d;hb=2526066acdc3faf3a178e50672c78e428287e9ef;hp=b49c2e00ec824e3da1bd4823753c754e269629a2;hpb=492340a6ceedebe4c496d8a4673eb2f1ff835b38;p=jalview.git diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index b49c2e0..528ba09 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -1,11 +1,10 @@ package jalview.io; +import jalview.api.AlignmentViewPanel; +import jalview.datamodel.AlignmentExportData; import jalview.exceptions.NoFileSelectedException; -import jalview.gui.AlignViewport; -import jalview.gui.AlignmentPanel; -import jalview.gui.FeatureRenderer; -import jalview.json.binding.v1.BioJSReleasePojo; -import jalview.json.binding.v1.BioJSRepositoryPojo; +import jalview.json.binding.biojs.BioJSReleasePojo; +import jalview.json.binding.biojs.BioJSRepositoryPojo; import jalview.util.MessageManager; import java.io.BufferedInputStream; @@ -23,7 +22,7 @@ import java.util.TreeMap; public class BioJsHTMLOutput { - private AlignViewport av; + private AlignmentViewPanel ap; private static File currentBJSTemplateFile; @@ -40,12 +39,11 @@ public class BioJsHTMLOutput "biojs_template_git_repo", "https://raw.githubusercontent.com/tcofoegbu/bjs-template/master/package.json"); - public BioJsHTMLOutput(AlignmentPanel ap, FeatureRenderer fr1) + public BioJsHTMLOutput(AlignmentViewPanel ap) { if (ap != null) { - this.av = ap.av; - av.setFeatureRenderer(new FeatureRenderer(ap)); + this.ap = ap; } } @@ -54,7 +52,20 @@ public class BioJsHTMLOutput try { String outputFile = getOutputFile(); - String jalviewAlignmentJson = JSONFile.getJSONData(av); + // String jalviewAlignmentJson = JSONFile.getJSONData(ap); + AlignmentExportData exportData = jalview.gui.AlignFrame + .getAlignmentForExport( + JSONFile.FILE_DESC, ap.getAlignViewport()); + if (exportData.getSettings().isCancelled()) + { + return; + } + String jalviewAlignmentJson = new FormatAdapter(ap, + exportData.getSettings()).formatSequences(JSONFile.FILE_DESC, + exportData.getAlignment(), exportData.getOmitHidden(), + exportData.getStartEndPostions(), ap.getAlignViewport() + .getColumnSelection()); + String bioJSTemplateString = getBioJsTemplateAsString(); String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString .replaceAll( @@ -85,7 +96,6 @@ public class BioJsHTMLOutput { "HTML files" }, "HTML files"); jvFileChooser.setFileView(new JalviewFileView()); - // TODO uncomment when supported by MassageManager jvFileChooser.setDialogTitle(MessageManager .getString("label.save_as_biojs_html")); jvFileChooser.setDialogTitle("save as BioJs HTML"); @@ -148,7 +158,7 @@ public class BioJsHTMLOutput return sb.toString(); } - public void refreshBioJSVersionsInfo(String dirName) + public static void refreshBioJSVersionsInfo(String dirName) throws URISyntaxException { File directory = new File(BJS_TEMPLATES_LOCAL_DIRECTORY); @@ -181,7 +191,7 @@ public class BioJsHTMLOutput setBioJsMSAVersions(versionFileMap); } - public void updateBioJS() + public static void updateBioJS() { Thread updateThread = new Thread() { @@ -190,10 +200,13 @@ public class BioJsHTMLOutput try { String gitRepoPkgJson = getURLContentAsString(BJS_TEMPLATE_GIT_REPO); - BioJSRepositoryPojo release = new BioJSRepositoryPojo( - gitRepoPkgJson); - syncUpdates(BJS_TEMPLATES_LOCAL_DIRECTORY, release); - refreshBioJSVersionsInfo(BJS_TEMPLATES_LOCAL_DIRECTORY); + if (gitRepoPkgJson != null) + { + BioJSRepositoryPojo release = new BioJSRepositoryPojo( + gitRepoPkgJson); + syncUpdates(BJS_TEMPLATES_LOCAL_DIRECTORY, release); + refreshBioJSVersionsInfo(BJS_TEMPLATES_LOCAL_DIRECTORY); + } } catch (URISyntaxException e) { e.printStackTrace(); @@ -205,7 +218,7 @@ public class BioJsHTMLOutput } - public void syncUpdates(String localDir, BioJSRepositoryPojo repo) + public static void syncUpdates(String localDir, BioJSRepositoryPojo repo) { for (BioJSReleasePojo bjsRelease : repo.getReleases()) {