House keeping
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 14 Nov 2014 14:43:56 +0000 (14:43 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 14 Nov 2014 14:43:56 +0000 (14:43 +0000)
18 files changed:
examples/example_biojs.html
resources/templates/BioJSTemplate.txt
src/jalview/exceptions/JalviewException.java [new file with mode: 0644]
src/jalview/exceptions/NoFileSelectedException.java [new file with mode: 0644]
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AnnotationExporter.java
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/Jalview2XML_V1.java
src/jalview/gui/SeqPanel.java
src/jalview/io/BioJsHTMLOutput.java
src/jalview/io/HtmlFile.java
src/jalview/io/IdentifyFile.java
src/jalview/json/binding/v1/BioJsAlignmentPojo.java
test/jalview/io/BioJsHTMLOutputTest.java [new file with mode: 0644]
test/jalview/io/HtmlFileTest.java [new file with mode: 0644]

index 5b0d71e..b6f7bec 100644 (file)
@@ -7,21 +7,21 @@
 <!-- <script src="https://s3-eu-west-1.amazonaws.com/biojs/msa/latest/msa.js"></script> -->
 <!-- <link type=text/css rel=stylesheet href=https://s3-eu-west-1.amazonaws.com/biojs/msa/latest/msa.css /> -->
  
- <img src="file:/Users/tcnofoegbu/Documents/workspace/java/dev/jalview/classes/images/Jalview_Logo.png" alt="Jalview Logo" title="This html page was generated from Jalview, to import the data back to Jalview, please drag the generated html file and drop it unto the Jalview workbench.
+ <img src="http://www.jalview.org/help/html/Jalview_Logo.png" alt="Jalview Logo" title="This html page was generated from Jalview, to import the data back to Jalview, please drag the generated html file and drop it unto the Jalview workbench.
  
  Alternatively, you could copy the url from the address bar and use Jalview's url importer (main menu-> File-> Input Alignment-> from URL) to import back the alignment jalview." >
 
 </br>
 </br>
 
-<button onclick="javascipt:openJalviewUsingCurrentUrl();">Launch in Jalview</button>
 <input type="button" name="divToggleButton" id="divToggleButton" onclick="javascipt:toggleMenuVisibility();" value="Show Menu"></input>
+<button onclick="javascipt:openJalviewUsingCurrentUrl();">Launch in Jalview</button>
 
 </br>
 </br> 
   
 <div id="yourDiv">press "Run with JS"</div>
-<input type='hidden' id='seqData' name='seqData' value='{"globalColorScheme":"zappo","seqs":[{"id":"1","start":1,"name":"FER_CAPAA/1-97","seq":"----------------------------------------------------------ASYKVKLITPDGPIEFDCPDDVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQLEEGWVLTCVAYPQSDVTIETHKEAELVG-","features":[],"end":97},{"id":"2","start":1,"name":"FER_CAPAN/1-144","seq":"------MASVSATMISTSFMPRKPAVTSLKPIP-NVG-EALFGLKS---ANGGKVTCMASYKVKLITPDGPIEFDCPDNVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQLEEGWVLTCVAYPQSDVTIETHKEAELVG-","features":[{"xEnd":22,"text":"feature_1","fillColor":"#8c25cd","xStart":2}],"end":144},{"id":"3","start":1,"name":"FER1_SOLLC/1-144","seq":"------MASISGTMISTSFLPRKPAVTSLKAIS-NVG-EALFGLKS---GRNGRITCMASYKVKLITPEGPIEFECPDDVYILDQAEEEGHDLPYSCRAGSCSSCAGKVTAGSVDQSDGNFLDEDQEAAGFVLTCVAYPKGDVTIETHKEEELTA-","features":[],"end":144},{"id":"4","start":1,"name":"Q93XJ9_SOLTU/1-144","seq":"------MASISGTMISTSFLPRKPVVTSLKAIS-NVG-EALFGLKS---GRNGRITCMASYKVKLITPDGPIEFECPDDVYILDQAEEEGHDLPYSCRAGSCSSCAGKVTAGTVDQSDGKFLDDDQEAAGFVLTCVAYPKCDVTIETHKEEELTA-","features":[],"end":144},{"id":"5","start":1,"name":"FER1_PEA/1-149","seq":"---MATTPALYGTAVSTSFLRTQPMPMSVTTTKAFSN--GFLGLKT-SLKRGDLAVAMASYKVKLVTPDGTQEFECPSDVYILDHAEEVGIDLPYSCRAGSCSSCAGKVVGGEVDQSDGSFLDDEQIEAGFVLTCVAYPTSDVVIETHKEEDLTA-","features":[],"end":149},{"id":"6","start":1,"name":"Q7XA98_TRIPR/1-152","seq":"---MATTPALYGTAVSTSFMRRQPVPMSVATTTTTKAFPSGFGLKSVSTKRGDLAVAMATYKVKLITPEGPQEFDCPDDVYILDHAEEVGIELPYSCRAGSCSSCAGKVVNGNVNQEDGSFLDDEQIEGGWVLTCVAFPTSDVTIETHKEEELTA-","features":[],"end":152},{"id":"7","start":1,"name":"FER1_MESCR/1-148","seq":"--MAATTAALSGATMSTAFAPKT--PPMTAALPTNVG-RALFGLKS--SASRGRVTAMAAYKVTLVTPEGKQELECPDDVYILDAAEEAGIDLPYSCRAGSCSSCAGKVTSGSVNQDDGSFLDDDQIKEGWVLTCVAYPTGDVTIETHKEEELTA-","features":[],"end":148},{"id":"8","start":1,"name":"FER1_SPIOL/1-147","seq":"----MAATTTTMMGMATTFVPKPQAPPMMAALPSNTG-RSLFGLKT--GSRGGRMT-MAAYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLDDDQIDEGWVLTCAAYPVSDVTIETHKEEELTA-","features":[],"end":147},{"id":"9","start":1,"name":"FER3_RAPSA/1-96","seq":"----------------------------------------------------------ATYKVKFITPEGEQEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSFLDDDQIAEGFVLTCAAYPTSDVTIETHREEDMV--","features":[],"end":96},{"id":"10","start":1,"name":"FER1_ARATH/1-148","seq":"----MASTALSSAIVGTSFIRRSPAPISLRSLPSANT-QSLFGLKS-GTARGGRVTAMATYKVKFITPEGELEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSFLDDEQIGEGFVLTCAAYPTSDVTIETHKEEDIV--","features":[],"end":148},{"id":"11","start":1,"name":"FER_BRANA/1-96","seq":"----------------------------------------------------------ATYKVKFITPEGEQEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGFVDQSDESFLDDDQIAEGFVLTCAAYPTSDVTIETHKEEELV--","features":[],"end":96},{"id":"12","start":1,"name":"FER2_ARATH/1-148","seq":"----MASTALSSAIVSTSFLRRQQTPISLRSLPFANT-QSLFGLKS-STARGGRVTAMATYKVKFITPEGEQEVECEEDVYVLDAAEEAGLDLPYSCRAGSCSSCAGKVVSGSIDQSDQSFLDDEQMSEGYVLTCVAYPTSDVVIETHKEEAIM--","features":[],"end":148},{"id":"13","start":1,"name":"Q93Z60_ARATH/1-118","seq":"----MASTALSSAIVSTSFLRRQQTPISLRSLPFANT-QSLFGLKS-STARGGRVTAMATYKVKFITPEGEQEVECEEDVYVLDAAEEAGLDLPYSCRAGSCSSCAGKVVSGSIDQSDQSFLDD--------------------------------","features":[],"end":118},{"id":"14","start":1,"name":"FER1_MAIZE/1-150","seq":"MATVLGSPRAPAFFFSSSSLRAAPAPTAVALPAAKVG---IMGRSA---SSRRRLRAQATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA","features":[],"end":150},{"id":"15","start":1,"name":"O80429_MAIZE/1-140","seq":"---------MAATALSMSILRAPP-PCFSSPLRLRVAVAKPLAAPM----RRQLLRAQATYNVKLITPEGEVELQVPDDVYILDFAEEEGIDLPFSCRAGSCSSCAGKVVSGSVDQSDQSFLNDNQVADGWVLTCAAYPTSDVVIETHKEDDLL--","features":[],"end":140}]}'/>
+<input type='hidden' id='seqData' name='seqData' value='{"globalColorScheme":"zappo","seqs":[{"id":"1","start":1,"name":"FER_CAPAA/1-97","seq":"----------------------------------------------------------ASYKVKLITPDGPIEFDCPDDVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQLEEGWVLTCVAYPQSDVTIETHKEAELVG-","features":[],"end":97},{"id":"2","start":1,"name":"FER_CAPAN/1-144","seq":"------MASVSATMISTSFMPRKPAVTSLKPIP-NVG-EALFGLKS---ANGGKVTCMASYKVKLITPDGPIEFDCPDNVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQTDGNFLDDDQLEEGWVLTCVAYPQSDVTIETHKEAELVG-","features":[{"text":"feature_1","xEnd":46,"fillColor":"#8c25cd","xStart":16}],"end":144},{"id":"3","start":1,"name":"FER1_SOLLC/1-144","seq":"------MASISGTMISTSFLPRKPAVTSLKAIS-NVG-EALFGLKS---GRNGRITCMASYKVKLITPEGPIEFECPDDVYILDQAEEEGHDLPYSCRAGSCSSCAGKVTAGSVDQSDGNFLDEDQEAAGFVLTCVAYPKGDVTIETHKEEELTA-","features":[],"end":144},{"id":"4","start":1,"name":"Q93XJ9_SOLTU/1-144","seq":"------MASISGTMISTSFLPRKPVVTSLKAIS-NVG-EALFGLKS---GRNGRITCMASYKVKLITPDGPIEFECPDDVYILDQAEEEGHDLPYSCRAGSCSSCAGKVTAGTVDQSDGKFLDDDQEAAGFVLTCVAYPKCDVTIETHKEEELTA-","features":[],"end":144},{"id":"5","start":1,"name":"FER1_PEA/1-149","seq":"---MATTPALYGTAVSTSFLRTQPMPMSVTTTKAFSN--GFLGLKT-SLKRGDLAVAMASYKVKLVTPDGTQEFECPSDVYILDHAEEVGIDLPYSCRAGSCSSCAGKVVGGEVDQSDGSFLDDEQIEAGFVLTCVAYPTSDVVIETHKEEDLTA-","features":[],"end":149},{"id":"6","start":1,"name":"Q7XA98_TRIPR/1-152","seq":"---MATTPALYGTAVSTSFMRRQPVPMSVATTTTTKAFPSGFGLKSVSTKRGDLAVAMATYKVKLITPEGPQEFDCPDDVYILDHAEEVGIELPYSCRAGSCSSCAGKVVNGNVNQEDGSFLDDEQIEGGWVLTCVAFPTSDVTIETHKEEELTA-","features":[{"text":"feature_2","xEnd":24,"fillColor":"#0000cc","xStart":8}],"end":152},{"id":"7","start":1,"name":"FER1_MESCR/1-148","seq":"--MAATTAALSGATMSTAFAPKT--PPMTAALPTNVG-RALFGLKS--SASRGRVTAMAAYKVTLVTPEGKQELECPDDVYILDAAEEAGIDLPYSCRAGSCSSCAGKVTSGSVNQDDGSFLDDDQIKEGWVLTCVAYPTGDVTIETHKEEELTA-","features":[],"end":148},{"id":"8","start":1,"name":"FER1_SPIOL/1-147","seq":"----MAATTTTMMGMATTFVPKPQAPPMMAALPSNTG-RSLFGLKT--GSRGGRMT-MAAYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLDDDQIDEGWVLTCAAYPVSDVTIETHKEEELTA-","features":[],"end":147},{"id":"9","start":1,"name":"FER3_RAPSA/1-96","seq":"----------------------------------------------------------ATYKVKFITPEGEQEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSFLDDDQIAEGFVLTCAAYPTSDVTIETHREEDMV--","features":[],"end":96},{"id":"10","start":1,"name":"FER1_ARATH/1-148","seq":"----MASTALSSAIVGTSFIRRSPAPISLRSLPSANT-QSLFGLKS-GTARGGRVTAMATYKVKFITPEGELEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSFLDDEQIGEGFVLTCAAYPTSDVTIETHKEEDIV--","features":[],"end":148},{"id":"11","start":1,"name":"FER_BRANA/1-96","seq":"----------------------------------------------------------ATYKVKFITPEGEQEVECDDDVYVLDAAEEAGIDLPYSCRAGSCSSCAGKVVSGFVDQSDESFLDDDQIAEGFVLTCAAYPTSDVTIETHKEEELV--","features":[],"end":96},{"id":"12","start":1,"name":"FER2_ARATH/1-148","seq":"----MASTALSSAIVSTSFLRRQQTPISLRSLPFANT-QSLFGLKS-STARGGRVTAMATYKVKFITPEGEQEVECEEDVYVLDAAEEAGLDLPYSCRAGSCSSCAGKVVSGSIDQSDQSFLDDEQMSEGYVLTCVAYPTSDVVIETHKEEAIM--","features":[{"text":"feature_3","xEnd":32,"fillColor":"#ffff00","xStart":4}],"end":148},{"id":"13","start":1,"name":"Q93Z60_ARATH/1-118","seq":"----MASTALSSAIVSTSFLRRQQTPISLRSLPFANT-QSLFGLKS-STARGGRVTAMATYKVKFITPEGEQEVECEEDVYVLDAAEEAGLDLPYSCRAGSCSSCAGKVVSGSIDQSDQSFLDD--------------------------------","features":[],"end":118},{"id":"14","start":1,"name":"FER1_MAIZE/1-150","seq":"MATVLGSPRAPAFFFSSSSLRAAPAPTAVALPAAKVG---IMGRSA---SSRRRLRAQATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA","features":[],"end":150},{"id":"15","start":1,"name":"O80429_MAIZE/1-140","seq":"---------MAATALSMSILRAPP-PCFSSPLRLRVAVAKPLAAPM----RRQLLRAQATYNVKLITPEGEVELQVPDDVYILDFAEEEGIDLPFSCRAGSCSSCAGKVVSGSVDQSDQSFLNDNQVADGWVLTCAAYPTSDVVIETHKEDDLL--","features":[],"end":140}],"webStartUrl":"http://www.jalview.org/services/launchApp","jalviewVersion":"Test"}'/>
 
 </body>
 </html>
@@ -31,8 +31,6 @@
 <script>
 
 function toggleMenuVisibility(){
-       //alert("toggleMenuVisibility called!");
-       
        var menu = document.getElementsByClassName("biojs_msa_menubar");
        var divToggleButton = document.getElementById("divToggleButton");
        if(menu[0].style.display == 'block'){
@@ -43,54 +41,30 @@ function toggleMenuVisibility(){
           divToggleButton.value="Hide Menu";
           }
 }
-function openJalviewUsingCurrentUrl2(){
-var jnpl = "<!--"+
-"Hi!"+
-"If you have downloaded this file after pressing \"Launch Full Application\" from Jalview on a web page and you don't know what to do with this file, you must install Java from http://www.java.sun.com then try opening this file again."+
-" \n"+
-"      JNLP generated by /jalviewServlet/services/launchAppDev"+
-"      JNLP generated from http://www.jalview.org/builds/develop/webstart/jalview.jnlp"+
-"Available servlet parameters (please URLEncode):"+
-"      open=<alignment file URL>"+
-"      jvm-max-heap=heap size in M or G"+
-"      features maps to        '-features'"+
-"      treeFile maps to        '-tree'"+
-"      tree maps to    '-tree'"+
-"      annotations maps to     '-annotations'"+
-"      colour maps to  '-colour'"+
-" "+
-"-->"+
-"<?xml version=\"1.0\" encoding=\"UTF-8\"?><jnlp spec=\"1.0+\" codebase=\"http://www.jalview.org/builds/develop/webstart\">    <information>           <title>Jalview</title>          <vendor>The Barton Group</vendor>               <homepage href=\"http://www.jalview.org\"/>             <description>Jalview Multiple Alignment Editor</description>            <description kind=\"short\">Jalview</description>               <icon href=\"JalviewLogo_big.png\"/>            <offline-allowed/>      </information>  <security>              <all-permissions/>      </security>     <resources>             <j2se version=\"1.7+\" initial-heap-size=\"10M\" max-heap-size=\"2G\"/>         <jar href=\"jalview.jar\"/>             <jar href=\"JGoogleAnalytics_0.3.jar\"/>                <jar href=\"Jmol-12.2.4.jar\"/>         <jar href=\"VARNAv3-91.jar\"/>          <jar href=\"activation.jar\"/>          <jar href=\"apache-mime4j-0.6.jar\"/>           <jar href=\"axis.jar\"/>                <jar href=\"castor-1.1-cycle-xml.jar\"/>                <jar href=\"commons-codec-1.3.jar\"/>           <jar href=\"commons-discovery.jar\"/>           <jar href=\"commons-logging-1.1.1.jar\"/>               <jar href=\"groovy-all-1.8.2.jar\"/>            <jar href=\"httpclient-4.0.3.jar\"/>            <jar href=\"httpcore-4.0.1.jar\"/>              <jar href=\"httpmime-4.0.3.jar\"/>              <jar href=\"jalview_jnlp_vm.jar\"/>             <jar href=\"jaxrpc.jar\"/>              <jar href=\"jdas-1.0.4.jar\"/>          <jar href=\"jhall.jar\"/>               <jar href=\"json_simple-1.1.jar\"/>             <jar href=\"jsoup-1.8.1.jar\"/>         <jar href=\"jswingreader-0.3.jar\"/>            <jar href=\"log4j-to-slf4j-2.0-rc2.jar\"/>              <jar href=\"mail.jar\"/>                <jar href=\"miglayout-4.0-swing.jar\"/>         <jar href=\"min-jabaws-client-2.1.0.jar\"/>             <jar href=\"regex.jar\"/>               <jar href=\"saaj.jar\"/>                <jar href=\"slf4j-api-1.7.7.jar\"/>             <jar href=\"slf4j-log4j12-1.7.7.jar\"/>         <jar href=\"spring-core-3.0.5.RELEASE.jar\"/>           <jar href=\"spring-web-3.0.5.RELEASE.jar\"/>            <jar href=\"vamsas-client.jar\"/>               <jar href=\"wsdl4j.jar\"/>              <jar href=\"xercesImpl.jar\"/>          <jar href=\"xml-apis.jar\"/>            <property name=\"jalview.version\" value=\"Development Branch Build\"/> </resources>"+
-"<application-desc main-class=\"jalview.bin.Jalview\">"+
-"<argument>-open</argument>"+
-"<argument>file:///Users/tcnofoegbu/Documents/workspace/java/dev/jalview/examples/example_biojs.html</argument>"+
-"</application-desc>"+
-"      <security>"+
-"              <all-permissions/>"+
-"      </security>"+
-"</jnlp>"
-
-var encodedUri = encodeURI(jnpl);
-window.open(encodedUri)
-//alert(jnpl)
-}
+
 
 function openJalviewUsingCurrentUrl(){
-       var url = "http://webservices.compbio.dundee.ac.uk:38080/jalviewServlet/services/launchAppDev";
+       var jalviewData = JSON.parse(document.getElementById("seqData").value)
+    var jalviewVersion = jalviewData['jalviewVersion'];
+    var url = jalviewData['webStartUrl'];
        var myForm = document.createElement("form");
        myForm.action = url;
        
-    var myInput = document.createElement("input") ;
-    myInput.setAttribute("name", "jvm-max-heap") ;
-    myInput.setAttribute("value", "2G");
-    myForm.appendChild(myInput) ;
+    var heap = document.createElement("input") ;
+    heap.setAttribute("name", "jvm-max-heap") ;
+    heap.setAttribute("value", "2G");
+    myForm.appendChild(heap) ;
     
-    var myInput1 = document.createElement("input") ;
-    myInput1.setAttribute("name", "open") ;
-    myInput1.setAttribute("value", document.URL);
-    myForm.appendChild(myInput1) ;
+    var target = document.createElement("input") ;
+    target.setAttribute("name", "open") ;
+    target.setAttribute("value", document.URL);
+    myForm.appendChild(target) ;
+    
+    var jvVersion = document.createElement("input") ;
+    jvVersion.setAttribute("name", "version") ;
+    jvVersion.setAttribute("value", jalviewVersion);
+    myForm.appendChild(jvVersion) ;
     
-
        document.body.appendChild(myForm) ;
        myForm.submit() ;
        document.body.removeChild(myForm) ;
@@ -9051,7 +9025,6 @@ m.addView("menu", defMenu);
 
 // call render at the end to display the whole MSA
 m.render();
 toggleMenuVisibility(); 
 toggleMenuVisibility(); 
 });
index d86fa65..74990ad 100644 (file)
@@ -7,15 +7,15 @@
 <!-- <script src="https://s3-eu-west-1.amazonaws.com/biojs/msa/latest/msa.js"></script> -->
 <!-- <link type=text/css rel=stylesheet href=https://s3-eu-west-1.amazonaws.com/biojs/msa/latest/msa.css /> -->
  
- <img src="#jalview_logo#" alt="Jalview Logo" title="This html page was generated from Jalview, to import the data back to Jalview, please drag the generated html file and drop it unto the Jalview workbench.
+ <img src="http://www.jalview.org/help/html/Jalview_Logo.png" alt="Jalview Logo" title="This html page was generated from Jalview, to import the data back to Jalview, please drag the generated html file and drop it unto the Jalview workbench.
  
  Alternatively, you could copy the url from the address bar and use Jalview's url importer (main menu-> File-> Input Alignment-> from URL) to import back the alignment jalview." >
 
 </br>
 </br>
 
-<button onclick="javascipt:openJalviewUsingCurrentUrl();">Launch in Jalview</button>
 <input type="button" name="divToggleButton" id="divToggleButton" onclick="javascipt:toggleMenuVisibility();" value="Show Menu"></input>
+<button onclick="javascipt:openJalviewUsingCurrentUrl();">Launch in Jalview</button>
 
 </br>
 </br> 
@@ -31,8 +31,6 @@
 <script>
 
 function toggleMenuVisibility(){
-       //alert("toggleMenuVisibility called!");
-       
        var menu = document.getElementsByClassName("biojs_msa_menubar");
        var divToggleButton = document.getElementById("divToggleButton");
        if(menu[0].style.display == 'block'){
@@ -43,54 +41,30 @@ function toggleMenuVisibility(){
           divToggleButton.value="Hide Menu";
           }
 }
-function openJalviewUsingCurrentUrl2(){
-var jnpl = "<!--"+
-"Hi!"+
-"If you have downloaded this file after pressing \"Launch Full Application\" from Jalview on a web page and you don't know what to do with this file, you must install Java from http://www.java.sun.com then try opening this file again."+
-" \n"+
-"      JNLP generated by /jalviewServlet/services/launchAppDev"+
-"      JNLP generated from http://www.jalview.org/builds/develop/webstart/jalview.jnlp"+
-"Available servlet parameters (please URLEncode):"+
-"      open=<alignment file URL>"+
-"      jvm-max-heap=heap size in M or G"+
-"      features maps to        '-features'"+
-"      treeFile maps to        '-tree'"+
-"      tree maps to    '-tree'"+
-"      annotations maps to     '-annotations'"+
-"      colour maps to  '-colour'"+
-" "+
-"-->"+
-"<?xml version=\"1.0\" encoding=\"UTF-8\"?><jnlp spec=\"1.0+\" codebase=\"http://www.jalview.org/builds/develop/webstart\">    <information>           <title>Jalview</title>          <vendor>The Barton Group</vendor>               <homepage href=\"http://www.jalview.org\"/>             <description>Jalview Multiple Alignment Editor</description>            <description kind=\"short\">Jalview</description>               <icon href=\"JalviewLogo_big.png\"/>            <offline-allowed/>      </information>  <security>              <all-permissions/>      </security>     <resources>             <j2se version=\"1.7+\" initial-heap-size=\"10M\" max-heap-size=\"2G\"/>         <jar href=\"jalview.jar\"/>             <jar href=\"JGoogleAnalytics_0.3.jar\"/>                <jar href=\"Jmol-12.2.4.jar\"/>         <jar href=\"VARNAv3-91.jar\"/>          <jar href=\"activation.jar\"/>          <jar href=\"apache-mime4j-0.6.jar\"/>           <jar href=\"axis.jar\"/>                <jar href=\"castor-1.1-cycle-xml.jar\"/>                <jar href=\"commons-codec-1.3.jar\"/>           <jar href=\"commons-discovery.jar\"/>           <jar href=\"commons-logging-1.1.1.jar\"/>               <jar href=\"groovy-all-1.8.2.jar\"/>            <jar href=\"httpclient-4.0.3.jar\"/>            <jar href=\"httpcore-4.0.1.jar\"/>              <jar href=\"httpmime-4.0.3.jar\"/>              <jar href=\"jalview_jnlp_vm.jar\"/>             <jar href=\"jaxrpc.jar\"/>              <jar href=\"jdas-1.0.4.jar\"/>          <jar href=\"jhall.jar\"/>               <jar href=\"json_simple-1.1.jar\"/>             <jar href=\"jsoup-1.8.1.jar\"/>         <jar href=\"jswingreader-0.3.jar\"/>            <jar href=\"log4j-to-slf4j-2.0-rc2.jar\"/>              <jar href=\"mail.jar\"/>                <jar href=\"miglayout-4.0-swing.jar\"/>         <jar href=\"min-jabaws-client-2.1.0.jar\"/>             <jar href=\"regex.jar\"/>               <jar href=\"saaj.jar\"/>                <jar href=\"slf4j-api-1.7.7.jar\"/>             <jar href=\"slf4j-log4j12-1.7.7.jar\"/>         <jar href=\"spring-core-3.0.5.RELEASE.jar\"/>           <jar href=\"spring-web-3.0.5.RELEASE.jar\"/>            <jar href=\"vamsas-client.jar\"/>               <jar href=\"wsdl4j.jar\"/>              <jar href=\"xercesImpl.jar\"/>          <jar href=\"xml-apis.jar\"/>            <property name=\"jalview.version\" value=\"Development Branch Build\"/> </resources>"+
-"<application-desc main-class=\"jalview.bin.Jalview\">"+
-"<argument>-open</argument>"+
-"<argument>file:///Users/tcnofoegbu/Documents/workspace/java/dev/jalview/examples/example_biojs.html</argument>"+
-"</application-desc>"+
-"      <security>"+
-"              <all-permissions/>"+
-"      </security>"+
-"</jnlp>"
-
-var encodedUri = encodeURI(jnpl);
-window.open(encodedUri)
-//alert(jnpl)
-}
+
 
 function openJalviewUsingCurrentUrl(){
-       var url = "http://webservices.compbio.dundee.ac.uk:38080/jalviewServlet/services/launchAppDev";
+       var jalviewData = JSON.parse(document.getElementById("seqData").value)
+    var jalviewVersion = jalviewData['jalviewVersion'];
+    var url = jalviewData['webStartUrl'];
        var myForm = document.createElement("form");
        myForm.action = url;
        
-    var myInput = document.createElement("input") ;
-    myInput.setAttribute("name", "jvm-max-heap") ;
-    myInput.setAttribute("value", "2G");
-    myForm.appendChild(myInput) ;
+    var heap = document.createElement("input") ;
+    heap.setAttribute("name", "jvm-max-heap") ;
+    heap.setAttribute("value", "2G");
+    myForm.appendChild(heap) ;
     
-    var myInput1 = document.createElement("input") ;
-    myInput1.setAttribute("name", "open") ;
-    myInput1.setAttribute("value", document.URL);
-    myForm.appendChild(myInput1) ;
+    var target = document.createElement("input") ;
+    target.setAttribute("name", "open") ;
+    target.setAttribute("value", document.URL);
+    myForm.appendChild(target) ;
+    
+    var jvVersion = document.createElement("input") ;
+    jvVersion.setAttribute("name", "version") ;
+    jvVersion.setAttribute("value", jalviewVersion);
+    myForm.appendChild(jvVersion) ;
     
-
        document.body.appendChild(myForm) ;
        myForm.submit() ;
        document.body.removeChild(myForm) ;
@@ -9051,7 +9025,6 @@ m.addView("menu", defMenu);
 
 // call render at the end to display the whole MSA
 m.render();
 toggleMenuVisibility(); 
 toggleMenuVisibility(); 
 });
diff --git a/src/jalview/exceptions/JalviewException.java b/src/jalview/exceptions/JalviewException.java
new file mode 100644 (file)
index 0000000..80e0b08
--- /dev/null
@@ -0,0 +1,25 @@
+package jalview.exceptions;
+
+@SuppressWarnings("serial")
+public class JalviewException extends Exception
+{
+  public JalviewException(String exceptionMessage)
+  {
+    super(exceptionMessage);
+  }
+
+  public JalviewException()
+  {
+    super();
+  }
+
+  public JalviewException(String exceptionMessage, Throwable cause)
+  {
+    super(exceptionMessage, cause);
+  }
+
+  public JalviewException(Throwable cause)
+  {
+    super(cause);
+  }
+}
diff --git a/src/jalview/exceptions/NoFileSelectedException.java b/src/jalview/exceptions/NoFileSelectedException.java
new file mode 100644 (file)
index 0000000..5c56f47
--- /dev/null
@@ -0,0 +1,10 @@
+package jalview.exceptions;
+
+@SuppressWarnings("serial")
+public class NoFileSelectedException extends JalviewException
+{
+  public NoFileSelectedException(String msg)
+  {
+    super(msg);
+  }
+}
index d4270f9..11d4e7a 100644 (file)
@@ -1234,7 +1234,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   public void bioJSMenuItem_actionPerformed(ActionEvent e)
   {
     new BioJsHTMLOutput(alignPanel,
-            alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
             alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
   }
   public void createImageMap(File file, String image)
index 6d6531f..1a328f9 100644 (file)
@@ -127,7 +127,7 @@ public class AlignViewport extends AlignmentViewport implements
    * Keys are the feature types which are currently visible. Note: Values are
    * not used!
    */
-  Hashtable featuresDisplayed = null;
+  private Hashtable featuresDisplayed = null;
 
   boolean antiAlias = false;
 
@@ -1264,4 +1264,14 @@ public class AlignViewport extends AlignmentViewport implements
       Cache.log.debug("trigger update for " + calcId);
     }
   }
