From: jprocter Date: Fri, 21 Oct 2011 12:09:37 +0000 (+0100) Subject: Merge branch 'Release_2_7_Branch_hotfix_JAL-962' into Release_2_7_Branch X-Git-Tag: Archived_Release_2_7~21 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=12808bb390e122a7297020319e02baffe77414ab;hp=d1f89c55f3e02bed671eb3ed27b3674d6137684e;p=jalview.git Merge branch 'Release_2_7_Branch_hotfix_JAL-962' into Release_2_7_Branch --- 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/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 39249cc..03f15d3 100755 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -1064,9 +1064,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer for (int i = 0; i < toset.length; i++) { Object st = featureGroups.get(toset[i]); + featureGroups.put(toset[i], new Boolean(visible)); if (st != null) { - featureGroups.put(toset[i], new Boolean(visible)); rdrw = rdrw || (visible != ((Boolean) st).booleanValue()); } } @@ -1090,6 +1090,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer } } + ArrayList hiddenGroups=new ArrayList(); /** * analyse alignment for groups and hash tables (used to be embedded in * FeatureSettings.setTableData) @@ -1103,8 +1104,10 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { featureGroups = new Hashtable(); } - Vector allFeatures = new Vector(); - Vector allGroups = new Vector(); + hiddenGroups =new ArrayList(); + hiddenGroups.addAll(featureGroups.keySet()); + ArrayList allFeatures = new ArrayList(); + ArrayList allGroups = new ArrayList(); SequenceFeature[] tmpfeatures; String group; for (int i = 0; i < av.alignment.getHeight(); i++) @@ -1123,9 +1126,11 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer if (tmpfeatures[index].getFeatureGroup() != null) { group = tmpfeatures[index].featureGroup; + // Remove group from the hiddenGroup list + hiddenGroups.remove(group); if (!allGroups.contains(group)) { - allGroups.addElement(group); + allGroups.add(group); boolean visible = true; if (featureGroups.containsKey(group)) @@ -1141,7 +1146,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer if (!allFeatures.contains(tmpfeatures[index].getType())) { - allFeatures.addElement(tmpfeatures[index].getType()); + allFeatures.add(tmpfeatures[index].getType()); } index++; } diff --git a/src/jalview/appletgui/FeatureSettings.java b/src/jalview/appletgui/FeatureSettings.java index e137416..ee0e23d 100755 --- a/src/jalview/appletgui/FeatureSettings.java +++ b/src/jalview/appletgui/FeatureSettings.java @@ -118,8 +118,10 @@ public class FeatureSettings extends Panel implements ItemListener, if (groupPanel != null) { - groupPanel.setLayout(new GridLayout(fr.featureGroups.size() / 4 + 1, - 4)); + groupPanel + .setLayout(new GridLayout( + (fr.featureGroups.size() - fr.hiddenGroups.size()) / 4 + 1, + 4)); groupPanel.validate(); add(groupPanel, BorderLayout.NORTH); @@ -261,7 +263,7 @@ public class FeatureSettings extends Panel implements ItemListener, rdrw = true; groupPanel.removeAll(); } - + // TODO: JAL-964 - smoothly incorporate new group entries if panel already displayed and new groups present Enumeration gps = fr.featureGroups.keys(); while (gps.hasMoreElements()) { @@ -273,6 +275,7 @@ public class FeatureSettings extends Panel implements ItemListener, check.addMouseListener(this); check.setFont(new Font("Serif", Font.BOLD, 12)); check.addItemListener(this); + check.setVisible(fr.hiddenGroups.contains(group)); groupPanel.add(check); } if (rdrw) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 52e7408..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) @@ -1840,7 +1863,27 @@ public class JalviewLite extends Applet implements } } - String param = applet.getParameter("features"); + // /////////////////////////// + // modify display of features + // we do this before any features have been loaded, ensuring any hidden groups are hidden when features first displayed + // + // hide specific groups + // + String param = applet.getParameter("hidefeaturegroups"); + if (param != null) + { + newAlignFrame.setFeatureGroupState(separatorListToArray(param), false); +// applet.setFeatureGroupStateOn(newAlignFrame, param, false); + } + // show specific groups + param = applet.getParameter("showfeaturegroups"); + if (param != null) + { + newAlignFrame.setFeatureGroupState(separatorListToArray(param), true); +// applet.setFeatureGroupStateOn(newAlignFrame, param, true); + } + // and now load features + param = applet.getParameter("features"); if (param != null) { param = setProtocolState(param); @@ -2059,21 +2102,6 @@ public class JalviewLite extends Applet implements protocols); } - // /////////////////////////// - // modify display of features - // - // hide specific groups - param = applet.getParameter("hidefeaturegroups"); - if (param != null) - { - applet.setFeatureGroupStateOn(newAlignFrame, param, false); - } - // show specific groups - param = applet.getParameter("showfeaturegroups"); - if (param != null) - { - applet.setFeatureGroupStateOn(newAlignFrame, param, true); - } } else { 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