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.Color; |
24 |
|
import java.awt.Component; |
25 |
|
import java.awt.event.ActionListener; |
26 |
|
|
27 |
|
import javax.swing.JColorChooser; |
28 |
|
import javax.swing.JComponent; |
29 |
|
import javax.swing.JDialog; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.36 |
|
35 |
|
public class JalviewColourChooser |
36 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: - |
|
37 |
|
public interface ColourChooserListener |
38 |
|
{ |
39 |
|
void colourSelected(Color c); |
40 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
41 |
0 |
default void cancel()... |
42 |
|
{ |
43 |
|
}; |
44 |
|
} |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
@param |
53 |
|
@param |
54 |
|
@param |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
56 |
0 |
public static void showColourChooser(Component parent, String title,... |
57 |
|
Color initialColour, ColourChooserListener listener) |
58 |
|
{ |
59 |
0 |
JColorChooser colorChooser = new JColorChooser(); |
60 |
0 |
if (initialColour != null) |
61 |
|
{ |
62 |
0 |
colorChooser.setColor(initialColour); |
63 |
|
} |
64 |
0 |
ActionListener onChoose = evt -> listener |
65 |
|
.colourSelected(colorChooser.getColor()); |
66 |
0 |
ActionListener onCancel = evt -> listener.cancel(); |
67 |
0 |
JDialog dialog = JColorChooser.createDialog(parent, title, true, |
68 |
|
colorChooser, onChoose, onCancel); |
69 |
0 |
dialog.setVisible(true); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
@param |
79 |
|
@param |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
81 |
0 |
public static void showColourChooser(Component parent, String title,... |
82 |
|
JComponent paintable) |
83 |
|
{ |
84 |
0 |
ColourChooserListener listener = new ColourChooserListener() |
85 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
86 |
0 |
@Override... |
87 |
|
public void colourSelected(Color c) |
88 |
|
{ |
89 |
0 |
paintable.setBackground(c); |
90 |
0 |
paintable.repaint(); |
91 |
|
} |
92 |
|
}; |
93 |
0 |
JalviewColourChooser.showColourChooser(parent, title, |
94 |
|
paintable.getBackground(), listener); |
95 |
|
} |
96 |
|
} |