JAL-3438 spotless for 2.11.2.0
[jalview.git] / src / jalview / gui / Slider.java
index b913ba0..184304c 100644 (file)
@@ -16,6 +16,12 @@ import javax.swing.JSlider;
 public class Slider extends JSlider
 {
   /*
+   * the number of nominal positions the slider represents
+   * (higher number = more fine-grained positioning)
+   */
+  private static final int SCALE_TICKS = 1000;
+
+  /*
    * 'true' value corresponding to zero on the slider
    */
   private float trueMin;
@@ -29,7 +35,7 @@ public class Slider extends JSlider
    * scaleFactor applied to true value range to give a
    * slider range of 0 - 100
    */
-  private int sliderScaleFactor;
+  private float sliderScaleFactor;
 
   /**
    * Constructor that rescales min - max to 0 - 100 for the slider
@@ -57,7 +63,7 @@ public class Slider extends JSlider
     trueMin = min;
     trueMax = max;
     setMinimum(0);
-    sliderScaleFactor = (int) (100f / (max - min));
+    sliderScaleFactor = SCALE_TICKS / (max - min);
     int sliderMax = (int) ((max - min) * sliderScaleFactor);
     setMaximum(sliderMax);
     setSliderValue(value);
@@ -75,7 +81,7 @@ public class Slider extends JSlider
      */
     int value = getValue();
     return value == getMaximum() ? trueMax
-            : value / (float) sliderScaleFactor + trueMin;
+            : value / sliderScaleFactor + trueMin;
   }
 
   /**
@@ -85,12 +91,12 @@ public class Slider extends JSlider
    */
   public void setSliderValue(float value)
   {
-    setValue((int) ((value - trueMin) * sliderScaleFactor));
+    setValue(Math.round((value - trueMin) * sliderScaleFactor));
   }
 
   /**
-   * Answers the value of the slider position as a percentage between minimum and
-   * maximum of its range
+   * Answers the value of the slider position as a percentage between minimum
+   * and maximum of its range
    * 
    * @return
    */