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)
}\r
\r
/**\r
- * DOCUMENT ME!\r
+ * Load a features file onto the alignment\r
* \r
- * @param String\r
- * DOCUMENT ME!\r
+ * @param file file URL, content, or other resolvable path\r
+ * @param type is protocol for accessing data referred to by file\r
*/\r
\r
public void parseFeaturesFile(String file, String type)\r
{\r
+ parseFeaturesFile(file, type, true);\r
+ }\r
+ \r
+ /**\r
+ * Load a features file onto the alignment\r
+ * \r
+ * @param file file URL, content, or other resolvable path\r
+ * @param type is protocol for accessing data referred to by file\r
+ * @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded\r
+ */\r
+ public void parseFeaturesFile(String file, String type, boolean autoenabledisplay)\r
+ { \r
Hashtable featureLinks = new Hashtable();\r
boolean featuresFile = false;\r
try\r
{\r
alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureLinks = featureLinks;\r
}\r
- viewport.showSequenceFeatures = true;\r
- sequenceFeatures.setState(true);\r
+ if (autoenabledisplay)\r
+ {\r
+ viewport.showSequenceFeatures = true;\r
+ sequenceFeatures.setState(true);\r
+ }\r
if (viewport.featureSettings != null)\r
{\r
viewport.featureSettings.refreshTable();\r
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());
}
}
}
}
+ ArrayList<String> hiddenGroups=new ArrayList<String>();
/**
* analyse alignment for groups and hash tables (used to be embedded in
* FeatureSettings.setTableData)
{
featureGroups = new Hashtable();
}
- Vector allFeatures = new Vector();
- Vector allGroups = new Vector();
+ hiddenGroups =new ArrayList<String>();
+ 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++)
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))
if (!allFeatures.contains(tmpfeatures[index].getType()))
{
- allFeatures.addElement(tmpfeatures[index].getType());
+ allFeatures.add(tmpfeatures[index].getType());
}
index++;
}
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);
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())
{
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)
/*\r
* (non-Javadoc)\r
* \r
+ * @see jalview.bin.JalviewLiteJsApi#loadAnnotation(java.lang.String)\r
+ */\r
+ public void loadFeatures(String features, boolean autoenabledisplay)\r
+ {\r
+ loadFeaturesFrom(getDefaultTargetFrame(), features, autoenabledisplay);\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see\r
+ * jalview.bin.JalviewLiteJsApi#loadAnnotationFrom(jalview.appletgui.AlignFrame\r
+ * , java.lang.String)\r
+ */\r
+ public void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay)\r
+ {\r
+ alf.parseFeaturesFile(features, AppletFormatAdapter.PASTE, autoenabledisplay);\r
+ }\r
+\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
* @see jalview.bin.JalviewLiteJsApi#getFeatures(java.lang.String)\r
*/\r
public String getFeatures(String format)\r
}\r
}\r
\r
- String param = applet.getParameter("features");\r
+ // ///////////////////////////\r
+ // modify display of features\r
+ // we do this before any features have been loaded, ensuring any hidden groups are hidden when features first displayed\r
+ //\r
+ // hide specific groups\r
+ // \r
+ String param = applet.getParameter("hidefeaturegroups");\r
+ if (param != null)\r
+ {\r
+ newAlignFrame.setFeatureGroupState(separatorListToArray(param), false); \r
+// applet.setFeatureGroupStateOn(newAlignFrame, param, false);\r
+ }\r
+ // show specific groups\r
+ param = applet.getParameter("showfeaturegroups");\r
+ if (param != null)\r
+ {\r
+ newAlignFrame.setFeatureGroupState(separatorListToArray(param), true); \r
+// applet.setFeatureGroupStateOn(newAlignFrame, param, true);\r
+ }\r
+ // and now load features\r
+ param = applet.getParameter("features");\r
if (param != null)\r
{\r
param = setProtocolState(param);\r
protocols);\r
\r
}\r
- // ///////////////////////////\r
- // modify display of features\r
- //\r
- // hide specific groups\r
- param = applet.getParameter("hidefeaturegroups");\r
- if (param != null)\r
- {\r
- applet.setFeatureGroupStateOn(newAlignFrame, param, false);\r
- }\r
- // show specific groups\r
- param = applet.getParameter("showfeaturegroups");\r
- if (param != null)\r
- {\r
- applet.setFeatureGroupStateOn(newAlignFrame, param, true);\r
- }\r
}\r
else\r
{\r
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