(JAL-962) allow group visibility to be specified before features in those groups...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 21 Oct 2011 11:48:21 +0000 (12:48 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 21 Oct 2011 11:48:21 +0000 (12:48 +0100)
src/jalview/appletgui/FeatureRenderer.java
src/jalview/appletgui/FeatureSettings.java

index 39249cc..03f15d3 100755 (executable)
@@ -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<String> hiddenGroups=new ArrayList<String>();
   /**
    * 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<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++)
@@ -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++;
       }
index e137416..ee0e23d 100755 (executable)
@@ -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)