- public static final String BJS_TEMPLATE_GIT_REPO = jalview.bin.Cache
- .getDefault(
- "biojs_template_git_repo",
- "https://raw.githubusercontent.com/tcofoegbu/bjs-template/master/package.json");
-
- public BioJsHTMLOutput(AlignmentViewPanel ap)
- {
- if (ap != null)
- {
- this.ap = ap;
- }
- }
-
- public void exportJalviewAlignmentAsBioJsHtmlFile()
- {
- try
- {
- String outputFile = getOutputFile();
- // 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(
-"#sequenceData#", jalviewAlignmentJson)
- .toString();
-
- PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
- outputFile));
- out.print(generatedBioJsWithJalviewAlignmentAsJson);
- out.flush();
- out.close();
- jalview.util.BrowserLauncher.openURL("file:///" + outputFile);
- } catch (NoFileSelectedException ex)
- {
- // do noting if no file was selected
- } catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public String getOutputFile() throws NoFileSelectedException
- {
- String selectedFile = null;
- JalviewFileChooser jvFileChooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
- { "html" }, new String[]
- { "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");
- jvFileChooser.setToolTipText(MessageManager.getString("action.save"));