X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FHtmlSvgOutput.java;h=c8d6975f3bbf4520a49efd0b1188a22e79dacdfc;hb=6e314387a9cf3c422388cd8b8315811ee58621f0;hp=3c9c60893c3ef4225c63c82d4a7b9a37d34cb9ed;hpb=4dad2ddfc361c0f408b8e2320e7186f985f3bb2d;p=jalview.git diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index 3c9c608..c8d6975 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -1,10 +1,11 @@ package jalview.io; +import jalview.api.AlignExportSettingI; +import jalview.api.FeatureRenderer; +import jalview.datamodel.AlignmentExportData; import jalview.datamodel.SequenceI; import jalview.gui.AlignViewport; import jalview.gui.AlignmentPanel; -import jalview.gui.AnnotationPanel; -import jalview.gui.FeatureRenderer; import jalview.gui.HTMLOptions; import jalview.math.AlignmentDimension; import jalview.util.MessageManager; @@ -27,14 +28,12 @@ public class HtmlSvgOutput FeatureRenderer fr; AlignmentPanel ap; - AnnotationPanel annotationPanel; public HtmlSvgOutput(File file, AlignmentPanel ap) { - - this.av = ap.av; - this.ap = ap; - this.annotationPanel = ap.getAnnotationPanel(); + this.av = ap.av; + this.ap = ap; + fr = ap.cloneFeatureRenderer(); generateHtmlSvgOutput(file); } @@ -42,11 +41,7 @@ public class HtmlSvgOutput { try { - if (file == null /* - * && !(System.getProperty("java.awt.headless") != null - * && System - * .getProperty("java.awt.headless").equals("true")) - */) + if (file == null) { JalviewFileChooser chooser = getHTMLChooser(); @@ -96,12 +91,63 @@ public class HtmlSvgOutput } printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, g1, g2); - FileOutputStream out = new FileOutputStream(file); String titleSvgData = g1.getSVGDocument(); String alignSvgData = g2.getSVGDocument(); - String htmlData = getHtml(titleSvgData, alignSvgData); - + String jsonData = null; + boolean isEmbbedBioJSON = Boolean.valueOf(jalview.bin.Cache + .getDefault("EXPORT_EMBBED_BIOJSON", "true")); + if (isEmbbedBioJSON) + { + 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()); + } + String htmlData = getHtml(titleSvgData, alignSvgData, jsonData); + FileOutputStream out = new FileOutputStream(file); out.write(htmlData.getBytes()); out.flush(); out.close(); @@ -257,27 +303,56 @@ public class HtmlSvgOutput return Printable.PAGE_EXISTS; } - private String getHtml(String titleSvg, String alignmentSvg) + private String getHtml(String titleSvg, String alignmentSvg, + String jsonData) { StringBuilder htmlSvg = new StringBuilder(); - htmlSvg.append("" - + ""); - htmlSvg.append("
"); - htmlSvg.append( -"
"); - htmlSvg.append( -"
") - .append(titleSvg) - .append("
") - .append("
\n\n\n\n"); - htmlSvg.append( -"
"); + + "object {pointer-events: none;}"); + if (jsonData != null) + { + // facebox style sheet for displaying raw BioJSON data + htmlSvg.append("#facebox { position: absolute; top: 0; left: 0; z-index: 100; text-align: left; }\n" + + "#facebox .popup{ position:relative; border:3px solid rgba(0,0,0,0); -webkit-border-radius:5px;" + + "-moz-border-radius:5px; border-radius:5px; -webkit-box-shadow:0 0 18px rgba(0,0,0,0.4); -moz-box-shadow:0 0 18px rgba(0,0,0,0.4);" + + "box-shadow:0 0 18px rgba(0,0,0,0.4); }\n" + + "#facebox .content { display:table; width: 98%; padding: 10px; background: #fff; -webkit-border-radius:4px; -moz-border-radius:4px;" + + " border-radius:4px; }\n" + + "#facebox .content > p:first-child{ margin-top:0; }\n" + + "#facebox .content > p:last-child{ margin-bottom:0; }\n" + + "#facebox .close{ position:absolute; top:5px; right:5px; padding:2px; background:#fff; }\n" + + "#facebox .close img{ opacity:0.3; }\n" + + "#facebox .close:hover img{ opacity:1.0; }\n" + + "#facebox .loading { text-align: center; }\n" + + "#facebox .image { text-align: center;}\n" + + "#facebox img { border: 0; margin: 0; }\n" + + "#facebox_overlay { position: fixed; top: 0px; left: 0px; height:100%; width:100%; }\n" + + ".facebox_hide { z-index:-100; }\n" + + ".facebox_overlayBG { background-color: #000; z-index: 99; }"); + } + + htmlSvg.append(""); + htmlSvg.append("
"); + htmlSvg.append("
\n"); + htmlSvg.append("
\n"); + htmlSvg.append(titleSvg); + htmlSvg.append("
"); + htmlSvg.append("
\n\n\n\n"); + htmlSvg.append("
"); htmlSvg.append( "
") .append(alignmentSvg) @@ -286,14 +361,303 @@ public class HtmlSvgOutput htmlSvg.append("
"); htmlSvg.append("\n" - + "\n" + + "\n" + ""); + htmlSvg.append("\n"); + + // javascript for launching file in Jalview + + htmlSvg.append("\n"); + htmlSvg.append(""); return htmlSvg.toString(); } }