From: Jim Procter Date: Thu, 1 May 2014 14:03:33 +0000 (+0100) Subject: fix for JAL-1494 tweaked logic to fix NPEs and modify settings for both background... X-Git-Tag: Jalview_2_9~190^2~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=854fa199e6dd89266237dc803ddc88bf7ba5bdcc;p=jalview.git fix for JAL-1494 tweaked logic to fix NPEs and modify settings for both background and all defined groups --- diff --git a/src/jalview/appletgui/SliderPanel.java b/src/jalview/appletgui/SliderPanel.java index bda4489..1bd5fd8 100644 --- a/src/jalview/appletgui/SliderPanel.java +++ b/src/jalview/appletgui/SliderPanel.java @@ -196,25 +196,16 @@ public class SliderPanel extends Panel implements ActionListener, return; } - ColourSchemeI toChange = null; + ColourSchemeI toChange = cs; Iterator 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(); diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java index 3eff177..f53204e 100755 --- a/src/jalview/gui/SliderPanel.java +++ b/src/jalview/gui/SliderPanel.java @@ -267,47 +267,34 @@ public class SliderPanel extends GSliderPanel return; } - ColourSchemeI toChange = null; - List allGroups = null; - int groupIndex = 0; + ColourSchemeI toChange = cs; + Iterator 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();