fix for JAL-1494 tweaked logic to fix NPEs and modify settings for both background...
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 1 May 2014 14:03:33 +0000 (15:03 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 1 May 2014 14:03:33 +0000 (15:03 +0100)
src/jalview/appletgui/SliderPanel.java
src/jalview/gui/SliderPanel.java

index bda4489..1bd5fd8 100644 (file)
@@ -196,25 +196,16 @@ public class SliderPanel extends Panel implements ActionListener,
       return;
     }
 
-    ColourSchemeI toChange = null;
+    ColourSchemeI toChange = cs;
     Iterator<SequenceGroup> allGroups = null;
 
     if (allGroupsCheck.getState())
     {
       allGroups = ap.av.getAlignment().getGroups().listIterator();
     }
-    else
-    {
-      toChange = cs;
-    }
 
-    do
+    while (toChange != null)
     {
-      if (allGroups != null)
-      {
-        toChange = allGroups.next().cs;
-      }
-
       if (forConservation)
       {
         toChange.setConservationInc(i);
@@ -223,8 +214,17 @@ public class SliderPanel extends Panel implements ActionListener,
       {
         toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());
       }
-
-    } while (allGroups != null && allGroups.hasNext());
+      if (allGroups != null && allGroups.hasNext())
+      {
+        while ((toChange = allGroups.next().cs) == null
+                && allGroups.hasNext())
+          ;
+      }
+      else
+      {
+        toChange = null;
+      }
+    }
 
     ap.seqPanel.seqCanvas.repaint();
 
index 3eff177..f53204e 100755 (executable)
@@ -267,47 +267,34 @@ public class SliderPanel extends GSliderPanel
       return;
     }
 
-    ColourSchemeI toChange = null;
-    List<SequenceGroup> allGroups = null;
-    int groupIndex = 0;
+    ColourSchemeI toChange = cs;
+    Iterator<SequenceGroup> allGroups = null;
 
     if (allGroupsCheck.isSelected())
     {
-      allGroups = ap.av.getAlignment().getGroups();
-      groupIndex = allGroups.size() - 1;
-    }
-    else
-    {
-      toChange = cs;
+      allGroups = ap.av.getAlignment().getGroups().listIterator();
     }
 
-    while (groupIndex > -1)
+    while (toChange != null)
     {
-      if (allGroups != null)
-      {
-        toChange = ((SequenceGroup) allGroups.get(groupIndex)).cs;
-
-        if (toChange == null)
-        {
-          groupIndex--;
-
-          continue;
-        }
-      }
-
       if (forConservation)
       {
-        if (toChange.conservationApplied())
-        {
-          toChange.setConservationInc(i);
-        }
+        toChange.setConservationInc(i);
       }
       else
       {
         toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());
       }
-
-      groupIndex--;
+      if (allGroups != null && allGroups.hasNext())
+      {
+        while ((toChange = allGroups.next().cs) == null
+                && allGroups.hasNext())
+          ;
+      }
+      else
+      {
+        toChange = null;
+      }
     }
 
     ap.seqPanel.seqCanvas.repaint();