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