JAL-1541 minor code clean up, and added test for BioJsHTMLOutput
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 20 May 2015 08:52:34 +0000 (09:52 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 20 May 2015 08:52:34 +0000 (09:52 +0100)
src/jalview/gui/AlignFrame.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/io/BioJsHTMLOutput.java
src/jalview/io/FileLoader.java
src/jalview/io/HtmlFile.java
src/jalview/io/JSONFile.java
test/jalview/io/BioJsHTMLOutputTest.java

index 61073e3..79868f6 100644 (file)
@@ -1342,8 +1342,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void bioJSMenuItem_actionPerformed(ActionEvent e)
   {
-    new BioJsHTMLOutput(alignPanel,
+    BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel,
             alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
+    bjs.exportJalviewAlignmentAsBioJsHtmlFile();
   }
   public void createImageMap(File file, String image)
   {
index 3f4aa71..1981488 100644 (file)
@@ -228,11 +228,11 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
 
         if (source instanceof HtmlFile)
         {
-          ((HtmlFile) source).LoadAlignmentFeatures(af);
+          ((HtmlFile) source).applySettingsToAlignFrame(af);
         }
         else if (source instanceof JSONFile)
         {
-          ((JSONFile) source).LoadAlignmentFeatures(af);
+          ((JSONFile) source).applySettingsToAlignFrame(af);
         }
 
 
index 86b4c28..669054d 100644 (file)
@@ -27,10 +27,10 @@ public class BioJsHTMLOutput
       this.av = ap.av;
       av.setFeatureRenderer(new FeatureRenderer(ap));
     }
-    exportJalviewAlignmentAsBioJsHtmlFile();
+
   }
 
-  private void exportJalviewAlignmentAsBioJsHtmlFile()
+  public void exportJalviewAlignmentAsBioJsHtmlFile()
   {
     try
     {
index 9ccde9e..6329f58 100755 (executable)
@@ -348,11 +348,11 @@ public class FileLoader implements Runnable
             }
             if (source instanceof HtmlFile)
             {
-              ((HtmlFile) source).LoadAlignmentFeatures(alignFrame);
+              ((HtmlFile) source).applySettingsToAlignFrame(alignFrame);
             }
             else if (source instanceof JSONFile)
             {
-              ((JSONFile) source).LoadAlignmentFeatures(alignFrame);
+              ((JSONFile) source).applySettingsToAlignFrame(alignFrame);
             }
 
             if (raiseGUI)
index fd07893..d507362 100644 (file)
@@ -62,7 +62,7 @@ public class HtmlFile extends AlignFile
     }
   }
 
-  public void LoadAlignmentFeatures(AlignFrame af)
+  public void applySettingsToAlignFrame(AlignFrame af)
   {
     af.setShowSeqFeatures(isShowSeqFeatures());
     af.changeColour(getColourScheme());
@@ -74,7 +74,7 @@ public class HtmlFile extends AlignFile
   public String print()
   {
     throw new UnsupportedOperationException(
-            "Print method of HtmlFile not yet supported!");
+            "Print method of HtmlFile is not supported!");
   }
 
   public boolean isShowSeqFeatures()
index fcedb2b..28b8ed2 100644 (file)
@@ -37,8 +37,6 @@ public class JSONFile extends AlignFile
 {
   private ColourSchemeI colourScheme;
 
-  // private static boolean seqFeaturesEnabled;
-
   private String jalviewVersion;
 
   private String webStartLaunchServletUrl;
@@ -55,8 +53,6 @@ public class JSONFile extends AlignFile
 
   private FeaturesDisplayedI displayedFeatures;
 
-  // private AlignViewportI viewport;
-
   private FeatureRenderer fr;
 
   private JSONExportSettings jsonExportSettings;
@@ -112,7 +108,6 @@ public class JSONFile extends AlignFile
         setDisplayedFeatures(getViewport().getFeaturesDisplayed());
         showSeqFeatures = getViewport().isShowSequenceFeatures();
         fr = getViewport().getFeatureRenderer();
-        // setSeqFeaturesEnabled(viewport.isShowSequenceFeatures());
       }
 
       int count = 0;
@@ -298,7 +293,6 @@ public class JSONFile extends AlignFile
         Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
                 "showSeqFeatures").toString());
         setColourScheme(getJalviewColorScheme(jsColourScheme));
-        // JSONFile.setSeqFeaturesEnabled(showFeatures);
         setShowSeqFeatures(showFeatures);
       }
 
@@ -467,7 +461,7 @@ public class JSONFile extends AlignFile
     return jalviewColor;
   }
 
-  public void LoadAlignmentFeatures(AlignFrame af)
+  public void applySettingsToAlignFrame(AlignFrame af)
   {
     af.setShowSeqFeatures(isShowSeqFeatures());
     af.changeColour(getColourScheme());
index 8c4b639..8d9de77 100644 (file)
@@ -1,19 +1,28 @@
 package jalview.io;
 
-import org.junit.Ignore;
+import java.io.IOException;
+
+import org.junit.Assert;
 import org.junit.Test;
 
 
 public class BioJsHTMLOutputTest
 {
 
-
   @Test
-  @Ignore
   public void getJalviewAlignmentAsJsonString()
   {
-    BioJsHTMLOutput bioJsHtmlOuput = new BioJsHTMLOutput(null, null);
-
+    BioJsHTMLOutput bioJsHtmlOutput = new BioJsHTMLOutput(null, null);
+    String bjsTemplate = null;
+    try
+    {
+      bjsTemplate = BioJsHTMLOutput
+              .getBioJsTemplateAsString(bioJsHtmlOutput);
+      // System.out.println(bjsTemplate);
+    } catch (IOException e)
+    {
+      e.printStackTrace();
+    }
+    Assert.assertNotNull(bjsTemplate);
   }
-  
 }