JAL-3432 hide the slider when validator has no min or max
authorJim Procter <jprocter@issues.jalview.org>
Tue, 17 Sep 2019 10:53:42 +0000 (11:53 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 17 Sep 2019 10:53:42 +0000 (11:53 +0100)
src/jalview/gui/OptsAndParamsPage.java

index 5b411b4..d66ec1c 100644 (file)
@@ -903,6 +903,11 @@ public class OptsAndParamsPage
         return valueField.getText().trim();
       }
 
+      if (validator.getMin() == null || validator.getMax() == null)
+      {
+        slider.setVisible(false);
+      }
+
       valueField.setText(valueField.getText().trim());
 
       /*
@@ -951,7 +956,7 @@ public class OptsAndParamsPage
         {
           slider.setVisible(false);
         }
-        return new Integer(iVal);
+        return Integer.valueOf(iVal);
       }
 
       if (isLogarithmicParameter)
@@ -960,7 +965,7 @@ public class OptsAndParamsPage
         try
         {
           double eValue = Double.valueOf(valueField.getText());
-          dVal = Math.log(eValue) * sliderScaleFactor;
+          dVal = Math.log(eValue);
         } catch (Exception e)
         {
           // shouldn't be possible here
@@ -973,14 +978,15 @@ public class OptsAndParamsPage
                   * sliderScaleFactor;
           double scaleMax = Math.log(validator.getMax().doubleValue())
                   * sliderScaleFactor;
-          slider.getModel().setRangeProperties((int) (dVal), 1,
+          slider.getModel().setRangeProperties(
+                  (int) (sliderScaleFactor * dVal), 1,
                   (int) scaleMin, 1 + (int) scaleMax, true);
         }
         else
         {
           slider.setVisible(false);
         }
-        return new Double(dVal);
+        return Double.valueOf(dVal);
       }
 
       float fVal = 0f;
@@ -1005,7 +1011,7 @@ public class OptsAndParamsPage
       {
         slider.setVisible(false);
       }
-      return new Float(fVal);
+      return Float.valueOf(fVal);
     }
   }