From: jprocter Date: Fri, 21 Oct 2011 12:01:02 +0000 (+0100) Subject: (JAL-965) new api methods to allow features to be loaded without automatically enabli... X-Git-Tag: Archived_Release_2_7~21^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=691798cf6a90094f4c83e79fd5c703457b1135b0;p=jalview.git (JAL-965) new api methods to allow features to be loaded without automatically enabling feature display. --- diff --git a/examples/jalviewLiteJs.html b/examples/jalviewLiteJs.html index e33b30d..197ef56 100644 --- a/examples/jalviewLiteJs.html +++ b/examples/jalviewLiteJs.html @@ -215,11 +215,21 @@ public String getAlignmentFrom(AlignFrame alf, String format) public String getAlignmentFrom(AlignFrame alf, String format, String suffix) // add the given features or annotation to the current alignment +// if features are loaded, feature display is automatically enabled public void loadAnnotation(String annotation) // add the given features or annotation to the given alignment view +// if features are loaded, feature display is automatically enabled public void loadAnnotationFrom(AlignFrame alf, String annotation) +// parse the given string as a jalview or GFF features file and optionally enable feature display on the current alignment +// (v2.7.1) +public abstract void loadFeatures(String features, boolean autoenabledisplay) + +// parse the given string as a jalview or GFF features file and optionally enable feature display on the given alignment +// (v2.7.1) +public abstract void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay) + // get the sequence features in the given format (Jalview or GFF) public String getFeatures(String format) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 759075a..5790bc3 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -161,14 +161,26 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, } /** - * DOCUMENT ME! + * Load a features file onto the alignment * - * @param String - * DOCUMENT ME! + * @param file file URL, content, or other resolvable path + * @param type is protocol for accessing data referred to by file */ public void parseFeaturesFile(String file, String type) { + parseFeaturesFile(file, type, true); + } + + /** + * Load a features file onto the alignment + * + * @param file file URL, content, or other resolvable path + * @param type is protocol for accessing data referred to by file + * @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded + */ + public void parseFeaturesFile(String file, String type, boolean autoenabledisplay) + { Hashtable featureLinks = new Hashtable(); boolean featuresFile = false; try @@ -188,8 +200,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks; } - viewport.showSequenceFeatures = true; - sequenceFeatures.setState(true); + if (autoenabledisplay) + { + viewport.showSequenceFeatures = true; + sequenceFeatures.setState(true); + } if (viewport.featureSettings != null) { viewport.featureSettings.refreshTable(); diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 562bc92..0cba50e 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -716,6 +716,29 @@ public class JalviewLite extends Applet implements /* * (non-Javadoc) * + * @see jalview.bin.JalviewLiteJsApi#loadAnnotation(java.lang.String) + */ + public void loadFeatures(String features, boolean autoenabledisplay) + { + loadFeaturesFrom(getDefaultTargetFrame(), features, autoenabledisplay); + } + + /* + * (non-Javadoc) + * + * @see + * jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame + * , java.lang.String) + */ + public void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay) + { + alf.parseFeaturesFile(features, AppletFormatAdapter.PASTE, autoenabledisplay); + } + + + /* + * (non-Javadoc) + * * @see jalview.bin.JalviewLiteJsApi#getFeatures(java.lang.String) */ public String getFeatures(String format) diff --git a/src/jalview/javascript/JalviewLiteJsApi.java b/src/jalview/javascript/JalviewLiteJsApi.java index 103e7da..d064790 100644 --- a/src/jalview/javascript/JalviewLiteJsApi.java +++ b/src/jalview/javascript/JalviewLiteJsApi.java @@ -280,6 +280,21 @@ public interface JalviewLiteJsApi public abstract void loadAnnotationFrom(AlignFrame alf, String annotation); /** + * parse the given string as a jalview feature or GFF annotation file and optionally enable feature display on the current alignFrame + * @param features - gff or features file + * @param autoenabledisplay - when true, feature display will be enabled if any features can be parsed from the string. + */ + public abstract void loadFeatures(String features, boolean autoenabledisplay); + + /** + * parse the given string as a jalview feature or GFF annotation file and optionally enable feature display on the given alignFrame. + * @param alf + * @param features - gff or features file + * @param autoenabledisplay - when true, feature display will be enabled if any features can be parsed from the string. + */ + public abstract void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay); + + /** * get the sequence features in the given format (Jalview or GFF) * @param format * @return