tidy imports
[jalview.git] / src / jalview / appletgui / FeatureRenderer.java
index 244b650..dd236bd 100755 (executable)
@@ -1,13 +1,13 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
@@ -23,7 +23,6 @@ import java.awt.*;
 
 import java.awt.event.*;
 
-import jalview.appletgui.FeatureSettings.MyCheckbox;
 import jalview.datamodel.*;
 import jalview.schemes.AnnotationColourGradient;
 import jalview.schemes.GraduatedColor;
@@ -84,17 +83,19 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     featureGroups = fr.featureGroups;
     featureColours = fr.featureColours;
     transparency = fr.transparency;
-    if (av!=null && fr.av!=null && fr.av!=av)
+    if (av != null && fr.av != null && fr.av != av)
     {
-      if (fr.av.featuresDisplayed!=null)
+      if (fr.av.featuresDisplayed != null)
       {
-        if (av.featuresDisplayed==null)
+        if (av.featuresDisplayed == null)
         {
           av.featuresDisplayed = new Hashtable();
-        } else {
+        }
+        else
+        {
           av.featuresDisplayed.clear();
         }
-        Enumeration en=fr.av.featuresDisplayed.keys();
+        Enumeration en = fr.av.featuresDisplayed.keys();
         while (en.hasMoreElements())
         {
           av.featuresDisplayed.put(en.nextElement(), Boolean.TRUE);
@@ -786,10 +787,10 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     av.featuresDisplayed = new Hashtable();
     Vector allfeatures = new Vector();
     minmax = new Hashtable();
-
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment = av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      SequenceFeature[] features = av.alignment.getSequenceAt(i)
+      SequenceFeature[] features = alignment.getSequenceAt(i)
               .getSequenceFeatures();
 
       if (features == null)
@@ -1064,9 +1065,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 +1091,8 @@ 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,29 +1106,34 @@ 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++)
+    AlignmentI alignment = av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+      if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
       {
         continue;
       }
 
       alignmentHasFeatures = true;
 
-      tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+      tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
       int index = 0;
       while (index < tmpfeatures.length)
       {
         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 +1149,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++;
       }
@@ -1170,16 +1178,17 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer
     Vector allFeatures = new Vector();
     SequenceFeature[] tmpfeatures;
     String group;
-    for (int i = 0; i < av.alignment.getHeight(); i++)
+    AlignmentI alignment = av.getAlignment();
+    for (int i = 0; i < alignment.getHeight(); i++)
     {
-      if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+      if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
       {
         continue;
       }
 
       alignmentHasFeatures = true;
 
-      tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+      tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
       int index = 0;
       while (index < tmpfeatures.length)
       {