From 73d2eb017ebcaff4453d676c0d728f61015d102c Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 4 Sep 2015 17:24:16 +0100 Subject: [PATCH] JAL-793 added ability to visualise raw BioJSON in the exported HTML using facebox --- src/jalview/io/HtmlFile.java | 14 +- src/jalview/io/HtmlSvgOutput.java | 318 +++++++++++++++++++++++++++++++++++-- 2 files changed, 313 insertions(+), 19 deletions(-) diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java index 4805b8e..dc14cc0 100644 --- a/src/jalview/io/HtmlFile.java +++ b/src/jalview/io/HtmlFile.java @@ -87,13 +87,23 @@ public class HtmlFile extends AlignFile implements ComplexAlignFile try { - content = doc.getElementById("seqData"); + boolean contentFromDiv = true; + // search for BioJSON data in div element with id seqData + content = doc.select("div[id=seqData]").first(); + if (content == null) + { + contentFromDiv = false; + // search for BioJSON data in input element with id seqData + content = doc.getElementById("seqData"); + } + if (content == null) { errormessage = "The html document is not embedded with BioJSON data"; throw new IOException(errormessage); } - JSONFile jsonFile = new JSONFile().parse(new StringReader(content + JSONFile jsonFile = new JSONFile().parse(new StringReader( + contentFromDiv ? content.text() : content .val())); this.seqs = jsonFile.getSeqs(); this.seqGroups = jsonFile.getSeqGroups(); diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index 3a0f169..c8d6975 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -310,27 +310,49 @@ public class HtmlSvgOutput htmlSvg.append("\n"); if (jsonData != null) { - htmlSvg.append(""); - htmlSvg.append(""); + htmlSvg.append("  "); + htmlSvg.append(""); + htmlSvg.append("
" + + jsonData + "
"); + htmlSvg.append("
 "); } htmlSvg.append("\n"); - 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) @@ -339,7 +361,7 @@ public class HtmlSvgOutput htmlSvg.append("
"); htmlSvg.append("\n" - + "\n" + + "\n" + "\n"); htmlSvg.append(""); return htmlSvg.toString(); -- 1.7.10.2