1 package jalview.ws.params.simple;
3 import jalview.ws.params.ParameterI;
4 import jalview.ws.params.ValueConstrainI;
7 * A model for a numeric-valued parameter which should be displayed using a
12 public class LogarithmicParameter extends Option implements ParameterI
14 public static class Builder extends Option.Builder
16 // setting them the opposite way disables limits until both are set.
17 protected double min = Double.POSITIVE_INFINITY;
19 protected double max = Double.NEGATIVE_INFINITY;
22 * Setting string on double parameter is not allowed, use
23 * {@link #setValue(Double)} instead.
26 public void setValue(String value)
28 throw new UnsupportedOperationException();
31 public void setValue(Double value)
34 super.setValue(value.toString());
40 * Setting string on double parameter is not allowed, use
41 * {@link #setDefaultValue(Double)} instead.
44 public void setDefaultValue(String defaultValue)
46 throw new UnsupportedOperationException();
49 public void setDefaultValue(Double defaultValue)
51 if (defaultValue != null)
52 super.setDefaultValue(defaultValue.toString());
54 super.setDefaultValue(null);
57 public void setMin(Double min)
59 this.min = min != null ? min : Double.POSITIVE_INFINITY;
62 public void setMax(Double max)
64 this.max = max != null ? max : Double.NEGATIVE_INFINITY;
67 public void setBounds(Double min, Double max)
74 public LogarithmicParameter build()
76 return new LogarithmicParameter(this);
87 public ValueConstrainI getValidValue()
89 return new ValueConstrainI()
93 public ValueType getType()
95 return ValueType.Double;
99 public Number getMin()
101 return min < max ? min : null;
105 public Number getMax()
107 return min < max ? max : null;
112 public static Builder newBuilder()
114 return new Builder();
117 public LogarithmicParameter(Builder builder)
120 this.min = builder.min;
121 this.max = builder.max;
122 if (defvalue != null)
123 defval = Double.parseDouble(defvalue);
128 public LogarithmicParameter(LogarithmicParameter parm)
136 public LogarithmicParameter(String name, String description,
137 boolean required, Double defValue, double min, double max)
139 super(name, description, required, String.valueOf(defValue), null, null,
146 public LogarithmicParameter(String name, String description,
147 boolean required, Double defValue, double value, double min,
150 super(name, description, required, String.valueOf(defValue),
151 String.valueOf(value), null, null);
158 public LogarithmicParameter copy()
160 return new LogarithmicParameter(this);