1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.jbgui; |
22 |
|
|
23 |
|
import jalview.util.MessageManager; |
24 |
|
|
25 |
|
import java.awt.BorderLayout; |
26 |
|
import java.awt.Color; |
27 |
|
import java.awt.Dimension; |
28 |
|
import java.awt.FlowLayout; |
29 |
|
import java.awt.Font; |
30 |
|
import java.awt.GridLayout; |
31 |
|
import java.awt.event.ActionEvent; |
32 |
|
import java.awt.event.ActionListener; |
33 |
|
import java.awt.event.FocusAdapter; |
34 |
|
import java.awt.event.FocusEvent; |
35 |
|
import java.awt.event.MouseAdapter; |
36 |
|
import java.awt.event.MouseEvent; |
37 |
|
|
38 |
|
import javax.swing.JButton; |
39 |
|
import javax.swing.JCheckBox; |
40 |
|
import javax.swing.JLabel; |
41 |
|
import javax.swing.JPanel; |
42 |
|
import javax.swing.JSlider; |
43 |
|
import javax.swing.JTextField; |
44 |
|
import javax.swing.SwingConstants; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@author |
50 |
|
@version |
51 |
|
|
|
|
| 73.2% |
Uncovered Elements: 19 (71) |
Complexity: 13 |
Complexity Density: 0.22 |
|
52 |
|
public class GSliderPanel extends JPanel |
53 |
|
{ |
54 |
|
private static final Font VERDANA_11 = new java.awt.Font("Verdana", 0, 11); |
55 |
|
|
56 |
|
protected static final int FRAME_WIDTH = 420; |
57 |
|
|
58 |
|
protected static final int FRAME_HEIGHT = 120; |
59 |
|
|
60 |
|
|
61 |
|
protected JSlider slider = new JSlider(); |
62 |
|
|
63 |
|
protected JTextField valueField = new JTextField(); |
64 |
|
|
65 |
|
protected JLabel label = new JLabel(); |
66 |
|
|
67 |
|
protected JPanel southPanel = new JPanel(); |
68 |
|
|
69 |
|
protected JButton applyButton = new JButton(); |
70 |
|
|
71 |
|
protected JButton undoButton = new JButton(); |
72 |
|
|
73 |
|
protected JCheckBox allGroupsCheck = new JCheckBox(); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
78 |
17 |
public GSliderPanel()... |
79 |
|
{ |
80 |
17 |
try |
81 |
|
{ |
82 |
17 |
jbInit(); |
83 |
|
} catch (Exception e) |
84 |
|
{ |
85 |
0 |
e.printStackTrace(); |
86 |
|
} |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (48) |
Complexity: 1 |
Complexity Density: 0.02 |
|
92 |
17 |
private void jbInit()... |
93 |
|
{ |
94 |
17 |
slider.setMajorTickSpacing(10); |
95 |
17 |
slider.setMinorTickSpacing(1); |
96 |
17 |
slider.setPaintTicks(true); |
97 |
17 |
slider.setBackground(Color.white); |
98 |
17 |
slider.setFont(VERDANA_11); |
99 |
17 |
slider.setDoubleBuffered(true); |
100 |
17 |
slider.addMouseListener(new MouseAdapter() |
101 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0 |
@Override... |
103 |
|
public void mouseReleased(MouseEvent e) |
104 |
|
{ |
105 |
0 |
slider_mouseReleased(e); |
106 |
|
} |
107 |
|
}); |
108 |
17 |
valueField.setFont(VERDANA_11); |
109 |
17 |
valueField.setMinimumSize(new Dimension(6, 14)); |
110 |
17 |
valueField.setPreferredSize(new Dimension(50, 12)); |
111 |
17 |
valueField.setText(""); |
112 |
17 |
valueField.setHorizontalAlignment(SwingConstants.CENTER); |
113 |
17 |
valueField.addActionListener(new ActionListener() |
114 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0 |
@Override... |
116 |
|
public void actionPerformed(ActionEvent e) |
117 |
|
{ |
118 |
0 |
valueField_actionPerformed(); |
119 |
|
} |
120 |
|
}); |
121 |
17 |
valueField.addFocusListener(new FocusAdapter() |
122 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
@Override... |
124 |
|
public void focusLost(FocusEvent e) |
125 |
|
{ |
126 |
0 |
valueField_actionPerformed(); |
127 |
|
} |
128 |
|
}); |
129 |
17 |
label.setFont(VERDANA_11); |
130 |
17 |
label.setOpaque(false); |
131 |
17 |
label.setHorizontalAlignment(SwingConstants.CENTER); |
132 |
17 |
label.setText(MessageManager.getString("label.set_this_label_text")); |
133 |
|
|
134 |
17 |
applyButton.setFont(VERDANA_11); |
135 |
17 |
applyButton.setOpaque(false); |
136 |
17 |
applyButton.setText(MessageManager.getString("action.apply")); |
137 |
17 |
applyButton.addActionListener(new ActionListener() |
138 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
0 |
@Override... |
140 |
|
public void actionPerformed(ActionEvent e) |
141 |
|
{ |
142 |
0 |
applyButton_actionPerformed(e); |
143 |
|
} |
144 |
|
}); |
145 |
17 |
undoButton.setEnabled(false); |
146 |
17 |
undoButton.setFont(VERDANA_11); |
147 |
17 |
undoButton.setOpaque(false); |
148 |
17 |
undoButton.setText(MessageManager.getString("action.undo")); |
149 |
17 |
undoButton.addActionListener(new ActionListener() |
150 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0 |
@Override... |
152 |
|
public void actionPerformed(ActionEvent e) |
153 |
|
{ |
154 |
0 |
undoButton_actionPerformed(e); |
155 |
|
} |
156 |
|
}); |
157 |
17 |
allGroupsCheck.setEnabled(false); |
158 |
17 |
allGroupsCheck.setFont(VERDANA_11); |
159 |
17 |
allGroupsCheck.setOpaque(false); |
160 |
17 |
allGroupsCheck |
161 |
|
.setText(MessageManager.getString("action.apply_all_groups")); |
162 |
|
|
163 |
17 |
this.setLayout(new GridLayout(2, 0)); |
164 |
17 |
this.setBackground(Color.white); |
165 |
|
|
166 |
17 |
JPanel firstRow = new JPanel(new FlowLayout()); |
167 |
17 |
firstRow.setOpaque(false); |
168 |
17 |
firstRow.add(label); |
169 |
17 |
firstRow.add(applyButton); |
170 |
17 |
firstRow.add(undoButton); |
171 |
17 |
this.add(firstRow); |
172 |
|
|
173 |
17 |
JPanel jPanel1 = new JPanel(new BorderLayout()); |
174 |
17 |
jPanel1.setOpaque(false); |
175 |
17 |
jPanel1.add(valueField, BorderLayout.CENTER); |
176 |
17 |
jPanel1.add(allGroupsCheck, BorderLayout.EAST); |
177 |
|
|
178 |
17 |
southPanel.setLayout(new BorderLayout()); |
179 |
17 |
southPanel.setOpaque(false); |
180 |
17 |
southPanel.add(jPanel1, BorderLayout.EAST); |
181 |
17 |
southPanel.add(slider, BorderLayout.CENTER); |
182 |
17 |
this.add(southPanel); |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
188 |
0 |
protected void valueField_actionPerformed()... |
189 |
|
{ |
190 |
0 |
try |
191 |
|
{ |
192 |
0 |
int i = Integer.valueOf(valueField.getText()); |
193 |
0 |
slider.setValue(i); |
194 |
|
} catch (NumberFormatException ex) |
195 |
|
{ |
196 |
0 |
valueField.setText(String.valueOf(slider.getValue())); |
197 |
|
} |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
|
205 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
206 |
0 |
protected void applyButton_actionPerformed(ActionEvent e)... |
207 |
|
{ |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
@param |
214 |
|
|
215 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
216 |
0 |
protected void undoButton_actionPerformed(ActionEvent e)... |
217 |
|
{ |
218 |
|
} |
219 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
220 |
0 |
public void slider_mouseReleased(MouseEvent e)... |
221 |
|
{ |
222 |
|
|
223 |
|
} |
224 |
|
} |