2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
23 import jalview.gui.JvSwingUtils;
24 import jalview.util.MessageManager;
26 import java.awt.BorderLayout;
27 import java.awt.Color;
28 import java.awt.Dimension;
30 import java.awt.Rectangle;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
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;
47 public class GFontChooser extends JPanel
49 private static final Font VERDANA_11PT = new java.awt.Font("Verdana", 0,
52 protected JComboBox<Integer> fontSize = new JComboBox<Integer>();
54 protected JComboBox<String> fontStyle = new JComboBox<String>();
56 protected JComboBox<String> fontName = new JComboBox<String>();
58 protected JButton defaultButton = new JButton();
60 protected JCheckBox smoothFont = new JCheckBox();
62 protected JCheckBox monospaced = new JCheckBox();
64 protected JCheckBox scaleAsCdna = new JCheckBox();
66 protected JCheckBox fontAsCdna = new JCheckBox();
69 * Creates a new GFontChooser object.
88 private void jbInit() throws Exception
91 this.setBackground(Color.white);
93 JLabel fontLabel = new JLabel(MessageManager.getString("label.font"));
94 fontLabel.setFont(VERDANA_11PT);
95 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
96 fontLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
98 fontSize.setFont(VERDANA_11PT);
99 fontSize.setOpaque(false);
100 fontSize.setPreferredSize(new Dimension(50, 21));
101 fontSize.addActionListener(new java.awt.event.ActionListener()
104 public void actionPerformed(ActionEvent e)
106 fontSize_actionPerformed();
110 fontStyle.setFont(VERDANA_11PT);
111 fontStyle.setOpaque(false);
112 fontStyle.setPreferredSize(new Dimension(90, 21));
113 fontStyle.addActionListener(new java.awt.event.ActionListener()
116 public void actionPerformed(ActionEvent e)
118 fontStyle_actionPerformed();
122 JLabel sizeLabel = new JLabel(MessageManager.getString("label.size"));
123 sizeLabel.setFont(VERDANA_11PT);
124 sizeLabel.setHorizontalAlignment(SwingConstants.RIGHT);
125 sizeLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
127 JLabel styleLabel = new JLabel(MessageManager.getString("label.style"));
128 styleLabel.setFont(VERDANA_11PT);
129 styleLabel.setHorizontalAlignment(SwingConstants.RIGHT);
130 styleLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
132 fontName.setFont(VERDANA_11PT);
133 fontName.setMaximumSize(new Dimension(32767, 32767));
134 fontName.setMinimumSize(new Dimension(300, 21));
135 fontName.setOpaque(false);
136 fontName.setPreferredSize(new Dimension(180, 21));
137 fontName.addActionListener(new java.awt.event.ActionListener()
140 public void actionPerformed(ActionEvent e)
142 fontName_actionPerformed();
146 JButton ok = new JButton(MessageManager.getString("action.ok"));
147 ok.setFont(VERDANA_11PT);
148 ok.addActionListener(new java.awt.event.ActionListener()
151 public void actionPerformed(ActionEvent e)
153 ok_actionPerformed();
157 JButton cancel = new JButton(MessageManager.getString("action.cancel"));
158 cancel.setFont(VERDANA_11PT);
159 cancel.addActionListener(new java.awt.event.ActionListener()
162 public void actionPerformed(ActionEvent e)
164 cancel_actionPerformed();
168 defaultButton.setFont(JvSwingUtils.getLabelFont());
169 defaultButton.setText(MessageManager.getString("label.set_as_default"));
170 defaultButton.addActionListener(new ActionListener()
173 public void actionPerformed(ActionEvent e)
175 defaultButton_actionPerformed();
179 smoothFont.setFont(JvSwingUtils.getLabelFont());
180 smoothFont.setOpaque(false);
181 smoothFont.setText(MessageManager.getString("label.anti_alias_fonts"));
182 smoothFont.setBounds(new Rectangle(1, 65, 300, 23));
183 smoothFont.addActionListener(new ActionListener()
186 public void actionPerformed(ActionEvent e)
188 smoothFont_actionPerformed();
193 * Scale protein as cDNA is only visible in SplitFrame
195 scaleAsCdna.setVisible(false);
196 scaleAsCdna.setFont(JvSwingUtils.getLabelFont());
197 scaleAsCdna.setOpaque(false);
198 scaleAsCdna.setText(MessageManager.getString("label.scale_as_cdna"));
199 scaleAsCdna.setBounds(new Rectangle(1, 85, 300, 23));
200 scaleAsCdna.addActionListener(new ActionListener()
203 public void actionPerformed(ActionEvent e)
205 scaleAsCdna_actionPerformed();
210 * Same font for cDNA/peptide is only visible in SplitFrame
212 fontAsCdna.setVisible(false);
213 fontAsCdna.setFont(JvSwingUtils.getLabelFont());
214 fontAsCdna.setOpaque(false);
215 fontAsCdna.setText(MessageManager.getString("label.font_as_cdna"));
216 fontAsCdna.setBounds(new Rectangle(1, 105, 350, 23));
217 fontAsCdna.addActionListener(new ActionListener()
220 public void actionPerformed(ActionEvent e)
222 mirrorFonts_actionPerformed();
226 monospaced.setEnabled(false);
227 monospaced.setFont(JvSwingUtils.getLabelFont());
228 monospaced.setOpaque(false);
229 monospaced.setToolTipText(MessageManager
230 .getString("label.monospaced_fonts_faster_to_render"));
231 monospaced.setText(MessageManager.getString("label.monospaced_font"));
234 * jPanel1: Font dropdown, Monospaced checkbox
236 JPanel jPanel1 = new JPanel();
237 jPanel1.setOpaque(false);
238 jPanel1.setBounds(new Rectangle(5, 6, 308, 23));
239 jPanel1.setLayout(new BorderLayout());
240 jPanel1.add(fontLabel, BorderLayout.WEST);
241 jPanel1.add(fontName, BorderLayout.CENTER);
242 jPanel1.add(monospaced, java.awt.BorderLayout.EAST);
245 * jPanel2: font size dropdown
247 JPanel jPanel2 = new JPanel();
248 jPanel2.setOpaque(false);
249 jPanel2.setBounds(new Rectangle(5, 37, 128, 21));
250 jPanel2.setLayout(new BorderLayout());
251 jPanel2.add(fontSize, java.awt.BorderLayout.CENTER);
252 jPanel2.add(sizeLabel, java.awt.BorderLayout.WEST);
255 * jPanel3: font style dropdown
257 JPanel jPanel3 = new JPanel();
258 jPanel3.setOpaque(false);
259 jPanel3.setBounds(new Rectangle(174, 38, 134, 21));
260 jPanel3.setLayout(new BorderLayout());
261 jPanel3.add(styleLabel, java.awt.BorderLayout.WEST);
262 jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER);
265 * jPanel4: Default and OK buttons
267 JPanel jPanel4 = new JPanel();
268 jPanel4.setOpaque(false);
269 jPanel4.setBounds(new Rectangle(24, 132, 300, 35));
270 jPanel4.add(defaultButton);
274 this.add(smoothFont);
275 this.add(scaleAsCdna);
276 this.add(fontAsCdna);
277 this.add(jPanel3, null);
278 this.add(jPanel2, null);
280 this.add(jPanel1, null);
283 protected void mirrorFonts_actionPerformed()
287 protected void scaleAsCdna_actionPerformed()
291 protected void ok_actionPerformed()
295 protected void cancel_actionPerformed()
299 protected void fontName_actionPerformed()
303 protected void fontSize_actionPerformed()
307 protected void fontStyle_actionPerformed()
311 public void defaultButton_actionPerformed()
315 protected void smoothFont_actionPerformed()