1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.appletgui; |
22 |
|
|
23 |
|
import jalview.analysis.Conservation; |
24 |
|
import jalview.datamodel.SequenceGroup; |
25 |
|
import jalview.renderer.ResidueShaderI; |
26 |
|
import jalview.util.MessageManager; |
27 |
|
|
28 |
|
import java.awt.BorderLayout; |
29 |
|
import java.awt.Button; |
30 |
|
import java.awt.Checkbox; |
31 |
|
import java.awt.Color; |
32 |
|
import java.awt.FlowLayout; |
33 |
|
import java.awt.Frame; |
34 |
|
import java.awt.Label; |
35 |
|
import java.awt.Panel; |
36 |
|
import java.awt.Scrollbar; |
37 |
|
import java.awt.TextField; |
38 |
|
import java.awt.event.ActionEvent; |
39 |
|
import java.awt.event.ActionListener; |
40 |
|
import java.awt.event.AdjustmentEvent; |
41 |
|
import java.awt.event.AdjustmentListener; |
42 |
|
import java.awt.event.FocusAdapter; |
43 |
|
import java.awt.event.FocusEvent; |
44 |
|
import java.awt.event.MouseEvent; |
45 |
|
import java.awt.event.MouseListener; |
46 |
|
import java.awt.event.WindowAdapter; |
47 |
|
import java.awt.event.WindowEvent; |
48 |
|
import java.util.List; |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 203 (203) |
Complexity: 49 |
Complexity Density: 0.35 |
|
50 |
|
public class SliderPanel extends Panel |
51 |
|
implements ActionListener, AdjustmentListener, MouseListener |
52 |
|
{ |
53 |
|
private static final String BACKGROUND = "Background"; |
54 |
|
|
55 |
|
AlignmentPanel ap; |
56 |
|
|
57 |
|
boolean forConservation = true; |
58 |
|
|
59 |
|
ResidueShaderI cs; |
60 |
|
|
61 |
|
static Frame conservationSlider; |
62 |
|
|
63 |
|
static Frame PIDSlider; |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
65 |
0 |
public static int setConservationSlider(AlignmentPanel ap,... |
66 |
|
ResidueShaderI ccs, String source) |
67 |
|
{ |
68 |
0 |
SliderPanel sp = null; |
69 |
|
|
70 |
0 |
if (conservationSlider == null) |
71 |
|
{ |
72 |
0 |
sp = new SliderPanel(ap, ccs.getConservationInc(), true, ccs); |
73 |
0 |
conservationSlider = new Frame(); |
74 |
0 |
conservationSlider.add(sp); |
75 |
|
} |
76 |
|
else |
77 |
|
{ |
78 |
0 |
sp = (SliderPanel) conservationSlider.getComponent(0); |
79 |
0 |
sp.cs = ccs; |
80 |
0 |
sp.valueField.setText(String.valueOf(ccs.getConservationInc())); |
81 |
|
} |
82 |
|
|
83 |
0 |
conservationSlider.setTitle(MessageManager.formatMessage( |
84 |
|
"label.conservation_colour_increment", new String[] |
85 |
0 |
{ source == null ? BACKGROUND : source })); |
86 |
0 |
List<SequenceGroup> groups = ap.av.getAlignment().getGroups(); |
87 |
0 |
if (groups != null && !groups.isEmpty()) |
88 |
|
{ |
89 |
0 |
sp.setAllGroupsCheckEnabled(true); |
90 |
|
} |
91 |
|
else |
92 |
|
{ |
93 |
0 |
sp.setAllGroupsCheckEnabled(false); |
94 |
|
} |
95 |
|
|
96 |
0 |
return sp.getValue(); |
97 |
|
} |
98 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
99 |
0 |
public static void showConservationSlider()... |
100 |
|
{ |
101 |
0 |
try |
102 |
|
{ |
103 |
0 |
PIDSlider.setVisible(false); |
104 |
0 |
PIDSlider = null; |
105 |
|
} catch (Exception ex) |
106 |
|
{ |
107 |
|
} |
108 |
|
|
109 |
0 |
if (!conservationSlider.isVisible()) |
110 |
|
{ |
111 |
0 |
jalview.bin.JalviewLite.addFrame(conservationSlider, |
112 |
|
conservationSlider.getTitle(), 420, 100); |
113 |
0 |
conservationSlider.addWindowListener(new WindowAdapter() |
114 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0 |
@Override... |
116 |
|
public void windowClosing(WindowEvent e) |
117 |
|
{ |
118 |
0 |
conservationSlider = null; |
119 |
|
} |
120 |
|
}); |
121 |
|
|
122 |
|
} |
123 |
|
|
124 |
|
} |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
126 |
0 |
public static int setPIDSliderSource(AlignmentPanel ap,... |
127 |
|
ResidueShaderI ccs, String source) |
128 |
|
{ |
129 |
0 |
SliderPanel pid = null; |
130 |
0 |
if (PIDSlider == null) |
131 |
|
{ |
132 |
0 |
pid = new SliderPanel(ap, ccs.getThreshold(), false, ccs); |
133 |
0 |
PIDSlider = new Frame(); |
134 |
0 |
PIDSlider.add(pid); |
135 |
|
} |
136 |
|
else |
137 |
|
{ |
138 |
0 |
pid = (SliderPanel) PIDSlider.getComponent(0); |
139 |
0 |
pid.cs = ccs; |
140 |
0 |
pid.valueField.setText(String.valueOf(ccs.getThreshold())); |
141 |
|
} |
142 |
0 |
PIDSlider.setTitle(MessageManager.formatMessage( |
143 |
|
"label.percentage_identity_threshold", new String[] |
144 |
0 |
{ source == null ? BACKGROUND : source })); |
145 |
|
|
146 |
0 |
if (ap.av.getAlignment().getGroups() != null) |
147 |
|
{ |
148 |
0 |
pid.setAllGroupsCheckEnabled(true); |
149 |
|
} |
150 |
|
else |
151 |
|
{ |
152 |
0 |
pid.setAllGroupsCheckEnabled(false); |
153 |
|
} |
154 |
|
|
155 |
0 |
return pid.getValue(); |
156 |
|
|
157 |
|
} |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
159 |
0 |
public static void showPIDSlider()... |
160 |
|
{ |
161 |
0 |
try |
162 |
|
{ |
163 |
0 |
conservationSlider.setVisible(false); |
164 |
0 |
conservationSlider = null; |
165 |
|
} catch (Exception ex) |
166 |
|
{ |
167 |
|
} |
168 |
|
|
169 |
0 |
if (!PIDSlider.isVisible()) |
170 |
|
{ |
171 |
0 |
jalview.bin.JalviewLite.addFrame(PIDSlider, PIDSlider.getTitle(), 420, |
172 |
|
100); |
173 |
0 |
PIDSlider.addWindowListener(new WindowAdapter() |
174 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
175 |
0 |
@Override... |
176 |
|
public void windowClosing(WindowEvent e) |
177 |
|
{ |
178 |
0 |
PIDSlider = null; |
179 |
|
} |
180 |
|
}); |
181 |
|
} |
182 |
|
|
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
188 |
0 |
public static void hidePIDSlider()... |
189 |
|
{ |
190 |
0 |
if (PIDSlider != null) |
191 |
|
{ |
192 |
0 |
PIDSlider.setVisible(false); |
193 |
0 |
PIDSlider = null; |
194 |
|
} |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
200 |
0 |
public static void hideConservationSlider()... |
201 |
|
{ |
202 |
0 |
if (conservationSlider != null) |
203 |
|
{ |
204 |
0 |
conservationSlider.setVisible(false); |
205 |
0 |
conservationSlider = null; |
206 |
|
} |
207 |
|
} |
208 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 3 |
Complexity Density: 0.14 |
|
209 |
0 |
public SliderPanel(AlignmentPanel ap, int value, boolean forConserve,... |
210 |
|
ResidueShaderI shader) |
211 |
|
{ |
212 |
0 |
try |
213 |
|
{ |
214 |
0 |
jbInit(); |
215 |
|
} catch (Exception e) |
216 |
|
{ |
217 |
0 |
e.printStackTrace(); |
218 |
|
} |
219 |
0 |
this.ap = ap; |
220 |
0 |
this.cs = shader; |
221 |
0 |
forConservation = forConserve; |
222 |
0 |
undoButton.setVisible(false); |
223 |
0 |
applyButton.setVisible(false); |
224 |
0 |
if (forConservation) |
225 |
|
{ |
226 |
0 |
label.setText(MessageManager |
227 |
|
.getString("label.modify_conservation_visibility")); |
228 |
0 |
slider.setMinimum(0); |
229 |
0 |
slider.setMaximum(50 + slider.getVisibleAmount()); |
230 |
0 |
slider.setUnitIncrement(1); |
231 |
|
} |
232 |
|
else |
233 |
|
{ |
234 |
0 |
label.setText(MessageManager |
235 |
|
.getString("label.colour_residues_above_occurrence")); |
236 |
0 |
slider.setMinimum(0); |
237 |
0 |
slider.setMaximum(100 + slider.getVisibleAmount()); |
238 |
0 |
slider.setBlockIncrement(1); |
239 |
|
} |
240 |
|
|
241 |
0 |
slider.addAdjustmentListener(this); |
242 |
0 |
slider.addMouseListener(this); |
243 |
|
|
244 |
0 |
slider.setValue(value); |
245 |
0 |
valueField.setText(value + ""); |
246 |
|
} |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 6 |
Complexity Density: 0.32 |
|
248 |
0 |
public void valueChanged(int i)... |
249 |
|
{ |
250 |
0 |
if (cs == null) |
251 |
|
{ |
252 |
0 |
return; |
253 |
|
} |
254 |
0 |
if (forConservation) |
255 |
|
{ |
256 |
0 |
cs.setConservationApplied(true); |
257 |
0 |
cs.setConservationInc(i); |
258 |
|
} |
259 |
|
else |
260 |
|
{ |
261 |
0 |
cs.setThreshold(i, ap.av.isIgnoreGapsConsensus()); |
262 |
|
} |
263 |
|
|
264 |
0 |
if (allGroupsCheck.getState()) |
265 |
|
{ |
266 |
0 |
for (SequenceGroup group : ap.av.getAlignment().getGroups()) |
267 |
|
{ |
268 |
0 |
ResidueShaderI groupColourScheme = group.getGroupColourScheme(); |
269 |
0 |
if (forConservation) |
270 |
|
{ |
271 |
0 |
if (!groupColourScheme.conservationApplied()) |
272 |
|
{ |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
0 |
Conservation c = new Conservation("Group", |
278 |
|
group.getSequences(null), group.getStartRes(), |
279 |
|
group.getEndRes()); |
280 |
0 |
c.calculate(); |
281 |
0 |
c.verdict(false, ap.av.getConsPercGaps()); |
282 |
0 |
group.cs.setConservation(c); |
283 |
|
|
284 |
|
} |
285 |
0 |
groupColourScheme.setConservationApplied(true); |
286 |
0 |
groupColourScheme.setConservationInc(i); |
287 |
|
} |
288 |
|
else |
289 |
|
{ |
290 |
0 |
groupColourScheme.setThreshold(i, ap.av.isIgnoreGapsConsensus()); |
291 |
|
} |
292 |
|
} |
293 |
|
} |
294 |
|
|
295 |
0 |
ap.seqPanel.seqCanvas.repaint(); |
296 |
|
} |
297 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
298 |
0 |
public void setAllGroupsCheckEnabled(boolean b)... |
299 |
|
{ |
300 |
0 |
allGroupsCheck.setState(ap.av.getColourAppliesToAllGroups()); |
301 |
0 |
allGroupsCheck.setEnabled(b); |
302 |
|
} |
303 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
304 |
0 |
@Override... |
305 |
|
public void actionPerformed(ActionEvent evt) |
306 |
|
{ |
307 |
0 |
if (evt.getSource() == applyButton) |
308 |
|
{ |
309 |
0 |
applyButton_actionPerformed(); |
310 |
|
} |
311 |
0 |
else if (evt.getSource() == undoButton) |
312 |
|
{ |
313 |
0 |
undoButton_actionPerformed(); |
314 |
|
} |
315 |
0 |
else if (evt.getSource() == valueField) |
316 |
|
{ |
317 |
0 |
valueField_actionPerformed(); |
318 |
|
} |
319 |
|
} |
320 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
321 |
0 |
@Override... |
322 |
|
public void adjustmentValueChanged(AdjustmentEvent evt) |
323 |
|
{ |
324 |
0 |
valueField.setText(slider.getValue() + ""); |
325 |
0 |
valueChanged(slider.getValue()); |
326 |
|
} |
327 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
328 |
0 |
public void valueField_actionPerformed()... |
329 |
|
{ |
330 |
0 |
try |
331 |
|
{ |
332 |
0 |
int i = Integer.valueOf(valueField.getText()); |
333 |
0 |
slider.setValue(i); |
334 |
|
} catch (NumberFormatException ex) |
335 |
|
{ |
336 |
0 |
valueField.setText(String.valueOf(slider.getValue())); |
337 |
|
} |
338 |
|
} |
339 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
340 |
0 |
public void setValue(int value)... |
341 |
|
{ |
342 |
0 |
slider.setValue(value); |
343 |
|
} |
344 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
345 |
0 |
public int getValue()... |
346 |
|
{ |
347 |
0 |
return Integer.parseInt(valueField.getText()); |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
|
protected Scrollbar slider = new Scrollbar(); |
352 |
|
|
353 |
|
protected TextField valueField = new TextField(); |
354 |
|
|
355 |
|
protected Label label = new Label(); |
356 |
|
|
357 |
|
Panel jPanel1 = new Panel(); |
358 |
|
|
359 |
|
Panel jPanel2 = new Panel(); |
360 |
|
|
361 |
|
protected Button applyButton = new Button(); |
362 |
|
|
363 |
|
protected Button undoButton = new Button(); |
364 |
|
|
365 |
|
FlowLayout flowLayout1 = new FlowLayout(); |
366 |
|
|
367 |
|
protected Checkbox allGroupsCheck = new Checkbox(); |
368 |
|
|
369 |
|
BorderLayout borderLayout1 = new BorderLayout(); |
370 |
|
|
371 |
|
BorderLayout borderLayout2 = new BorderLayout(); |
372 |
|
|
373 |
|
FlowLayout flowLayout2 = new FlowLayout(); |
374 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
|
375 |
0 |
private void jbInit() throws Exception... |
376 |
|
{ |
377 |
0 |
this.setLayout(borderLayout2); |
378 |
|
|
379 |
|
|
380 |
|
|
381 |
|
|
382 |
0 |
slider.setBackground(Color.white); |
383 |
0 |
slider.setFont(new java.awt.Font("Verdana", 0, 11)); |
384 |
0 |
slider.setOrientation(0); |
385 |
0 |
valueField.setFont(new java.awt.Font("Verdana", 0, 11)); |
386 |
0 |
valueField.setText(" "); |
387 |
0 |
valueField.addActionListener(this); |
388 |
0 |
valueField.setColumns(3); |
389 |
0 |
valueField.addFocusListener(new FocusAdapter() |
390 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
391 |
0 |
@Override... |
392 |
|
public void focusLost(FocusEvent e) |
393 |
|
{ |
394 |
0 |
valueField_actionPerformed(); |
395 |
0 |
valueChanged(slider.getValue()); |
396 |
|
} |
397 |
|
}); |
398 |
|
|
399 |
0 |
label.setFont(new java.awt.Font("Verdana", 0, 11)); |
400 |
0 |
label.setText(MessageManager.getString("label.set_this_label_text")); |
401 |
0 |
jPanel1.setLayout(borderLayout1); |
402 |
0 |
jPanel2.setLayout(flowLayout1); |
403 |
0 |
applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); |
404 |
0 |
applyButton.setLabel(MessageManager.getString("action.apply")); |
405 |
0 |
applyButton.addActionListener(this); |
406 |
0 |
undoButton.setEnabled(false); |
407 |
0 |
undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); |
408 |
0 |
undoButton.setLabel(MessageManager.getString("action.undo")); |
409 |
0 |
undoButton.addActionListener(this); |
410 |
0 |
allGroupsCheck.setEnabled(false); |
411 |
0 |
allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); |
412 |
0 |
allGroupsCheck.setLabel( |
413 |
|
MessageManager.getString("action.apply_threshold_all_groups")); |
414 |
0 |
allGroupsCheck |
415 |
|
.setName(MessageManager.getString("action.apply_all_groups")); |
416 |
0 |
this.setBackground(Color.white); |
417 |
0 |
this.setForeground(Color.black); |
418 |
0 |
jPanel2.add(label, null); |
419 |
0 |
jPanel2.add(applyButton, null); |
420 |
0 |
jPanel2.add(undoButton, null); |
421 |
0 |
jPanel2.add(allGroupsCheck); |
422 |
0 |
jPanel1.add(valueField, java.awt.BorderLayout.EAST); |
423 |
0 |
jPanel1.add(slider, java.awt.BorderLayout.CENTER); |
424 |
0 |
this.add(jPanel1, java.awt.BorderLayout.SOUTH); |
425 |
0 |
this.add(jPanel2, java.awt.BorderLayout.CENTER); |
426 |
|
} |
427 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
428 |
0 |
protected void applyButton_actionPerformed()... |
429 |
|
{ |
430 |
|
} |
431 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
432 |
0 |
protected void undoButton_actionPerformed()... |
433 |
|
{ |
434 |
|
} |
435 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
436 |
0 |
@Override... |
437 |
|
public void mousePressed(MouseEvent evt) |
438 |
|
{ |
439 |
|
} |
440 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
441 |
0 |
@Override... |
442 |
|
public void mouseReleased(MouseEvent evt) |
443 |
|
{ |
444 |
0 |
ap.paintAlignment(true, true); |
445 |
|
} |
446 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
447 |
0 |
@Override... |
448 |
|
public void mouseClicked(MouseEvent evt) |
449 |
|
{ |
450 |
|
} |
451 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
452 |
0 |
@Override... |
453 |
|
public void mouseEntered(MouseEvent evt) |
454 |
|
{ |
455 |
|
} |
456 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
457 |
0 |
@Override... |
458 |
|
public void mouseExited(MouseEvent evt) |
459 |
|
{ |
460 |
|
} |
461 |
|
} |