+
+  public Hashtable getFeaturesDisplayed()
+  {
+    return featuresDisplayed;
+  }
+
+  public void setFeaturesDisplayed(Hashtable featuresDisplayed)
+  {
+    this.featuresDisplayed = featuresDisplayed;
+  }
 }
index 315c3e2..ecf4b8e 100644 (file)
@@ -210,11 +210,11 @@ public class AnnotationExporter extends JPanel
   private Hashtable getDisplayedFeatureCols()
   {
     Hashtable fcols = new Hashtable();
-    if (ap.av.featuresDisplayed == null)
+    if (ap.av.getFeaturesDisplayed() == null)
     {
       return fcols;
     }
-    Enumeration en = ap.av.featuresDisplayed.keys();
+    Enumeration en = ap.av.getFeaturesDisplayed().keys();
     FeatureRenderer fr = ap.seqPanel.seqCanvas.getFeatureRenderer(); // consider
                                                                      // higher
                                                                      // level
index d2d9c9c..fe083b0 100644 (file)
@@ -192,20 +192,20 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
       // copy over the displayed feature settings
       if (fr.av != null)
       {
-        if (fr.av.featuresDisplayed != null)
+        if (fr.av.getFeaturesDisplayed() != null)
         {
           // update display settings
-          if (av.featuresDisplayed == null)
+          if (av.getFeaturesDisplayed() == null)
           {
-            av.featuresDisplayed = new Hashtable(fr.av.featuresDisplayed);
+            av.setFeaturesDisplayed(new Hashtable(fr.av.getFeaturesDisplayed()));
           }
           else
           {
-            av.featuresDisplayed.clear();
-            Enumeration en = fr.av.featuresDisplayed.keys();
+            av.getFeaturesDisplayed().clear();
+            Enumeration en = fr.av.getFeaturesDisplayed().keys();
             while (en.hasMoreElements())
             {
-              av.featuresDisplayed.put(en.nextElement(), Boolean.TRUE);
+              av.getFeaturesDisplayed().put(en.nextElement(), Boolean.TRUE);
             }
 
           }
@@ -349,11 +349,11 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
       fm = g.getFontMetrics();
     }
 
-    if (av.featuresDisplayed == null || renderOrder == null
+    if (av.getFeaturesDisplayed() == null || renderOrder == null
             || newFeatureAdded)
     {
       findAllFeatures();
-      if (av.featuresDisplayed.size() < 1)
+      if (av.getFeaturesDisplayed().size() < 1)
       {
         return;
       }
@@ -388,7 +388,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     {
       type = renderOrder[renderIndex];
 
-      if (type == null || !av.featuresDisplayed.containsKey(type))
+      if (type == null || !av.getFeaturesDisplayed().containsKey(type))
       {
         continue;
       }
@@ -682,9 +682,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
 
     findingFeatures = true;
 
-    if (av.featuresDisplayed == null)
+    if (av.getFeaturesDisplayed() == null)
     {
-      av.featuresDisplayed = new Hashtable();
+      av.setFeaturesDisplayed(new Hashtable());
     }
 
     allfeatures = new Vector();
@@ -717,7 +717,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
       int index = 0;
       while (index < features.length)
       {
-        if (!av.featuresDisplayed.containsKey(features[index].getType()))
+        if (!av.getFeaturesDisplayed().containsKey(features[index].getType()))
         {
 
           if (featureGroups.containsKey(features[index].getType()))
@@ -742,7 +742,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
             {
               // this is a new feature type on the alignment. Mark it for
               // display.
-              av.featuresDisplayed.put(features[index].getType(),
+              av.getFeaturesDisplayed().put(features[index].getType(),
                       new Integer(getColour(features[index].getType())
                               .getRGB()));
               setOrder(features[index].getType(), 0);
@@ -1253,7 +1253,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
         sf.description = lastDescriptionAdded;
 
         setColour(sf.type, fcol);
-        av.featuresDisplayed.put(sf.type, getColour(sf.type));
+        av.getFeaturesDisplayed().put(sf.type, getColour(sf.type));
 
         try
         {
@@ -1281,9 +1281,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
           ffile.parseDescriptionHTML(features[i], false);
         }
 
-        if (av.featuresDisplayed == null)
+        if (av.getFeaturesDisplayed() == null)
         {
-          av.featuresDisplayed = new Hashtable();
+          av.setFeaturesDisplayed(new Hashtable());
         }
 
         if (lastFeatureGroupAdded != null)
@@ -1293,7 +1293,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
           featureGroups.put(lastFeatureGroupAdded, new Boolean(true));
         }
         setColour(lastFeatureAdded, fcol);
-        av.featuresDisplayed.put(lastFeatureAdded,
+        av.getFeaturesDisplayed().put(lastFeatureAdded,
                 getColour(lastFeatureAdded));
 
         findAllFeatures(false);
@@ -1386,13 +1386,13 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
   {
     if (visibleNew)
     {
-      if (av.featuresDisplayed != null)
+      if (av.getFeaturesDisplayed() != null)
       {
-        av.featuresDisplayed.clear();
+        av.getFeaturesDisplayed().clear();
       }
       else
       {
-        av.featuresDisplayed = new Hashtable();
+        av.setFeaturesDisplayed(new Hashtable());
       }
     }
     if (data == null)
@@ -1414,7 +1414,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
         // interface object
         if (((Boolean) data[i][2]).booleanValue())
         {
-          av.featuresDisplayed.put(type, new Integer(getColour(type)
+          av.getFeaturesDisplayed().put(type, new Integer(getColour(type)
                   .getRGB()));
         }
 
index 693e6fe..2190858 100644 (file)
@@ -208,7 +208,7 @@ public class FeatureSettings extends JPanel
     dassourceBrowser = new DasSourceBrowser(this);
     dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER);
 
-    if (af.getViewport().featuresDisplayed == null
+    if (af.getViewport().getFeaturesDisplayed() == null
             || fr.renderOrder == null)
     {
       fr.findAllFeatures(true); // display everything!
@@ -627,7 +627,7 @@ public class FeatureSettings extends JPanel
         data[dataIndex][0] = type;
         data[dataIndex][1] = fr.getFeatureStyle(type);
         data[dataIndex][2] = new Boolean(
-                af.getViewport().featuresDisplayed.containsKey(type));
+                af.getViewport().getFeaturesDisplayed().containsKey(type));
         dataIndex++;
         visibleChecks.removeElement(type);
       }
@@ -1223,7 +1223,7 @@ public class FeatureSettings extends JPanel
         System.arraycopy(fr.renderOrder, 0, typ, 0, typ.length);
         for (int i = 0; i < typ.length; i++)
         {
-          if (af.viewport.featuresDisplayed.get(typ[i]) == null)
+          if (af.viewport.getFeaturesDisplayed().get(typ[i]) == null)
           {
             typ[i] = null;
           }
index b608b95..158ae50 100644 (file)
@@ -1145,7 +1145,7 @@ public class Jalview2XML
       view.setFollowHighlight(av.followHighlight);
       view.setFollowSelection(av.followSelection);
       view.setIgnoreGapsinConsensus(av.getIgnoreGapsConsensus());
-      if (av.featuresDisplayed != null)
+      if (av.getFeaturesDisplayed() != null)
       {
         jalview.schemabinding.version2.FeatureSettings fs = new jalview.schemabinding.version2.FeatureSettings();
 
@@ -1180,7 +1180,7 @@ public class Jalview2XML
                       .getColour(renderOrder[ro]).getRGB());
             }
 
-            setting.setDisplay(av.featuresDisplayed
+            setting.setDisplay(av.getFeaturesDisplayed()
                     .containsKey(renderOrder[ro]));
             float rorder = ap.seqPanel.seqCanvas.getFeatureRenderer()
                     .getOrder(renderOrder[ro]);
@@ -3604,7 +3604,7 @@ public class Jalview2XML
     // recover featre settings
     if (jms.getFeatureSettings() != null)
     {
-      af.viewport.featuresDisplayed = new Hashtable();
+      af.viewport.setFeaturesDisplayed(new Hashtable());
       String[] renderOrder = new String[jms.getFeatureSettings()
               .getSettingCount()];
       for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++)
@@ -3656,7 +3656,7 @@ public class Jalview2XML
         }
         if (setting.getDisplay())
         {
-          af.viewport.featuresDisplayed.put(setting.getType(), new Integer(
+          af.viewport.getFeaturesDisplayed().put(setting.getType(), new Integer(
                   setting.getColour()));
         }
       }
index 9263cd9..3773a64 100755 (executable)
@@ -415,7 +415,7 @@ public class Jalview2XML_V1
 
     if (jms.getFeatureSettings() != null)
     {
-      af.viewport.featuresDisplayed = new Hashtable();
+      af.viewport.setFeaturesDisplayed(new Hashtable());
       String[] renderOrder = new String[jms.getFeatureSettings()
               .getSettingCount()];
       for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++)
@@ -429,7 +429,7 @@ public class Jalview2XML_V1
 
         if (setting.getDisplay())
         {
-          af.viewport.featuresDisplayed.put(setting.getType(), new Integer(
+          af.viewport.getFeaturesDisplayed().put(setting.getType(), new Integer(
                   setting.getColour()));
         }
       }
index 02c6c16..6a9c8ee 100644 (file)
  */
 package jalview.gui;
 
-import java.util.*;
-import java.util.List;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import jalview.commands.*;
-import jalview.datamodel.*;
+import jalview.commands.EditCommand;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
 import jalview.io.SequenceAnnotationReport;
-import jalview.schemes.*;
-import jalview.structure.*;
+import jalview.schemes.ResidueProperties;
+import jalview.structure.SelectionListener;
+import jalview.structure.SelectionSource;
+import jalview.structure.SequenceListener;
+import jalview.structure.StructureSelectionManager;
 import jalview.util.MessageManager;
 
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.ToolTipManager;
+
 /**
  * DOCUMENT ME!
  * 
@@ -233,8 +250,9 @@ public class SeqPanel extends JPanel implements MouseListener,
     {
       for (int i = 0; i < features.length; i++)
       {
-        if (av.featuresDisplayed == null
-                || !av.featuresDisplayed.containsKey(features[i].getType()))
+        if (av.getFeaturesDisplayed() == null
+                || !av.getFeaturesDisplayed().containsKey(
+                        features[i].getType()))
         {
           continue;
         }
@@ -245,7 +263,9 @@ public class SeqPanel extends JPanel implements MouseListener,
                         .containsKey(features[i].featureGroup)
                 && !((Boolean) seqCanvas.fr.featureGroups
                         .get(features[i].featureGroup)).booleanValue())
+        {
           continue;
+        }
 
         if ((features[i].getBegin() <= res)
                 && (features[i].getEnd() >= res))
@@ -695,7 +715,9 @@ public class SeqPanel extends JPanel implements MouseListener,
 
     pos = setStatusMessage(sequence, res, seq);
     if (ssm != null && pos > -1)
+    {
       mouseOverSequence(sequence, res, pos);
+    }
 
     tooltipText.setLength(6); // Cuts the buffer back to <html>
 
index 068b4b2..772337a 100644 (file)
@@ -3,10 +3,10 @@ package jalview.io;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
+import jalview.exceptions.NoFileSelectedException;
 import jalview.gui.AlignViewport;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.FeatureRenderer;
-import jalview.gui.SequenceRenderer;
 import jalview.json.binding.v1.BioJsAlignmentPojo;
 import jalview.json.binding.v1.BioJsFeaturePojo;
 import jalview.json.binding.v1.BioJsSeqPojo;
@@ -19,6 +19,7 @@ import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Hashtable;
 
 import com.json.JSONException;
 
@@ -28,76 +29,109 @@ public class BioJsHTMLOutput
 
   private FeatureRenderer fr;
 
-  public BioJsHTMLOutput(AlignmentPanel ap, SequenceRenderer sr,
+  private String globalColorScheme;
+
+  private Hashtable displayedFeatures;
+
+  private String jalviewVersion;
+
+  private String webStartLaunchServletUrl = "http://www.jalview.org/services/launchApp";
+
+  public BioJsHTMLOutput(AlignmentPanel ap,
           FeatureRenderer fr1)
   {
-    this.av = ap.av;
-    this.fr = new FeatureRenderer(ap);
+
+    jalviewVersion = jalview.bin.Cache.getProperty("VERSION");
+    webStartLaunchServletUrl = jalview.bin.Cache.getDefault(
+            "www.jalview.org", "http://www.jalview.org")
+            + "/services/launchApp";
+    if (ap != null)
+    {
+      this.av = ap.av;
+      this.globalColorScheme = ColourSchemeProperty.getColourName(av
+              .getGlobalColourScheme());
+      this.fr = new FeatureRenderer(ap);
     fr.transferSettings(fr1);
+      displayedFeatures = av.getFeaturesDisplayed();
 
-    exportAsBioJsHtml();
+    exportJalviewAlignmentAsBioJsHtmlFile();
+  }
   }
 
-  private void exportAsBioJsHtml()
+  private void exportJalviewAlignmentAsBioJsHtmlFile()
   {
     try
     {
-      JalviewFileChooser jvFileChooser = getJalviewFileChooserOption();
-      int fileChooserOpt = jvFileChooser.showSaveDialog(null);
-      if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION)
-      {
-        jalview.bin.Cache.setProperty("LAST_DIRECTORY", jvFileChooser
-                .getSelectedFile().getParent());
-        String selectedFile = jvFileChooser.getSelectedFile().getPath();
-        String generartedBioJs = generateBioJsAlignmentData(av
-                .getAlignment());
-        PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
-                selectedFile));
-        out.print(generartedBioJs);
-        out.close();
-        jalview.util.BrowserLauncher.openURL("file:///" + selectedFile);
-      }
-    } catch (Exception ex)
+      String outputFile = getOutputFile();
+      String jalviewAlignmentJson = getJalviewAlignmentAsJsonString(av
+              .getAlignment());
+      String bioJSTemplateString = getBioJsTemplateAsString(this);
+      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)
     {
-      ex.printStackTrace();
+      e.printStackTrace();
     }
   }
 
-  private JalviewFileChooser getJalviewFileChooserOption()
+  public String getOutputFile() throws NoFileSelectedException
   {
-    JalviewFileChooser chooser = new JalviewFileChooser(
+    String selectedFile = null;
+    JalviewFileChooser jvFileChooser = new JalviewFileChooser(
             jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
             { "html" }, new String[]
             { "HTML files" }, "HTML files");
-    chooser.setFileView(new JalviewFileView());
+    jvFileChooser.setFileView(new JalviewFileView());
 
     // TODO uncomment when supported by MassageManager
-    chooser.setDialogTitle(MessageManager
+    jvFileChooser.setDialogTitle(MessageManager
             .getString("label.save_as_biojs_html"));
-    chooser.setDialogTitle("save as BioJs HTML");
-    chooser.setToolTipText(MessageManager.getString("action.save"));
+    jvFileChooser.setDialogTitle("save as BioJs HTML");
+    jvFileChooser.setToolTipText(MessageManager.getString("action.save"));
+
+    int fileChooserOpt = jvFileChooser.showSaveDialog(null);
+    if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION)
+    {
+      jalview.bin.Cache.setProperty("LAST_DIRECTORY", jvFileChooser
+              .getSelectedFile().getParent());
+      selectedFile = jvFileChooser.getSelectedFile().getPath();
+    }
+    else
+    {
+      throw new NoFileSelectedException("No file was selected.");
+    }
 
-    return chooser;
+    return selectedFile;
   }
 
-  private String generateBioJsAlignmentData(AlignmentI alignment)
+  public String getJalviewAlignmentAsJsonString(AlignmentI alignment)
           throws IOException, JSONException
   {
     BioJsAlignmentPojo bjsAlignment = new BioJsAlignmentPojo();
-    bjsAlignment.setGlobalColorScheme(ColourSchemeProperty.getColourName(av
-            .getGlobalColourScheme()));
 
-    // av.setGlobalColourScheme(cs);
+    bjsAlignment.setGlobalColorScheme(getGlobalColorScheme());
+    bjsAlignment.setJalviewVersion(jalviewVersion);
+    bjsAlignment.setWebStartUrl(webStartLaunchServletUrl);
+
     int count = 0;
     for (SequenceI seq : alignment.getSequences())
     {
       StringBuilder name = new StringBuilder();
       name.append(seq.getName()).append("/").append(seq.getStart())
               .append("-").append(seq.getEnd());
-      // BioJsSeqPojo seqPojo = new BioJsSeqPojo(seq.getStart(), seq.getEnd(),
-      // String.valueOf(++count),
-      // name.toString(), seq.getSequenceAsString());
-      //
+
       BioJsSeqPojo seqPojo = new BioJsSeqPojo();
       seqPojo.setId(String.valueOf(++count));
       seqPojo.setEnd(seq.getEnd());
@@ -109,41 +143,29 @@ public class BioJsHTMLOutput
               .getSequenceFeatures();
       if (seqFeatures != null)
       {
-
         ArrayList<BioJsFeaturePojo> bjsSeqFeatures = new ArrayList<BioJsFeaturePojo>();
         for (SequenceFeature sf : seqFeatures)
         {
-
-          String featureColour = jalview.util.Format.getHexString(fr
-                  .getColour(sf));
-          BioJsFeaturePojo bjsFeature = new BioJsFeaturePojo();
-          bjsFeature.setFillColor(featureColour);
-          bjsFeature.setXstart(sf.getBegin());
-          bjsFeature.setXend(sf.getEnd());
-          bjsFeature.setText(sf.getType());
-
-          bjsSeqFeatures.add(bjsFeature);
-
+          if (displayedFeatures != null
+                  && displayedFeatures.get(sf.getType()) != null)
+          {
+            String featureColour = jalview.util.Format.getHexString(fr
+                    .getColour(sf));
+            BioJsFeaturePojo bjsFeature = new BioJsFeaturePojo();
+            bjsFeature.setFillColor(featureColour);
+            bjsFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
+            bjsFeature.setXend(seq.findIndex(sf.getEnd()));
+            bjsFeature.setText(sf.getType());
+            bjsSeqFeatures.add(bjsFeature);
+          }
         }
-
         seqPojo.setFeatures(bjsSeqFeatures);
       }
       bjsAlignment.getSeqs().add(seqPojo);
     }
 
-    String jalviewData = new com.json.JSONObject(bjsAlignment).toString()
+    return new com.json.JSONObject(bjsAlignment).toString()
             .replaceAll("xstart", "xStart").replaceAll("xend", "xEnd");
-    // String bioJSTemplate = new String(
-    // java.nio.file.Files.readAllBytes(java.nio.file.Paths
-    // .get("resources/templates/BioJSTemplate.txt")));
-    String bioJSTemplate = getBioJsTemplateAsString(this);
-
-    return bioJSTemplate.replaceAll("#sequenceData#", jalviewData)
-            .replaceAll(
-                    "#jalview_logo#",
-                    alignment.getClass()
-                            .getResource("/images/Jalview_Logo.png")
-                            .toString());
   }
 
   public static String getBioJsTemplateAsString(Object currentObj)
@@ -183,8 +205,17 @@ public class BioJsHTMLOutput
         }
       }
     }
-
     return sb.toString();
   }
 
+  public String getGlobalColorScheme()
+  {
+    return globalColorScheme;
+  }
+
+  public void setGlobalColorScheme(String globalColorScheme)
+  {
+    this.globalColorScheme = globalColorScheme;
+  }
+
 }
index ee1b151..77da038 100644 (file)
@@ -95,7 +95,8 @@ public class HtmlFile extends AlignFile
     if (jsonSeqFeatures != null)
     {
       seqFeatures = new SequenceFeature[jsonSeqFeatures.size()];
-      for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
+      for (@SuppressWarnings("unchecked")
+      Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
               .hasNext();)
       {
 
@@ -105,7 +106,7 @@ public class HtmlFile extends AlignFile
         Long end = (Long) jsonFeature.get("xEnd");
         String type = (String) jsonFeature.get("text");
 
-        String color = (String) jsonFeature.get("fillColor");
+        // String color = (String) jsonFeature.get("fillColor");
 
         sequenceFeature.setBegin(begin.intValue());
         sequenceFeature.setEnd(end.intValue());
index 365982e..4fb2516 100755 (executable)
@@ -136,13 +136,14 @@ public class IdentifyFile
 
           break;
         }
-        if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
+        // if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
+        if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
         {
           reply = "HTML";
           break;
         }
 
-        if ((data.indexOf("<") > -1))
+        if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>"))
         {
           reply = "RNAML";
 
index 7c2fe10..8e8747f 100644 (file)
@@ -19,6 +19,10 @@ import java.util.ArrayList;
 public class BioJsAlignmentPojo
 {
   private String globalColorScheme = "none";
+
+  private String jalviewVersion;
+
+  private String webStartUrl;
   private ArrayList<BioJsSeqPojo> seqs = new ArrayList<BioJsSeqPojo>();
 
   public BioJsAlignmentPojo()
@@ -65,6 +69,26 @@ public class BioJsAlignmentPojo
   }
 
 
+  public String getJalviewVersion()
+  {
+    return jalviewVersion;
+  }
+
+  public void setJalviewVersion(String jalviewVersion)
+  {
+    this.jalviewVersion = jalviewVersion;
+  }
+
+  public String getWebStartUrl()
+  {
+    return webStartUrl;
+  }
+
+  public void setWebStartUrl(String webStartUrl)
+  {
+    this.webStartUrl = webStartUrl;
+  }
+
   public enum JalviewBioJsColorSchemeMapper
   {
     USER_DEFINED("User Defined", "user defined", null), NONE("None", "foo",
diff --git a/test/jalview/io/BioJsHTMLOutputTest.java b/test/jalview/io/BioJsHTMLOutputTest.java
new file mode 100644 (file)
index 0000000..cbda794
--- /dev/null
@@ -0,0 +1,47 @@
+package jalview.io;
+
+import jalview.datamodel.Alignment;
+import jalview.datamodel.Sequence;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import com.json.JSONException;
+
+public class BioJsHTMLOutputTest
+{
+
+
+  @Test
+  public void getJalviewAlignmentAsJsonString()
+  {
+    BioJsHTMLOutput bioJsHtmlOuput = new BioJsHTMLOutput(null, null);
+    bioJsHtmlOuput.setGlobalColorScheme("Zappo");
+
+    Sequence[] seqs = new Sequence[1];
+    Sequence seq = new Sequence("name", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1, 26);
+    // SequenceFeature seqFeature = new SequenceFeature("type", "desc",
+    // "status", 1, 5, "jalview");
+    // seq.addSequenceFeature(seqFeature);
+    seq.setDatasetSequence(seq);
+    seqs[0] = seq;
+
+    Alignment al = new Alignment(seqs);
+    try
+    {
+      String generatedJson = bioJsHtmlOuput
+              .getJalviewAlignmentAsJsonString(al);
+      assert (generatedJson
+              .equalsIgnoreCase("{\"globalColorScheme\":\"zappo\",\"seqs\":[{\"id\":\"1\",\"start\":1,\"name\":\"name/1-26\",\"features\":[],\"seq\":\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"end\":26}]}"));
+      System.out.println("Output : " + generatedJson);
+    } catch (IOException e)
+    {
+      e.printStackTrace();
+    } catch (JSONException e)
+    {
+      e.printStackTrace();
+    }
+  }
+
+}
diff --git a/test/jalview/io/HtmlFileTest.java b/test/jalview/io/HtmlFileTest.java
new file mode 100644 (file)
index 0000000..be228b8
--- /dev/null
@@ -0,0 +1,16 @@
+package jalview.io;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class HtmlFileTest
+{
+
+  @Test
+  public void test()
+  {
+    fail("Not yet implemented");
+  }
+
+}