From: gmungoc Date: Fri, 28 Jul 2017 08:45:57 +0000 (+0200) Subject: JAL-2006 squash rounding errors at min/max threshold slider positions X-Git-Tag: Release_2_10_3b1~132^2~31^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=98f6651899fa88eed326ef6684b22e06e7a49c1a;p=jalview.git JAL-2006 squash rounding errors at min/max threshold slider positions --- diff --git a/src/jalview/gui/FeatureColourChooser.java b/src/jalview/gui/FeatureColourChooser.java index 7974af9..4172819 100644 --- a/src/jalview/gui/FeatureColourChooser.java +++ b/src/jalview/gui/FeatureColourChooser.java @@ -445,7 +445,8 @@ public class FeatureColourChooser extends JalviewDialog slider.setMinimum((int) (min * scaleFactor)); slider.setMaximum((int) (max * scaleFactor)); - slider.setValue((int) (threshline.value * scaleFactor)); + // slider.setValue((int) (threshline.value * scaleFactor)); + slider.setValue(Math.round(threshline.value * scaleFactor)); thresholdValue.setText(threshline.value + ""); slider.setMajorTickSpacing((int) (range / 10f)); slider.setEnabled(true); @@ -565,7 +566,13 @@ public class FeatureColourChooser extends JalviewDialog */ protected void sliderValueChanged() { - threshline.value = slider.getValue() / scaleFactor; + /* + * squash rounding errors by forcing min/max of slider to + * actual min/max of feature score range + */ + int value = slider.getValue(); + threshline.value = value == slider.getMaximum() ? max + : (value == slider.getMinimum() ? min : value / scaleFactor); cs.setThreshold(threshline.value); /*