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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Dimension;
27 import java.awt.Rectangle;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
31 import javax.swing.JButton;
32 import javax.swing.JCheckBox;
33 import javax.swing.JComboBox;
34 import javax.swing.JLabel;
35 import javax.swing.JPanel;
36 import javax.swing.SwingConstants;
38 import jalview.gui.JvSwingUtils;
39 import jalview.util.MessageManager;
47 public class GFontChooser extends JPanel
49 private static final Font VERDANA_11PT = new java.awt.Font("Verdana", 0, 11);
51 protected JComboBox<Integer> fontSize = new JComboBox<Integer>();
53 protected JComboBox<String> fontStyle = new JComboBox<String>();
55 protected JComboBox<String> fontName = new JComboBox<String>();
57 protected JButton defaultButton = new JButton();
59 protected JCheckBox smoothFont = new JCheckBox();
61 protected JCheckBox monospaced = new JCheckBox();
63 protected JCheckBox scaleAsCdna = new JCheckBox();
66 * Creates a new GFontChooser object.
85 private void jbInit() throws Exception
88 this.setBackground(Color.white);
90 JLabel fontLabel = new JLabel(MessageManager.getString("label.font"));
91 fontLabel.setFont(VERDANA_11PT);
92 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
93 fontLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
95 fontSize.setFont(VERDANA_11PT);
96 fontSize.setOpaque(false);
97 fontSize.setPreferredSize(new Dimension(50, 21));
98 fontSize.addActionListener(new java.awt.event.ActionListener()
100 public void actionPerformed(ActionEvent e)
102 fontSize_actionPerformed(e);
106 fontStyle.setFont(VERDANA_11PT);
107 fontStyle.setOpaque(false);
108 fontStyle.setPreferredSize(new Dimension(90, 21));
109 fontStyle.addActionListener(new java.awt.event.ActionListener()
111 public void actionPerformed(ActionEvent e)
113 fontStyle_actionPerformed(e);
117 JLabel sizeLabel = new JLabel(MessageManager.getString("label.size"));
118 sizeLabel.setFont(VERDANA_11PT);
119 sizeLabel.setHorizontalAlignment(SwingConstants.RIGHT);
120 sizeLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
122 JLabel styleLabel = new JLabel(MessageManager.getString("label.style"));
123 styleLabel.setFont(VERDANA_11PT);
124 styleLabel.setHorizontalAlignment(SwingConstants.RIGHT);
125 styleLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
127 fontName.setFont(VERDANA_11PT);
128 fontName.setMaximumSize(new Dimension(32767, 32767));
129 fontName.setMinimumSize(new Dimension(300, 21));
130 fontName.setOpaque(false);
131 fontName.setPreferredSize(new Dimension(180, 21));
132 fontName.addActionListener(new java.awt.event.ActionListener()
134 public void actionPerformed(ActionEvent e)
136 fontName_actionPerformed(e);
140 JButton ok = new JButton(MessageManager.getString("action.ok"));
141 ok.setFont(VERDANA_11PT);
142 ok.addActionListener(new java.awt.event.ActionListener()
144 public void actionPerformed(ActionEvent e)
146 ok_actionPerformed(e);
150 JButton cancel = new JButton(MessageManager.getString("action.cancel"));
151 cancel.setFont(VERDANA_11PT);
152 cancel.addActionListener(new java.awt.event.ActionListener()
154 public void actionPerformed(ActionEvent e)
156 cancel_actionPerformed(e);
160 defaultButton.setFont(JvSwingUtils.getLabelFont());
161 defaultButton.setText(MessageManager.getString("label.set_as_default"));
162 defaultButton.addActionListener(new ActionListener()
164 public void actionPerformed(ActionEvent e)
166 defaultButton_actionPerformed(e);
170 smoothFont.setFont(JvSwingUtils.getLabelFont());
171 smoothFont.setOpaque(false);
172 smoothFont.setText(MessageManager.getString("label.anti_alias_fonts"));
173 smoothFont.setBounds(new Rectangle(41, 65, 260, 23));
174 smoothFont.addActionListener(new ActionListener()
176 public void actionPerformed(ActionEvent e)
178 smoothFont_actionPerformed(e);
183 * Scale protein as cDNA is only visible in SplitFrame protein alignment
185 scaleAsCdna.setVisible(false);
186 scaleAsCdna.setFont(JvSwingUtils.getLabelFont());
187 scaleAsCdna.setOpaque(false);
188 scaleAsCdna.setText(MessageManager.getString("label.scale_as_cdna"));
189 scaleAsCdna.setBounds(new Rectangle(41, 85, 260, 23));
190 scaleAsCdna.addActionListener(new ActionListener()
192 public void actionPerformed(ActionEvent e)
194 scaleAsCdna_actionPerformed(e);
198 monospaced.setEnabled(false);
199 monospaced.setFont(JvSwingUtils.getLabelFont());
200 monospaced.setOpaque(false);
201 monospaced.setToolTipText(MessageManager
202 .getString("label.monospaced_fonts_faster_to_render"));
203 monospaced.setText(MessageManager.getString("label.monospaced_font"));
206 * jPanel1: Font dropdown, Monospaced checkbox
208 JPanel jPanel1 = new JPanel();
209 jPanel1.setOpaque(false);
210 jPanel1.setBounds(new Rectangle(5, 6, 308, 23));
211 jPanel1.setLayout(new BorderLayout());
212 jPanel1.add(fontLabel, BorderLayout.WEST);
213 jPanel1.add(fontName, BorderLayout.CENTER);
214 jPanel1.add(monospaced, java.awt.BorderLayout.EAST);
217 * jPanel2: font size dropdown
219 JPanel jPanel2 = new JPanel();
220 jPanel2.setOpaque(false);
221 jPanel2.setBounds(new Rectangle(5, 37, 128, 21));
222 jPanel2.setLayout(new BorderLayout());
223 jPanel2.add(fontSize, java.awt.BorderLayout.CENTER);
224 jPanel2.add(sizeLabel, java.awt.BorderLayout.WEST);
227 * jPanel3: font style dropdown
229 JPanel jPanel3 = new JPanel();
230 jPanel3.setOpaque(false);
231 jPanel3.setBounds(new Rectangle(174, 38, 134, 21));
232 jPanel3.setLayout(new BorderLayout());
233 jPanel3.add(styleLabel, java.awt.BorderLayout.WEST);
234 jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER);
237 * jPanel4: Default and OK buttons
239 JPanel jPanel4 = new JPanel();
240 jPanel4.setOpaque(false);
241 jPanel4.setBounds(new Rectangle(24, 112, 300, 35));
242 jPanel4.add(defaultButton);
246 this.add(smoothFont);
247 this.add(scaleAsCdna);
248 this.add(jPanel3, null);
249 this.add(jPanel2, null);
251 this.add(jPanel1, null);
254 protected void scaleAsCdna_actionPerformed(ActionEvent e)
264 protected void ok_actionPerformed(ActionEvent e)
274 protected void cancel_actionPerformed(ActionEvent e)
284 protected void fontName_actionPerformed(ActionEvent e)
294 protected void fontSize_actionPerformed(ActionEvent e)
304 protected void fontStyle_actionPerformed(ActionEvent e)
314 public void defaultButton_actionPerformed(ActionEvent e)
318 public void smoothFont_actionPerformed(ActionEvent e)