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 java.awt.event.MouseAdapter; |
24 |
|
import java.awt.event.MouseEvent; |
25 |
|
import java.beans.PropertyVetoException; |
26 |
|
import java.util.List; |
27 |
|
|
28 |
|
import javax.swing.JInternalFrame; |
29 |
|
import javax.swing.JLayeredPane; |
30 |
|
import javax.swing.event.ChangeEvent; |
31 |
|
import javax.swing.event.ChangeListener; |
32 |
|
import javax.swing.event.InternalFrameAdapter; |
33 |
|
import javax.swing.event.InternalFrameEvent; |
34 |
|
|
35 |
|
import jalview.analysis.Conservation; |
36 |
|
import jalview.datamodel.SequenceGroup; |
37 |
|
import jalview.jbgui.GSliderPanel; |
38 |
|
import jalview.renderer.ResidueShaderI; |
39 |
|
import jalview.util.MessageManager; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@author |
45 |
|
@version |
46 |
|
|
|
|
| 81.2% |
Uncovered Elements: 36 (192) |
Complexity: 54 |
Complexity Density: 0.44 |
|
47 |
|
public class SliderPanel extends GSliderPanel |
48 |
|
{ |
49 |
|
private static final String BACKGROUND = "Background"; |
50 |
|
|
51 |
|
static JInternalFrame conservationSlider; |
52 |
|
|
53 |
|
static JInternalFrame PIDSlider; |
54 |
|
|
55 |
|
AlignmentPanel ap; |
56 |
|
|
57 |
|
boolean forConservation = true; |
58 |
|
|
59 |
|
ResidueShaderI cs; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
@return |
65 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 5 |
Complexity Density: 1 |
|
66 |
19 |
public static SliderPanel getSliderPanel()... |
67 |
|
{ |
68 |
19 |
if (conservationSlider != null && conservationSlider.isVisible()) |
69 |
|
{ |
70 |
10 |
return (SliderPanel) conservationSlider.getContentPane(); |
71 |
|
} |
72 |
9 |
if (PIDSlider != null && PIDSlider.isVisible()) |
73 |
|
{ |
74 |
9 |
return (SliderPanel) PIDSlider.getContentPane(); |
75 |
|
} |
76 |
0 |
return null; |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
@param |
83 |
|
|
84 |
|
@param |
85 |
|
|
86 |
|
@param |
87 |
|
|
88 |
|
@param |
89 |
|
|
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 2 |
Complexity Density: 0.12 |
|
91 |
17 |
public SliderPanel(final AlignmentPanel ap, int value,... |
92 |
|
boolean forConserve, ResidueShaderI scheme) |
93 |
|
{ |
94 |
17 |
this.ap = ap; |
95 |
17 |
this.cs = scheme; |
96 |
17 |
forConservation = forConserve; |
97 |
17 |
undoButton.setVisible(false); |
98 |
17 |
applyButton.setVisible(false); |
99 |
|
|
100 |
17 |
if (forConservation) |
101 |
|
{ |
102 |
7 |
label.setText(MessageManager.getString( |
103 |
|
"label.enter_value_increase_conservation_visibility")); |
104 |
7 |
slider.setMinimum(0); |
105 |
7 |
slider.setMaximum(100); |
106 |
|
} |
107 |
|
else |
108 |
|
{ |
109 |
10 |
label.setText(MessageManager.getString( |
110 |
|
"label.enter_percentage_identity_above_which_colour_residues")); |
111 |
10 |
slider.setMinimum(0); |
112 |
10 |
slider.setMaximum(100); |
113 |
|
} |
114 |
|
|
115 |
17 |
slider.addChangeListener(new ChangeListener() |
116 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
117 |
17 |
@Override... |
118 |
|
public void stateChanged(ChangeEvent evt) |
119 |
|
{ |
120 |
17 |
valueField.setText(String.valueOf(slider.getValue())); |
121 |
17 |
valueChanged(slider.getValue()); |
122 |
|
} |
123 |
|
}); |
124 |
|
|
125 |
17 |
slider.addMouseListener(new MouseAdapter() |
126 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
0 |
@Override... |
128 |
|
public void mouseReleased(MouseEvent evt) |
129 |
|
{ |
130 |
0 |
ap.paintAlignment(true, true); |
131 |
|
} |
132 |
|
}); |
133 |
|
|
134 |
17 |
slider.setValue(value); |
135 |
17 |
valueField.setText(String.valueOf(value)); |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@param |
142 |
|
|
143 |
|
@param |
144 |
|
|
145 |
|
@param |
146 |
|
|
147 |
|
|
148 |
|
@return |
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 5 |
Complexity Density: 0.26 |
|
150 |
11 |
public static int setConservationSlider(AlignmentPanel ap,... |
151 |
|
ResidueShaderI rs, String source) |
152 |
|
{ |
153 |
11 |
SliderPanel sliderPanel = null; |
154 |
|
|
155 |
11 |
if (conservationSlider == null) |
156 |
|
{ |
157 |
7 |
sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs); |
158 |
7 |
conservationSlider = new JInternalFrame(); |
159 |
7 |
conservationSlider.setFrameIcon(null); |
160 |
7 |
conservationSlider.setContentPane(sliderPanel); |
161 |
7 |
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); |
162 |
|
} |
163 |
|
else |
164 |
|
{ |
165 |
4 |
sliderPanel = (SliderPanel) conservationSlider.getContentPane(); |
166 |
4 |
sliderPanel.valueField |
167 |
|
.setText(String.valueOf(rs.getConservationInc())); |
168 |
4 |
sliderPanel.cs = rs; |
169 |
4 |
sliderPanel.ap = ap; |
170 |
4 |
sliderPanel.slider.setValue(rs.getConservationInc()); |
171 |
|
} |
172 |
|
|
173 |
11 |
conservationSlider.setTitle(MessageManager.formatMessage( |
174 |
|
"label.conservation_colour_increment", new String[] |
175 |
11 |
{ source == null ? BACKGROUND : source })); |
176 |
|
|
177 |
11 |
List<SequenceGroup> groups = ap.av.getAlignment().getGroups(); |
178 |
11 |
if (groups != null && !groups.isEmpty()) |
179 |
|
{ |
180 |
6 |
sliderPanel.setAllGroupsCheckEnabled(true); |
181 |
6 |
sliderPanel.allGroupsCheck |
182 |
|
.setSelected(ap.av.getColourAppliesToAllGroups()); |
183 |
|
} |
184 |
|
else |
185 |
|
{ |
186 |
5 |
sliderPanel.setAllGroupsCheckEnabled(false); |
187 |
|
} |
188 |
|
|
189 |
11 |
return sliderPanel.getValue(); |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
195 |
170 |
public static void hidePIDSlider()... |
196 |
|
{ |
197 |
170 |
if (PIDSlider != null) |
198 |
|
{ |
199 |
8 |
try |
200 |
|
{ |
201 |
8 |
PIDSlider.setClosed(true); |
202 |
8 |
PIDSlider = null; |
203 |
|
} catch (PropertyVetoException ex) |
204 |
|
{ |
205 |
|
} |
206 |
|
} |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
212 |
169 |
public static void hideConservationSlider()... |
213 |
|
{ |
214 |
169 |
if (conservationSlider != null) |
215 |
|
{ |
216 |
6 |
try |
217 |
|
{ |
218 |
6 |
conservationSlider.setClosed(true); |
219 |
6 |
conservationSlider = null; |
220 |
|
} catch (PropertyVetoException ex) |
221 |
|
{ |
222 |
|
} |
223 |
|
} |
224 |
|
} |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
229 |
9 |
public static void showConservationSlider()... |
230 |
|
{ |
231 |
9 |
hidePIDSlider(); |
232 |
|
|
233 |
9 |
if (!conservationSlider.isVisible()) |
234 |
|
{ |
235 |
7 |
Desktop.addInternalFrame(conservationSlider, |
236 |
|
conservationSlider.getTitle(), true, FRAME_WIDTH, |
237 |
|
FRAME_HEIGHT, false, true); |
238 |
7 |
conservationSlider.addInternalFrameListener(new InternalFrameAdapter() |
239 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
240 |
7 |
@Override... |
241 |
|
public void internalFrameClosed(InternalFrameEvent e) |
242 |
|
{ |
243 |
7 |
conservationSlider = null; |
244 |
|
} |
245 |
|
}); |
246 |
7 |
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); |
247 |
|
} |
248 |
|
} |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
@param |
254 |
|
|
255 |
|
@param |
256 |
|
|
257 |
|
@param |
258 |
|
|
259 |
|
|
260 |
|
@return |
261 |
|
|
|
|
| 91.7% |
Uncovered Elements: 2 (24) |
Complexity: 4 |
Complexity Density: 0.22 |
|
262 |
11 |
public static int setPIDSliderSource(AlignmentPanel ap, ResidueShaderI rs,... |
263 |
|
String source) |
264 |
|
{ |
265 |
11 |
int threshold = rs.getThreshold(); |
266 |
|
|
267 |
11 |
SliderPanel sliderPanel = null; |
268 |
|
|
269 |
11 |
if (PIDSlider == null) |
270 |
|
{ |
271 |
10 |
sliderPanel = new SliderPanel(ap, threshold, false, rs); |
272 |
10 |
PIDSlider = new JInternalFrame(); |
273 |
10 |
PIDSlider.setFrameIcon(null); |
274 |
10 |
PIDSlider.setContentPane(sliderPanel); |
275 |
10 |
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); |
276 |
|
} |
277 |
|
else |
278 |
|
{ |
279 |
1 |
sliderPanel = (SliderPanel) PIDSlider.getContentPane(); |
280 |
1 |
sliderPanel.cs = rs; |
281 |
1 |
sliderPanel.ap = ap; |
282 |
1 |
sliderPanel.valueField.setText(String.valueOf(rs.getThreshold())); |
283 |
1 |
sliderPanel.slider.setValue(rs.getThreshold()); |
284 |
|
} |
285 |
|
|
286 |
11 |
PIDSlider.setTitle(MessageManager.formatMessage( |
287 |
|
"label.percentage_identity_threshold", new String[] |
288 |
11 |
{ source == null ? BACKGROUND : source })); |
289 |
|
|
290 |
11 |
if (ap.av.getAlignment().getGroups() != null) |
291 |
|
{ |
292 |
11 |
sliderPanel.setAllGroupsCheckEnabled(true); |
293 |
|
} |
294 |
|
else |
295 |
|
{ |
296 |
0 |
sliderPanel.setAllGroupsCheckEnabled(false); |
297 |
|
} |
298 |
|
|
299 |
11 |
return sliderPanel.getValue(); |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
@return |
306 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
307 |
9 |
public static JInternalFrame showPIDSlider()... |
308 |
|
{ |
309 |
9 |
hideConservationSlider(); |
310 |
|
|
311 |
9 |
if (!PIDSlider.isVisible()) |
312 |
|
{ |
313 |
9 |
Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), true, |
314 |
|
FRAME_WIDTH, FRAME_HEIGHT, false, true); |
315 |
9 |
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); |
316 |
9 |
PIDSlider.addInternalFrameListener(new InternalFrameAdapter() |
317 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
318 |
9 |
@Override... |
319 |
|
public void internalFrameClosed(InternalFrameEvent e) |
320 |
|
{ |
321 |
9 |
PIDSlider = null; |
322 |
|
} |
323 |
|
}); |
324 |
9 |
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); |
325 |
|
} |
326 |
9 |
return PIDSlider; |
327 |
|
} |
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
@param |
335 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
336 |
37 |
public void valueChanged(int percent)... |
337 |
|
{ |
338 |
37 |
if (!forConservation) |
339 |
|
{ |
340 |
21 |
ap.av.setThreshold(percent); |
341 |
|
} |
342 |
37 |
updateColourScheme(percent, cs, null); |
343 |
|
|
344 |
37 |
if (allGroupsCheck.isSelected()) |
345 |
|
{ |
346 |
2 |
List<SequenceGroup> groups = ap.av.getAlignment().getGroups(); |
347 |
2 |
for (SequenceGroup sg : groups) |
348 |
|
{ |
349 |
2 |
updateColourScheme(percent, sg.getGroupColourScheme(), sg); |
350 |
|
} |
351 |
|
} |
352 |
|
|
353 |
37 |
ap.getSeqPanel().seqCanvas.repaint(); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
@param |
361 |
|
@param |
362 |
|
@param |
363 |
|
|
|
|
| 58.8% |
Uncovered Elements: 7 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
364 |
39 |
protected void updateColourScheme(int percent, ResidueShaderI scheme,... |
365 |
|
SequenceGroup sg) |
366 |
|
{ |
367 |
39 |
if (scheme == null) |
368 |
|
{ |
369 |
0 |
return; |
370 |
|
} |
371 |
39 |
if (forConservation) |
372 |
|
{ |
373 |
18 |
if (!scheme.conservationApplied() && sg != null) |
374 |
|
{ |
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
0 |
Conservation c = new Conservation("Group", sg.getSequences(null), |
380 |
|
sg.getStartRes(), sg.getEndRes()); |
381 |
0 |
c.calculate(); |
382 |
0 |
c.verdict(false, ap.av.getConsPercGaps()); |
383 |
0 |
sg.cs.setConservation(c); |
384 |
|
|
385 |
|
} |
386 |
18 |
scheme.setConservationApplied(true); |
387 |
18 |
scheme.setConservationInc(percent); |
388 |
|
} |
389 |
|
else |
390 |
|
{ |
391 |
21 |
scheme.setThreshold(percent, ap.av.isIgnoreGapsConsensus()); |
392 |
|
} |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
@param |
399 |
|
|
400 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
401 |
22 |
public void setAllGroupsCheckEnabled(boolean b)... |
402 |
|
{ |
403 |
22 |
allGroupsCheck.setEnabled(b); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
@param |
410 |
|
|
411 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
412 |
0 |
@Override... |
413 |
|
public void valueField_actionPerformed() |
414 |
|
{ |
415 |
0 |
try |
416 |
|
{ |
417 |
0 |
int i = Integer.parseInt(valueField.getText()); |
418 |
0 |
slider.setValue(i); |
419 |
|
} catch (NumberFormatException ex) |
420 |
|
{ |
421 |
0 |
valueField.setText(slider.getValue() + ""); |
422 |
|
} |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
@param |
429 |
|
|
430 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
431 |
0 |
public void setValue(int value)... |
432 |
|
{ |
433 |
0 |
slider.setValue(value); |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
@return |
440 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
441 |
24 |
public int getValue()... |
442 |
|
{ |
443 |
24 |
return Integer.parseInt(valueField.getText()); |
444 |
|
} |
445 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
446 |
0 |
@Override... |
447 |
|
public void slider_mouseReleased(MouseEvent e) |
448 |
|
{ |
449 |
0 |
if (ap.overviewPanel != null) |
450 |
|
{ |
451 |
0 |
ap.overviewPanel.updateOverviewImage(); |
452 |
|
} |
453 |
|
} |
454 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
455 |
0 |
public static int getConservationValue()... |
456 |
|
{ |
457 |
0 |
return getValue(conservationSlider); |
458 |
|
} |
459 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
460 |
0 |
static int getValue(JInternalFrame slider)... |
461 |
|
{ |
462 |
0 |
return slider == null ? 0 |
463 |
|
: ((SliderPanel) slider.getContentPane()).getValue(); |
464 |
|
} |
465 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
466 |
0 |
public static int getPIDValue()... |
467 |
|
{ |
468 |
0 |
return getValue(PIDSlider); |
469 |
|
} |
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
@return |
476 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
477 |
24 |
public boolean isForConservation()... |
478 |
|
{ |
479 |
24 |
return forConservation; |
480 |
|
} |
481 |
|
|
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
@return |
487 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
488 |
6 |
public String getTitle()... |
489 |
|
{ |
490 |
6 |
String title = null; |
491 |
6 |
if (isForConservation()) |
492 |
|
{ |
493 |
4 |
if (conservationSlider != null) |
494 |
|
{ |
495 |
4 |
title = conservationSlider.getTitle(); |
496 |
|
} |
497 |
|
} |
498 |
2 |
else if (PIDSlider != null) |
499 |
|
{ |
500 |
2 |
title = PIDSlider.getTitle(); |
501 |
|
} |
502 |
6 |
return title; |
503 |
|
} |
504 |
|
} |