JAL-2006 squash rounding errors at min/max threshold slider positions
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 28 Jul 2017 08:45:57 +0000 (10:45 +0200)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 28 Jul 2017 08:45:57 +0000 (10:45 +0200)
src/jalview/gui/FeatureColourChooser.java

index 7974af9..4172819 100644 (file)
@@ -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);
 
     /*