From 854fa199e6dd89266237dc803ddc88bf7ba5bdcc Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 1 May 2014 15:03:33 +0100 Subject: [PATCH] fix for JAL-1494 tweaked logic to fix NPEs and modify settings for both background and all defined groups --- src/jalview/appletgui/SliderPanel.java | 26 +++++++++---------- src/jalview/gui/SliderPanel.java | 43 +++++++++++--------------------- 2 files changed, 28 insertions(+), 41 deletions(-) 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(); -- 1.7.10.2