From: tcofoegbu Date: Wed, 20 May 2015 08:52:34 +0000 (+0100) Subject: JAL-1541 minor code clean up, and added test for BioJsHTMLOutput X-Git-Tag: Release_2_10_0~657^2~3^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7ce1382b998c007a78c9b33a3dc331e966eebc4b;p=jalview.git JAL-1541 minor code clean up, and added test for BioJsHTMLOutput --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 61073e3..79868f6 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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) { diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 3f4aa71..1981488 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -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); } diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 86b4c28..669054d 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -27,10 +27,10 @@ public class BioJsHTMLOutput this.av = ap.av; av.setFeatureRenderer(new FeatureRenderer(ap)); } - exportJalviewAlignmentAsBioJsHtmlFile(); + } - private void exportJalviewAlignmentAsBioJsHtmlFile() + public void exportJalviewAlignmentAsBioJsHtmlFile() { try { diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 9ccde9e..6329f58 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -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) diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java index fd07893..d507362 100644 --- a/src/jalview/io/HtmlFile.java +++ b/src/jalview/io/HtmlFile.java @@ -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() diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index fcedb2b..28b8ed2 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -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()); diff --git a/test/jalview/io/BioJsHTMLOutputTest.java b/test/jalview/io/BioJsHTMLOutputTest.java index 8c4b639..8d9de77 100644 --- a/test/jalview/io/BioJsHTMLOutputTest.java +++ b/test/jalview/io/BioJsHTMLOutputTest.java @@ -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); } - }