Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.ws.params.simple

File LogarithmicParameter.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

14
37
18
2
162
123
25
0.68
2.06
9
1.39

Classes

Class Line # Actions
LogarithmicParameter 12 24 13
0.00%
LogarithmicParameter.Builder 14 13 12
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package jalview.ws.params.simple;
2   
3    import jalview.ws.params.ParameterI;
4    import jalview.ws.params.ValueConstrainI;
5   
6    /**
7    * A model for a numeric-valued parameter which should be displayed using a
8    * logarithmic scale
9    *
10    * @author TZVanaalten
11    */
 
12    public class LogarithmicParameter extends Option implements ParameterI
13    {
 
14    public static class Builder extends Option.Builder
15    {
16    // setting them the opposite way disables limits until both are set.
17    protected double min = Double.POSITIVE_INFINITY;
18   
19    protected double max = Double.NEGATIVE_INFINITY;
20   
21    /**
22    * Setting string on double parameter is not allowed, use
23    * {@link #setValue(Double)} instead.
24    */
 
25  0 toggle @Override
26    public void setValue(String value)
27    {
28  0 throw new UnsupportedOperationException();
29    }
30   
 
31  0 toggle public void setValue(Double value)
32    {
33  0 if (value != null)
34  0 super.setValue(value.toString());
35    else
36  0 super.setValue(null);
37    }
38   
39    /**
40    * Setting string on double parameter is not allowed, use
41    * {@link #setDefaultValue(Double)} instead.
42    */
 
43  0 toggle @Override
44    public void setDefaultValue(String defaultValue)
45    {
46  0 throw new UnsupportedOperationException();
47    }
48   
 
49  0 toggle public void setDefaultValue(Double defaultValue)
50    {
51  0 if (defaultValue != null)
52  0 super.setDefaultValue(defaultValue.toString());
53    else
54  0 super.setDefaultValue(null);
55    }
56   
 
57  0 toggle public void setMin(Double min)
58    {
59  0 this.min = min != null ? min : Double.POSITIVE_INFINITY;
60    }
61   
 
62  0 toggle public void setMax(Double max)
63    {
64  0 this.max = max != null ? max : Double.NEGATIVE_INFINITY;
65    }
66   
 
67  0 toggle public void setBounds(Double min, Double max)
68    {
69  0 setMin(min);
70  0 setMax(max);
71    }
72   
 
73  0 toggle @Override
74    public LogarithmicParameter build()
75    {
76  0 return new LogarithmicParameter(this);
77    }
78    }
79   
80    final double defval;
81   
82    final double min;
83   
84    final double max;
85   
 
86  0 toggle @Override
87    public ValueConstrainI getValidValue()
88    {
89  0 return new ValueConstrainI()
90    {
91   
 
92  0 toggle @Override
93    public ValueType getType()
94    {
95  0 return ValueType.Double;
96    }
97   
 
98  0 toggle @Override
99    public Number getMin()
100    {
101  0 return min < max ? min : null;
102    }
103   
 
104  0 toggle @Override
105    public Number getMax()
106    {
107  0 return min < max ? max : null;
108    }
109    };
110    }
111   
 
112  0 toggle public static Builder newBuilder()
113    {
114  0 return new Builder();
115    }
116   
 
117  0 toggle public LogarithmicParameter(Builder builder)
118    {
119  0 super(builder);
120  0 this.min = builder.min;
121  0 this.max = builder.max;
122  0 if (defvalue != null)
123  0 defval = Double.parseDouble(defvalue);
124    else
125  0 defval = 0.0;
126    }
127   
 
128  0 toggle public LogarithmicParameter(LogarithmicParameter parm)
129    {
130  0 super(parm);
131  0 max = parm.max;
132  0 min = parm.min;
133  0 defval = 0D;
134    }
135   
 
136  0 toggle public LogarithmicParameter(String name, String description,
137    boolean required, Double defValue, double min, double max)
138    {
139  0 super(name, description, required, String.valueOf(defValue), null, null,
140    null);
141  0 defval = defValue;
142  0 this.min = min;
143  0 this.max = max;
144    }
145   
 
146  0 toggle public LogarithmicParameter(String name, String description,
147    boolean required, Double defValue, double value, double min,
148    double max)
149    {
150  0 super(name, description, required, String.valueOf(defValue),
151    String.valueOf(value), null, null);
152  0 defval = defValue;
153  0 this.min = min;
154  0 this.max = max;
155    }
156   
 
157  0 toggle @Override
158    public LogarithmicParameter copy()
159    {
160  0 return new LogarithmicParameter(this);
161    }
162    }