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
19 package jalview.gui;
\r
21 import jalview.bin.*;
\r
23 import jalview.jbgui.*;
\r
26 import java.awt.event.*;
\r
28 import javax.swing.*;
\r
35 * @version $Revision$
\r
37 public class FontChooser extends GFontChooser
\r
41 boolean init = true;
\r
42 JInternalFrame frame;
\r
45 * Creates a new FontChooser object.
\r
47 * @param ap DOCUMENT ME!
\r
49 public FontChooser(AlignmentPanel ap)
\r
51 frame = new JInternalFrame();
\r
52 frame.setContentPane(this);
\r
53 Desktop.addInternalFrame(frame, "Change Font", 480, 100, false);
\r
54 frame.setLayer(JLayeredPane.PALETTE_LAYER);
\r
58 String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()
\r
59 .getAvailableFontFamilyNames();
\r
61 for (int i = 0; i < fonts.length; i++)
\r
63 fontName.addItem(fonts[i]);
\r
66 for (int i = 1; i < 31; i++)
\r
68 fontSize.addItem(i + "");
\r
71 fontStyle.addItem("plain");
\r
72 fontStyle.addItem("bold");
\r
73 fontStyle.addItem("italic");
\r
75 oldFont = ap.av.getFont();
\r
76 fontName.setSelectedItem(oldFont.getName());
\r
77 fontSize.setSelectedItem(oldFont.getSize() + "");
\r
78 fontStyle.setSelectedIndex(oldFont.getStyle());
\r
86 * @param e DOCUMENT ME!
\r
88 protected void ok_actionPerformed(ActionEvent e)
\r
92 frame.setClosed(true);
\r
94 catch (Exception ex)
\r
98 if (ap.getOverviewPanel() != null)
\r
100 ap.getOverviewPanel().updateOverviewImage();
\r
107 * @param e DOCUMENT ME!
\r
109 protected void cancel_actionPerformed(ActionEvent e)
\r
111 ap.av.setFont(oldFont);
\r
113 fontName.setSelectedItem(oldFont.getName());
\r
114 fontSize.setSelectedItem(oldFont.getSize() + "");
\r
115 fontStyle.setSelectedIndex(oldFont.getStyle());
\r
119 frame.setClosed(true);
\r
121 catch (Exception ex)
\r
131 Font newFont = new Font(fontName.getSelectedItem().toString(),
\r
132 fontStyle.getSelectedIndex(),
\r
133 Integer.parseInt(fontSize.getSelectedItem().toString()));
\r
134 ap.av.setFont(newFont);
\r
141 * @param e DOCUMENT ME!
\r
143 protected void fontName_actionPerformed(ActionEvent e)
\r
156 * @param e DOCUMENT ME!
\r
158 protected void fontSize_actionPerformed(ActionEvent e)
\r
171 * @param e DOCUMENT ME!
\r
173 protected void fontStyle_actionPerformed(ActionEvent e)
\r
186 * @param e DOCUMENT ME!
\r
188 public void defaultButton_actionPerformed(ActionEvent e)
\r
190 Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString());
\r
191 Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + "");
\r
192 Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString());
\r