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();
67 * Creates a new GFontChooser object.
86 private void jbInit() throws Exception
89 this.setBackground(Color.white);
91 JLabel fontLabel = new JLabel(MessageManager.getString("label.font"));
92 fontLabel.setFont(VERDANA_11PT);
93 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
94 fontLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
96 fontSize.setFont(VERDANA_11PT);
97 fontSize.setOpaque(false);
98 fontSize.setPreferredSize(new Dimension(50, 21));
99 fontSize.addActionListener(new java.awt.event.ActionListener()
101 public void actionPerformed(ActionEvent e)
103 fontSize_actionPerformed(e);
107 fontStyle.setFont(VERDANA_11PT);
108 fontStyle.setOpaque(false);
109 fontStyle.setPreferredSize(new Dimension(90, 21));
110 fontStyle.addActionListener(new java.awt.event.ActionListener()
112 public void actionPerformed(ActionEvent e)
114 fontStyle_actionPerformed(e);
118 JLabel sizeLabel = new JLabel(MessageManager.getString("label.size"));
119 sizeLabel.setFont(VERDANA_11PT);
120 sizeLabel.setHorizontalAlignment(SwingConstants.RIGHT);
121 sizeLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
123 JLabel styleLabel = new JLabel(MessageManager.getString("label.style"));
124 styleLabel.setFont(VERDANA_11PT);
125 styleLabel.setHorizontalAlignment(SwingConstants.RIGHT);
126 styleLabel.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
128 fontName.setFont(VERDANA_11PT);
129 fontName.setMaximumSize(new Dimension(32767, 32767));
130 fontName.setMinimumSize(new Dimension(300, 21));
131 fontName.setOpaque(false);
132 fontName.setPreferredSize(new Dimension(180, 21));
133 fontName.addActionListener(new java.awt.event.ActionListener()
135 public void actionPerformed(ActionEvent e)
137 fontName_actionPerformed(e);
141 JButton ok = new JButton(MessageManager.getString("action.ok"));
142 ok.setFont(VERDANA_11PT);
143 ok.addActionListener(new java.awt.event.ActionListener()
145 public void actionPerformed(ActionEvent e)
147 ok_actionPerformed(e);
151 JButton cancel = new JButton(MessageManager.getString("action.cancel"));
152 cancel.setFont(VERDANA_11PT);
153 cancel.addActionListener(new java.awt.event.ActionListener()
155 public void actionPerformed(ActionEvent e)
157 cancel_actionPerformed(e);
161 defaultButton.setFont(JvSwingUtils.getLabelFont());
162 defaultButton.setText(MessageManager.getString("label.set_as_default"));
163 defaultButton.addActionListener(new ActionListener()
165 public void actionPerformed(ActionEvent e)
167 defaultButton_actionPerformed(e);
171 smoothFont.setFont(JvSwingUtils.getLabelFont());
172 smoothFont.setOpaque(false);
173 smoothFont.setText(MessageManager.getString("label.anti_alias_fonts"));
174 smoothFont.setBounds(new Rectangle(41, 65, 260, 23));
175 smoothFont.addActionListener(new ActionListener()
177 public void actionPerformed(ActionEvent e)
179 smoothFont_actionPerformed(e);
184 * Scale protein as cDNA is only visible in SplitFrame protein alignment
186 scaleAsCdna.setVisible(false);
187 scaleAsCdna.setFont(JvSwingUtils.getLabelFont());
188 scaleAsCdna.setOpaque(false);
189 scaleAsCdna.setText(MessageManager.getString("label.scale_as_cdna"));
190 scaleAsCdna.setBounds(new Rectangle(41, 85, 260, 23));
191 scaleAsCdna.addActionListener(new ActionListener()
193 public void actionPerformed(ActionEvent e)
195 scaleAsCdna_actionPerformed(e);
199 monospaced.setEnabled(false);
200 monospaced.setFont(JvSwingUtils.getLabelFont());
201 monospaced.setOpaque(false);
202 monospaced.setToolTipText(MessageManager
203 .getString("label.monospaced_fonts_faster_to_render"));
204 monospaced.setText(MessageManager.getString("label.monospaced_font"));
207 * jPanel1: Font dropdown, Monospaced checkbox
209 JPanel jPanel1 = new JPanel();
210 jPanel1.setOpaque(false);
211 jPanel1.setBounds(new Rectangle(5, 6, 308, 23));
212 jPanel1.setLayout(new BorderLayout());
213 jPanel1.add(fontLabel, BorderLayout.WEST);
214 jPanel1.add(fontName, BorderLayout.CENTER);
215 jPanel1.add(monospaced, java.awt.BorderLayout.EAST);
218 * jPanel2: font size dropdown
220 JPanel jPanel2 = new JPanel();
221 jPanel2.setOpaque(false);
222 jPanel2.setBounds(new Rectangle(5, 37, 128, 21));
223 jPanel2.setLayout(new BorderLayout());
224 jPanel2.add(fontSize, java.awt.BorderLayout.CENTER);
225 jPanel2.add(sizeLabel, java.awt.BorderLayout.WEST);
228 * jPanel3: font style dropdown
230 JPanel jPanel3 = new JPanel();
231 jPanel3.setOpaque(false);
232 jPanel3.setBounds(new Rectangle(174, 38, 134, 21));
233 jPanel3.setLayout(new BorderLayout());
234 jPanel3.add(styleLabel, java.awt.BorderLayout.WEST);
235 jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER);
238 * jPanel4: Default and OK buttons
240 JPanel jPanel4 = new JPanel();
241 jPanel4.setOpaque(false);
242 jPanel4.setBounds(new Rectangle(24, 112, 300, 35));
243 jPanel4.add(defaultButton);
247 this.add(smoothFont);
248 this.add(scaleAsCdna);
249 this.add(jPanel3, null);
250 this.add(jPanel2, null);
252 this.add(jPanel1, null);
255 protected void scaleAsCdna_actionPerformed(ActionEvent e)
265 protected void ok_actionPerformed(ActionEvent e)
275 protected void cancel_actionPerformed(ActionEvent e)
285 protected void fontName_actionPerformed(ActionEvent e)
295 protected void fontSize_actionPerformed(ActionEvent e)
305 protected void fontStyle_actionPerformed(ActionEvent e)
315 public void defaultButton_actionPerformed(ActionEvent e)
319 public void smoothFont_actionPerformed(ActionEvent e)