Class |
Line # |
Actions |
|||
---|---|---|---|---|---|
GFontChooser | 47 | 103 | 21 |
1 | /* | |
2 | * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) | |
3 | * Copyright (C) $$Year-Rel$$ The Jalview Authors | |
4 | * | |
5 | * This file is part of Jalview. | |
6 | * | |
7 | * Jalview is free software: you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License | |
9 | * as published by the Free Software Foundation, either version 3 | |
10 | * of the License, or (at your option) any later version. | |
11 | * | |
12 | * Jalview is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty | |
14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
15 | * PURPOSE. See the GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Jalview. If not, see <http://www.gnu.org/licenses/>. | |
19 | * The Jalview Authors are detailed in the 'AUTHORS' file. | |
20 | */ | |
21 | package jalview.jbgui; | |
22 | ||
23 | import jalview.gui.JvSwingUtils; | |
24 | import jalview.util.MessageManager; | |
25 | ||
26 | import java.awt.BorderLayout; | |
27 | import java.awt.Color; | |
28 | import java.awt.Dimension; | |
29 | import java.awt.Font; | |
30 | import java.awt.Rectangle; | |
31 | import java.awt.event.ActionEvent; | |
32 | import java.awt.event.ActionListener; | |
33 | ||
34 | import javax.swing.JButton; | |
35 | import javax.swing.JCheckBox; | |
36 | import javax.swing.JComboBox; | |
37 | import javax.swing.JLabel; | |
38 | import javax.swing.JPanel; | |
39 | import javax.swing.SwingConstants; | |
40 | ||
41 | /** | |
42 | * DOCUMENT ME! | |
43 | * | |
44 | * @author $author$ | |
45 | * @version $Revision$ | |
46 | */ | |
47 | public class GFontChooser extends JPanel | |
48 | { | |
49 | private static final Font VERDANA_11PT = new java.awt.Font("Verdana", 0, | |
50 | 11); | |
51 | ||
52 | protected JComboBox<Integer> fontSize = new JComboBox<Integer>(); | |
53 | ||
54 | protected JComboBox<String> fontStyle = new JComboBox<String>(); | |
55 | ||
56 | protected JComboBox<String> fontName = new JComboBox<String>(); | |
57 | ||
58 | protected JButton defaultButton = new JButton(); | |
59 | ||
60 | protected JCheckBox smoothFont = new JCheckBox(); | |
61 | ||
62 | protected JCheckBox monospaced = new JCheckBox(); | |
63 | ||
64 | protected JCheckBox scaleAsCdna = new JCheckBox(); | |
65 | ||
66 | protected JCheckBox fontAsCdna = new JCheckBox(); | |
67 | ||
68 | /** | |
69 | * Creates a new GFontChooser object. | |
70 | */ | |
71 | 0 | public GFontChooser() |
72 | { | |
73 | 0 | try |
74 | { | |
75 | 0 | jbInit(); |
76 | } catch (Exception e) | |
77 | { | |
78 | 0 | e.printStackTrace(); |
79 | } | |
80 | } | |
81 | ||
82 | /** | |
83 | * DOCUMENT ME! | |
84 | * | |
85 | * @throws Exception | |
86 | * DOCUMENT ME! | |
87 | */ | |
88 | 0 | private void jbInit() throws Exception |
89 | { | |
90 | 0 | this.setLayout(null); |
91 | 0 | this.setBackground(Color.white); |
92 | ||
93 | 0 | JLabel fontLabel = new JLabel(MessageManager.getString("label.font")); |
94 | 0 | fontLabel.setFont(VERDANA_11PT); |
95 | 0 | fontLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
96 | 0 | fontLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); |
97 | ||
98 | 0 | fontSize.setFont(VERDANA_11PT); |
99 | 0 | fontSize.setOpaque(false); |
100 | 0 | fontSize.setPreferredSize(new Dimension(50, 21)); |
101 | 0 | fontSize.addActionListener(new java.awt.event.ActionListener() |
102 | { | |
103 | 0 | @Override |
104 | public void actionPerformed(ActionEvent e) | |
105 | { | |
106 | 0 | fontSize_actionPerformed(); |
107 | } | |
108 | }); | |
109 | ||
110 | 0 | fontStyle.setFont(VERDANA_11PT); |
111 | 0 | fontStyle.setOpaque(false); |
112 | 0 | fontStyle.setPreferredSize(new Dimension(90, 21)); |
113 | 0 | fontStyle.addActionListener(new java.awt.event.ActionListener() |
114 | { | |
115 | 0 | @Override |
116 | public void actionPerformed(ActionEvent e) | |
117 | { | |
118 | 0 | fontStyle_actionPerformed(); |
119 | } | |
120 | }); | |
121 | ||
122 | 0 | JLabel sizeLabel = new JLabel(MessageManager.getString("label.size")); |
123 | 0 | sizeLabel.setFont(VERDANA_11PT); |
124 | 0 | sizeLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
125 | 0 | sizeLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); |
126 | ||
127 | 0 | JLabel styleLabel = new JLabel(MessageManager.getString("label.style")); |
128 | 0 | styleLabel.setFont(VERDANA_11PT); |
129 | 0 | styleLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
130 | 0 | styleLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); |
131 | ||
132 | 0 | fontName.setFont(VERDANA_11PT); |
133 | 0 | fontName.setMaximumSize(new Dimension(32767, 32767)); |
134 | 0 | fontName.setMinimumSize(new Dimension(300, 21)); |
135 | 0 | fontName.setOpaque(false); |
136 | 0 | fontName.setPreferredSize(new Dimension(180, 21)); |
137 | 0 | fontName.addActionListener(new java.awt.event.ActionListener() |
138 | { | |
139 | 0 | @Override |
140 | public void actionPerformed(ActionEvent e) | |
141 | { | |
142 | 0 | fontName_actionPerformed(); |
143 | } | |
144 | }); | |
145 | ||
146 | 0 | JButton ok = new JButton(MessageManager.getString("action.ok")); |
147 | 0 | ok.setFont(VERDANA_11PT); |
148 | 0 | ok.addActionListener(new java.awt.event.ActionListener() |
149 | { | |
150 | 0 | @Override |
151 | public void actionPerformed(ActionEvent e) | |
152 | { | |
153 | 0 | ok_actionPerformed(); |
154 | } | |
155 | }); | |
156 | ||
157 | 0 | JButton cancel = new JButton(MessageManager.getString("action.cancel")); |
158 | 0 | cancel.setFont(VERDANA_11PT); |
159 | 0 | cancel.addActionListener(new java.awt.event.ActionListener() |
160 | { | |
161 | 0 | @Override |
162 | public void actionPerformed(ActionEvent e) | |
163 | { | |
164 | 0 | cancel_actionPerformed(); |
165 | } | |
166 | }); | |
167 | ||
168 | 0 | defaultButton.setFont(JvSwingUtils.getLabelFont()); |
169 | 0 | defaultButton.setText(MessageManager.getString("label.set_as_default")); |
170 | 0 | defaultButton.addActionListener(new ActionListener() |
171 | { | |
172 | 0 | @Override |
173 | public void actionPerformed(ActionEvent e) | |
174 | { | |
175 | 0 | defaultButton_actionPerformed(); |
176 | } | |
177 | }); | |
178 | ||
179 | 0 | smoothFont.setFont(JvSwingUtils.getLabelFont()); |
180 | 0 | smoothFont.setOpaque(false); |
181 | 0 | smoothFont.setText(MessageManager.getString("label.anti_alias_fonts")); |
182 | 0 | smoothFont.setBounds(new Rectangle(1, 65, 300, 23)); |
183 | 0 | smoothFont.addActionListener(new ActionListener() |
184 | { | |
185 | 0 | @Override |
186 | public void actionPerformed(ActionEvent e) | |
187 | { | |
188 | 0 | smoothFont_actionPerformed(); |
189 | } | |
190 | }); | |
191 | ||
192 | /* | |
193 | * Scale protein as cDNA is only visible in SplitFrame | |
194 | */ | |
195 | 0 | scaleAsCdna.setVisible(false); |
196 | 0 | scaleAsCdna.setFont(JvSwingUtils.getLabelFont()); |
197 | 0 | scaleAsCdna.setOpaque(false); |
198 | 0 | scaleAsCdna.setText(MessageManager.getString("label.scale_as_cdna")); |
199 | 0 | scaleAsCdna.setBounds(new Rectangle(1, 85, 300, 23)); |
200 | 0 | scaleAsCdna.addActionListener(new ActionListener() |
201 | { | |
202 | 0 | @Override |
203 | public void actionPerformed(ActionEvent e) | |
204 | { | |
205 | 0 | scaleAsCdna_actionPerformed(); |
206 | } | |
207 | }); | |
208 | ||
209 | /* | |
210 | * Same font for cDNA/peptide is only visible in SplitFrame | |
211 | */ | |
212 | 0 | fontAsCdna.setVisible(false); |
213 | 0 | fontAsCdna.setFont(JvSwingUtils.getLabelFont()); |
214 | 0 | fontAsCdna.setOpaque(false); |
215 | 0 | fontAsCdna.setText(MessageManager.getString("label.font_as_cdna")); |
216 | 0 | fontAsCdna.setBounds(new Rectangle(1, 105, 350, 23)); |
217 | 0 | fontAsCdna.addActionListener(new ActionListener() |
218 | { | |
219 | 0 | @Override |
220 | public void actionPerformed(ActionEvent e) | |
221 | { | |
222 | 0 | mirrorFonts_actionPerformed(); |
223 | } | |
224 | }); | |
225 | ||
226 | 0 | monospaced.setEnabled(false); |
227 | 0 | monospaced.setFont(JvSwingUtils.getLabelFont()); |
228 | 0 | monospaced.setOpaque(false); |
229 | 0 | monospaced.setToolTipText(MessageManager |
230 | .getString("label.monospaced_fonts_faster_to_render")); | |
231 | 0 | monospaced.setText(MessageManager.getString("label.monospaced_font")); |
232 | ||
233 | /* | |
234 | * jPanel1: Font dropdown, Monospaced checkbox | |
235 | */ | |
236 | 0 | JPanel jPanel1 = new JPanel(); |
237 | 0 | jPanel1.setOpaque(false); |
238 | 0 | jPanel1.setBounds(new Rectangle(5, 6, 308, 23)); |
239 | 0 | jPanel1.setLayout(new BorderLayout()); |
240 | 0 | jPanel1.add(fontLabel, BorderLayout.WEST); |
241 | 0 | jPanel1.add(fontName, BorderLayout.CENTER); |
242 | 0 | jPanel1.add(monospaced, java.awt.BorderLayout.EAST); |
243 | ||
244 | /* | |
245 | * jPanel2: font size dropdown | |
246 | */ | |
247 | 0 | JPanel jPanel2 = new JPanel(); |
248 | 0 | jPanel2.setOpaque(false); |
249 | 0 | jPanel2.setBounds(new Rectangle(5, 37, 128, 21)); |
250 | 0 | jPanel2.setLayout(new BorderLayout()); |
251 | 0 | jPanel2.add(fontSize, java.awt.BorderLayout.CENTER); |
252 | 0 | jPanel2.add(sizeLabel, java.awt.BorderLayout.WEST); |
253 | ||
254 | /* | |
255 | * jPanel3: font style dropdown | |
256 | */ | |
257 | 0 | JPanel jPanel3 = new JPanel(); |
258 | 0 | jPanel3.setOpaque(false); |
259 | 0 | jPanel3.setBounds(new Rectangle(174, 38, 134, 21)); |
260 | 0 | jPanel3.setLayout(new BorderLayout()); |
261 | 0 | jPanel3.add(styleLabel, java.awt.BorderLayout.WEST); |
262 | 0 | jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER); |
263 | ||
264 | /* | |
265 | * jPanel4: Default and OK buttons | |
266 | */ | |
267 | 0 | JPanel jPanel4 = new JPanel(); |
268 | 0 | jPanel4.setOpaque(false); |
269 | 0 | jPanel4.setBounds(new Rectangle(24, 132, 300, 35)); |
270 | 0 | jPanel4.add(defaultButton); |
271 | 0 | jPanel4.add(ok); |
272 | 0 | jPanel4.add(cancel); |
273 | ||
274 | 0 | this.add(smoothFont); |
275 | 0 | this.add(scaleAsCdna); |
276 | 0 | this.add(fontAsCdna); |
277 | 0 | this.add(jPanel3, null); |
278 | 0 | this.add(jPanel2, null); |
279 | 0 | this.add(jPanel4); |
280 | 0 | this.add(jPanel1, null); |
281 | } | |
282 | ||
283 | 0 | protected void mirrorFonts_actionPerformed() |
284 | { | |
285 | } | |
286 | ||
287 | 0 | protected void scaleAsCdna_actionPerformed() |
288 | { | |
289 | } | |
290 | ||
291 | 0 | protected void ok_actionPerformed() |
292 | { | |
293 | } | |
294 | ||
295 | 0 | protected void cancel_actionPerformed() |
296 | { | |
297 | } | |
298 | ||
299 | 0 | protected void fontName_actionPerformed() |
300 | { | |
301 | } | |
302 | ||
303 | 0 | protected void fontSize_actionPerformed() |
304 | { | |
305 | } | |
306 | ||
307 | 0 | protected void fontStyle_actionPerformed() |
308 | { | |
309 | } | |
310 | ||
311 | 0 | public void defaultButton_actionPerformed() |
312 | { | |
313 | } | |
314 | ||
315 | 0 | protected void smoothFont_actionPerformed() |
316 | { | |
317 | } | |
318 | } |