2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
20 package jalview.appletgui;
\r
24 import java.awt.event.ActionEvent;
\r
25 import java.awt.event.ItemEvent;
\r
27 public class FontChooser
\r
33 boolean init = true;
\r
36 public FontChooser(TreePanel tp)
\r
44 e.printStackTrace();
\r
48 oldFont = tp.getTreeFont();
\r
52 public FontChooser(AlignmentPanel ap)
\r
55 oldFont = ap.av.getFont();
\r
61 String fonts[] = Toolkit.getDefaultToolkit().getFontList();
\r
62 for (int i = 0; i < fonts.length; i++)
\r
64 fontName.addItem(fonts[i]);
\r
67 for (int i = 1; i < 31; i++)
\r
69 fontSize.addItem(i + "");
\r
72 fontStyle.addItem("plain");
\r
73 fontStyle.addItem("bold");
\r
74 fontStyle.addItem("italic");
\r
76 fontName.select(oldFont.getName());
\r
77 fontSize.select(oldFont.getSize() + "");
\r
78 fontStyle.select(oldFont.getStyle());
\r
80 Frame frame = new Frame();
\r
83 jalview.bin.JalviewLite.addFrame(frame, "Change Font", 440, 100);
\r
88 protected void ok_actionPerformed()
\r
90 frame.setVisible(false);
\r
93 if (ap.getOverviewPanel() != null)
\r
95 ap.getOverviewPanel().updateOverviewImage();
\r
101 protected void cancel_actionPerformed()
\r
105 ap.av.setFont(oldFont);
\r
110 tp.setTreeFont(oldFont);
\r
111 tp.treeCanvas.repaint();
\r
114 fontName.select(oldFont.getName());
\r
115 fontSize.select(oldFont.getSize() + "");
\r
116 fontStyle.select(oldFont.getStyle());
\r
118 frame.setVisible(false);
\r
123 Font newFont = new Font(fontName.getSelectedItem().toString(),
\r
124 fontStyle.getSelectedIndex(),
\r
125 Integer.parseInt(fontSize.getSelectedItem().
\r
130 ap.av.setFont(newFont);
\r
133 else if(tp != null)
\r
135 tp.setTreeFont(newFont);
\r
139 protected void fontName_actionPerformed()
\r
148 protected void fontSize_actionPerformed()
\r
157 protected void fontStyle_actionPerformed()
\r
165 Label label1 = new Label();
\r
166 protected Choice fontSize = new Choice();
\r
167 protected Choice fontStyle = new Choice();
\r
168 Label label2 = new Label();
\r
169 Label label3 = new Label();
\r
170 protected Choice fontName = new Choice();
\r
171 Button ok = new Button();
\r
172 Button cancel = new Button();
\r
173 Panel panel1 = new Panel();
\r
174 Panel panel2 = new Panel();
\r
175 Panel panel3 = new Panel();
\r
176 BorderLayout borderLayout1 = new BorderLayout();
\r
177 BorderLayout borderLayout2 = new BorderLayout();
\r
178 BorderLayout borderLayout3 = new BorderLayout();
\r
179 Panel panel4 = new Panel();
\r
180 Panel panel5 = new Panel();
\r
181 BorderLayout borderLayout4 = new BorderLayout();
\r
184 private void jbInit() throws Exception {
\r
185 label1.setFont(new java.awt.Font("Verdana", 0, 11));
\r
186 label1.setAlignment(Label.RIGHT);
\r
187 label1.setText("Font: ");
\r
188 this.setLayout(borderLayout4);
\r
189 fontSize.setFont(new java.awt.Font("Verdana", 0, 11));
\r
190 fontSize.addItemListener(new java.awt.event.ItemListener() {
\r
191 public void itemStateChanged(ItemEvent e) {
\r
192 fontSize_actionPerformed();
\r
195 fontStyle.setFont(new java.awt.Font("Verdana", 0, 11));
\r
196 fontStyle.addItemListener(new java.awt.event.ItemListener() {
\r
197 public void itemStateChanged(ItemEvent e) {
\r
198 fontStyle_actionPerformed();
\r
201 label2.setAlignment(Label.RIGHT);
\r
202 label2.setFont(new java.awt.Font("Verdana", 0, 11));
\r
203 label2.setText("Size: ");
\r
204 label3.setAlignment(Label.RIGHT);
\r
205 label3.setFont(new java.awt.Font("Verdana", 0, 11));
\r
206 label3.setText("Style: ");
\r
207 fontName.setFont(new java.awt.Font("Verdana", 0, 11));
\r
208 fontName.addItemListener(new java.awt.event.ItemListener() {
\r
209 public void itemStateChanged(ItemEvent e) {
\r
210 fontName_actionPerformed();
\r
213 ok.setFont(new java.awt.Font("Verdana", 0, 11));
\r
215 ok.addActionListener(new java.awt.event.ActionListener() {
\r
216 public void actionPerformed(ActionEvent e) {
\r
217 ok_actionPerformed();
\r
220 cancel.setFont(new java.awt.Font("Verdana", 0, 11));
\r
221 cancel.setLabel("Cancel");
\r
222 cancel.addActionListener(new java.awt.event.ActionListener() {
\r
223 public void actionPerformed(ActionEvent e) {
\r
224 cancel_actionPerformed();
\r
227 this.setBackground(Color.white);
\r
228 panel1.setLayout(borderLayout1);
\r
229 panel2.setLayout(borderLayout3);
\r
230 panel3.setLayout(borderLayout2);
\r
231 panel5.setBackground(Color.white);
\r
232 panel4.setBackground(Color.white);
\r
233 panel1.setBackground(Color.white);
\r
234 panel2.setBackground(Color.white);
\r
235 panel3.setBackground(Color.white);
\r
236 panel1.add(label1, BorderLayout.WEST);
\r
237 panel1.add(fontName, BorderLayout.CENTER);
\r
238 panel5.add(panel1, null);
\r
239 panel5.add(panel3, null);
\r
240 panel5.add(panel2, null);
\r
241 panel2.add(label3, BorderLayout.WEST);
\r
242 panel2.add(fontStyle, BorderLayout.CENTER);
\r
243 panel3.add(label2, BorderLayout.WEST);
\r
244 panel3.add(fontSize, BorderLayout.CENTER);
\r
245 this.add(panel4, BorderLayout.SOUTH);
\r
246 panel4.add(ok, null);
\r
247 panel4.add(cancel, null);
\r
248 this.add(panel5, BorderLayout.CENTER);
\r