1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import javax.swing.JSlider; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@author |
34 |
|
|
35 |
|
@SuppressWarnings("serial") |
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0.47 |
|
36 |
|
public class Slider extends JSlider |
37 |
|
{ |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
private static final int SCALE_TICKS = 1000; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
private float trueMin; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
private float trueMax; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
private float sliderScaleFactor; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
@param |
65 |
|
@param |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
0 |
public Slider(float min, float max, float value)... |
68 |
|
{ |
69 |
0 |
super(); |
70 |
0 |
setSliderModel(min, max, value); |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
@param |
79 |
|
@param |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
81 |
0 |
public void setSliderModel(float min, float max, float value)... |
82 |
|
{ |
83 |
0 |
trueMin = min; |
84 |
0 |
trueMax = max; |
85 |
0 |
setMinimum(0); |
86 |
0 |
sliderScaleFactor = SCALE_TICKS / (max - min); |
87 |
0 |
int sliderMax = (int) ((max - min) * sliderScaleFactor); |
88 |
0 |
setMaximum(sliderMax); |
89 |
0 |
setSliderValue(value); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@return |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
97 |
0 |
public float getSliderValue()... |
98 |
|
{ |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
0 |
int value = getValue(); |
103 |
0 |
return value == getMaximum() ? trueMax |
104 |
|
: value / sliderScaleFactor + trueMin; |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
@param |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
public void setSliderValue(float value)... |
113 |
|
{ |
114 |
0 |
setValue(Math.round((value - trueMin) * sliderScaleFactor)); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
@return |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
public float getSliderPercentageValue()... |
124 |
|
{ |
125 |
0 |
return (getValue() - getMinimum()) * 100f |
126 |
|
/ (getMaximum() - getMinimum()); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@param |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
134 |
0 |
public void setSliderPercentageValue(float pct)... |
135 |
|
{ |
136 |
0 |
float pc = pct / 100f * getMaximum(); |
137 |
0 |
setValue((int) pc); |
138 |
|
} |
139 |
|
} |