From: jprocter Date: Fri, 21 Oct 2011 11:48:21 +0000 (+0100) Subject: (JAL-962) allow group visibility to be specified before features in those groups... X-Git-Tag: Archived_Release_2_7~21^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8f49ecb042d47e8eda13869f7581fd340191f46b;p=jalview.git (JAL-962) allow group visibility to be specified before features in those groups are loaded on to the alignment. TODO re JAL-964 --- 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)