JAL-2435 copy font changes across split screen
[jalview.git] / src / jalview / jbgui / GFontChooser.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.jbgui;
22
23 import jalview.gui.JvSwingUtils;
24 import jalview.util.MessageManager;
25
26 import java.awt.BorderLayout;
27 import java.awt.Color;
28 import java.awt.Dimension;
29 import java.awt.Font;
30 import java.awt.Rectangle;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33
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;
40
41 /**
42  * DOCUMENT ME!
43  * 
44  * @author $author$
45  * @version $Revision$
46  */
47 public class GFontChooser extends JPanel
48 {
49   private static final Font VERDANA_11PT = new java.awt.Font("Verdana", 0,
50           11);
51
52   protected JComboBox<Integer> fontSize = new JComboBox<Integer>();
53
54   protected JComboBox<String> fontStyle = new JComboBox<String>();
55
56   protected JComboBox<String> fontName = new JComboBox<String>();
57
58   protected JButton defaultButton = new JButton();
59
60   protected JCheckBox smoothFont = new JCheckBox();
61
62   protected JCheckBox monospaced = new JCheckBox();
63
64   protected JCheckBox scaleAsCdna = new JCheckBox();
65
66   protected JCheckBox fontAsCdna = new JCheckBox();
67
68   /**
69    * Creates a new GFontChooser object.
70    */
71   public GFontChooser()
72   {
73     try
74     {
75       jbInit();
76     } catch (Exception e)
77     {
78       e.printStackTrace();
79     }
80   }
81
82   /**
83    * DOCUMENT ME!
84    * 
85    * @throws Exception
86    *           DOCUMENT ME!
87    */
88   private void jbInit() throws Exception
89   {
90     this.setLayout(null);
91     this.setBackground(Color.white);
92
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);
97
98     fontSize.setFont(VERDANA_11PT);
99     fontSize.setOpaque(false);
100     fontSize.setPreferredSize(new Dimension(50, 21));
101     fontSize.addActionListener(new java.awt.event.ActionListener()
102     {
103       @Override
104       public void actionPerformed(ActionEvent e)
105       {
106         fontSize_actionPerformed(e);
107       }
108     });
109
110     fontStyle.setFont(VERDANA_11PT);
111     fontStyle.setOpaque(false);
112     fontStyle.setPreferredSize(new Dimension(90, 21));
113     fontStyle.addActionListener(new java.awt.event.ActionListener()
114     {
115       @Override
116       public void actionPerformed(ActionEvent e)
117       {
118         fontStyle_actionPerformed(e);
119       }
120     });
121
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);
126
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);
131
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()
138     {
139       @Override
140       public void actionPerformed(ActionEvent e)
141       {
142         fontName_actionPerformed(e);
143       }
144     });
145
146     JButton ok = new JButton(MessageManager.getString("action.ok"));
147     ok.setFont(VERDANA_11PT);
148     ok.addActionListener(new java.awt.event.ActionListener()
149     {
150       @Override
151       public void actionPerformed(ActionEvent e)
152       {
153         ok_actionPerformed(e);
154       }
155     });
156
157     JButton cancel = new JButton(MessageManager.getString("action.cancel"));
158     cancel.setFont(VERDANA_11PT);
159     cancel.addActionListener(new java.awt.event.ActionListener()
160     {
161       @Override
162       public void actionPerformed(ActionEvent e)
163       {
164         cancel_actionPerformed(e);
165       }
166     });
167
168     defaultButton.setFont(JvSwingUtils.getLabelFont());
169     defaultButton.setText(MessageManager.getString("label.set_as_default"));
170     defaultButton.addActionListener(new ActionListener()
171     {
172       @Override
173       public void actionPerformed(ActionEvent e)
174       {
175         defaultButton_actionPerformed(e);
176       }
177     });
178
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()
184     {
185       @Override
186       public void actionPerformed(ActionEvent e)
187       {
188         smoothFont_actionPerformed(e);
189       }
190     });
191
192     /*
193      * Scale protein as cDNA is only visible in SplitFrame
194      */
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()
201     {
202       @Override
203       public void actionPerformed(ActionEvent e)
204       {
205         scaleAsCdna_actionPerformed(e);
206       }
207     });
208
209     /*
210      * Same font for cDNA/peptide is only visible in SplitFrame
211      */
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
218     monospaced.setEnabled(false);
219     monospaced.setFont(JvSwingUtils.getLabelFont());
220     monospaced.setOpaque(false);
221     monospaced.setToolTipText(MessageManager
222             .getString("label.monospaced_fonts_faster_to_render"));
223     monospaced.setText(MessageManager.getString("label.monospaced_font"));
224
225     /*
226      * jPanel1: Font dropdown, Monospaced checkbox
227      */
228     JPanel jPanel1 = new JPanel();
229     jPanel1.setOpaque(false);
230     jPanel1.setBounds(new Rectangle(5, 6, 308, 23));
231     jPanel1.setLayout(new BorderLayout());
232     jPanel1.add(fontLabel, BorderLayout.WEST);
233     jPanel1.add(fontName, BorderLayout.CENTER);
234     jPanel1.add(monospaced, java.awt.BorderLayout.EAST);
235
236     /*
237      * jPanel2: font size dropdown
238      */
239     JPanel jPanel2 = new JPanel();
240     jPanel2.setOpaque(false);
241     jPanel2.setBounds(new Rectangle(5, 37, 128, 21));
242     jPanel2.setLayout(new BorderLayout());
243     jPanel2.add(fontSize, java.awt.BorderLayout.CENTER);
244     jPanel2.add(sizeLabel, java.awt.BorderLayout.WEST);
245
246     /*
247      * jPanel3: font style dropdown
248      */
249     JPanel jPanel3 = new JPanel();
250     jPanel3.setOpaque(false);
251     jPanel3.setBounds(new Rectangle(174, 38, 134, 21));
252     jPanel3.setLayout(new BorderLayout());
253     jPanel3.add(styleLabel, java.awt.BorderLayout.WEST);
254     jPanel3.add(fontStyle, java.awt.BorderLayout.CENTER);
255
256     /*
257      * jPanel4: Default and OK buttons
258      */
259     JPanel jPanel4 = new JPanel();
260     jPanel4.setOpaque(false);
261     jPanel4.setBounds(new Rectangle(24, 132, 300, 35));
262     jPanel4.add(defaultButton);
263     jPanel4.add(ok);
264     jPanel4.add(cancel);
265
266     this.add(smoothFont);
267     this.add(scaleAsCdna);
268     this.add(fontAsCdna);
269     this.add(jPanel3, null);
270     this.add(jPanel2, null);
271     this.add(jPanel4);
272     this.add(jPanel1, null);
273   }
274
275   protected void scaleAsCdna_actionPerformed(ActionEvent e)
276   {
277   }
278
279   /**
280    * DOCUMENT ME!
281    * 
282    * @param e
283    *          DOCUMENT ME!
284    */
285   protected void ok_actionPerformed(ActionEvent e)
286   {
287   }
288
289   /**
290    * DOCUMENT ME!
291    * 
292    * @param e
293    *          DOCUMENT ME!
294    */
295   protected void cancel_actionPerformed(ActionEvent e)
296   {
297   }
298
299   /**
300    * DOCUMENT ME!
301    * 
302    * @param e
303    *          DOCUMENT ME!
304    */
305   protected void fontName_actionPerformed(ActionEvent e)
306   {
307   }
308
309   /**
310    * DOCUMENT ME!
311    * 
312    * @param e
313    *          DOCUMENT ME!
314    */
315   protected void fontSize_actionPerformed(ActionEvent e)
316   {
317   }
318
319   /**
320    * DOCUMENT ME!
321    * 
322    * @param e
323    *          DOCUMENT ME!
324    */
325   protected void fontStyle_actionPerformed(ActionEvent e)
326   {
327   }
328
329   /**
330    * DOCUMENT ME!
331    * 
332    * @param e
333    *          DOCUMENT ME!
334    */
335   public void defaultButton_actionPerformed(ActionEvent e)
336   {
337   }
338
339   public void smoothFont_actionPerformed(ActionEvent e)
340   {
341
342   }
343 }