JAL-741 (poss related JAL-971) - fix NPE raised when attempting to sort alignment...
authorJim Procter <jprocter@dundee.ac.uk>
Sat, 19 Apr 2014 12:56:18 +0000 (13:56 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 21 Apr 2014 13:09:19 +0000 (14:09 +0100)
src/jalview/gui/FeatureSettings.java

index d7f05dc..9e0925b 100644 (file)
@@ -1158,13 +1158,13 @@ public class FeatureSettings extends JPanel
   private String[] getDisplayedFeatureGroups()
   {
     String[] gps = null;
+    ArrayList<String> _gps = new ArrayList<String>();
     if (fr != null)
     {
 
       if (fr.featureGroups != null)
       {
         Iterator en = fr.featureGroups.keySet().iterator();
-        gps = new String[fr.featureColours.size()];
         int g = 0;
         boolean valid = false;
         while (en.hasNext())
@@ -1174,16 +1174,15 @@ public class FeatureSettings extends JPanel
           if (on != null && on.booleanValue())
           {
             valid = true;
-            gps[g++] = gp;
+            _gps.add(gp);
           }
         }
-        while (g < gps.length)
-        {
-          gps[g++] = null;
-        }
         if (!valid)
         {
           return null;
+        } else {
+          gps = new String[_gps.size()];
+          _gps.toArray(gps);
         }
       }
     }