JAL-1690 'scale protein as cDNA' options in Preferences, FontChooser
[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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Dimension;
26 import java.awt.Font;
27 import java.awt.Rectangle;
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30
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;
37
38 import jalview.gui.JvSwingUtils;
39 import jalview.util.MessageManager;
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, 11);
50
51   protected JComboBox<Integer> fontSize = new JComboBox<Integer>();
52
53   protected JComboBox<String> fontStyle = new JComboBox<String>();
54
55   protected JComboBox<String> fontName = new JComboBox<String>();
56
57   protected JButton defaultButton = new JButton();
58
59   protected JCheckBox smoothFont = new JCheckBox();
60
61   protected JCheckBox monospaced = new JCheckBox();
62
63   protected JCheckBox scaleAsCdna = new JCheckBox();
64
65   /**
66    * Creates a new GFontChooser object.
67    */
68   public GFontChooser()
69   {
70     try
71     {
72       jbInit();
73     } catch (Exception e)
74     {
75       e.printStackTrace();
76     }
77   }
78
79   /**
80    * DOCUMENT ME!
81    * 
82    * @throws Exception
83    *           DOCUMENT ME!
84    */
85   private void jbInit() throws Exception
86   {
87     this.setLayout(null);
88     this.setBackground(Color.white);
89
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);
94
95     fontSize.setFont(VERDANA_11PT);
96     fontSize.setOpaque(false);
97     fontSize.setPreferredSize(new Dimension(50, 21));
98     fontSize.addActionListener(new java.awt.event.ActionListener()
99     {
100       public void actionPerformed(ActionEvent e)
101       {
102         fontSize_actionPerformed(e);
103       }
104     });
105
106     fontStyle.setFont(VERDANA_11PT);
107     fontStyle.setOpaque(false);
108     fontStyle.setPreferredSize(new Dimension(90, 21));
109     fontStyle.addActionListener(new java.awt.event.ActionListener()
110     {
111       public void actionPerformed(ActionEvent e)
112       {
113         fontStyle_actionPerformed(e);
114       }
115     });
116
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);
121
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);
126
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()
133     {
134       public void actionPerformed(ActionEvent e)
135       {
136         fontName_actionPerformed(e);
137       }
138     });
139
140     JButton ok = new JButton(MessageManager.getString("action.ok"));
141     ok.setFont(VERDANA_11PT);
142     ok.addActionListener(new java.awt.event.ActionListener()
143     {
144       public void actionPerformed(ActionEvent e)
145       {
146         ok_actionPerformed(e);
147       }
148     });
149
150     JButton cancel = new JButton(MessageManager.getString("action.cancel"));
151     cancel.setFont(VERDANA_11PT);
152     cancel.addActionListener(new java.awt.event.ActionListener()
153     {
154       public void actionPerformed(ActionEvent e)
155       {
156         cancel_actionPerformed(e);
157       }
158     });
159
160     defaultButton.setFont(JvSwingUtils.getLabelFont());
161     defaultButton.setText(MessageManager.getString("label.set_as_default"));
162     defaultButton.addActionListener(new ActionListener()
163     {
164       public void actionPerformed(ActionEvent e)
165       {
166         defaultButton_actionPerformed(e);
167       }
168     });
169
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()
175     {
176       public void actionPerformed(ActionEvent e)
177       {
178         smoothFont_actionPerformed(e);
179       }
180     });
181
182     /*
183      * Scale protein as cDNA is only visible in SplitFrame protein alignment
184      */
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()
191     {
192       public void actionPerformed(ActionEvent e)
193       {
194         scaleAsCdna_actionPerformed(e);
195       }
196     });
197
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"));
204
205     /*
206      * jPanel1: Font dropdown, Monospaced checkbox
207      */
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);
215
216     /*
217      * jPanel2: font size dropdown
218      */
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);
225
226     /*
227      * jPanel3: font style dropdown
228      */
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);
235
236     /*
237      * jPanel4: Default and OK buttons
238      */
239     JPanel jPanel4 = new JPanel();
240     jPanel4.setOpaque(false);
241     jPanel4.setBounds(new Rectangle(24, 112, 300, 35));
242     jPanel4.add(defaultButton);
243     jPanel4.add(ok);
244     jPanel4.add(cancel);
245
246     this.add(smoothFont);
247     this.add(scaleAsCdna);
248     this.add(jPanel3, null);
249     this.add(jPanel2, null);
250     this.add(jPanel4);
251     this.add(jPanel1, null);
252   }
253
254   protected void scaleAsCdna_actionPerformed(ActionEvent e)
255   {
256   }
257
258   /**
259    * DOCUMENT ME!
260    * 
261    * @param e
262    *          DOCUMENT ME!
263    */
264   protected void ok_actionPerformed(ActionEvent e)
265   {
266   }
267
268   /**
269    * DOCUMENT ME!
270    * 
271    * @param e
272    *          DOCUMENT ME!
273    */
274   protected void cancel_actionPerformed(ActionEvent e)
275   {
276   }
277
278   /**
279    * DOCUMENT ME!
280    * 
281    * @param e
282    *          DOCUMENT ME!
283    */
284   protected void fontName_actionPerformed(ActionEvent e)
285   {
286   }
287
288   /**
289    * DOCUMENT ME!
290    * 
291    * @param e
292    *          DOCUMENT ME!
293    */
294   protected void fontSize_actionPerformed(ActionEvent e)
295   {
296   }
297
298   /**
299    * DOCUMENT ME!
300    * 
301    * @param e
302    *          DOCUMENT ME!
303    */
304   protected void fontStyle_actionPerformed(ActionEvent e)
305   {
306   }
307
308   /**
309    * DOCUMENT ME!
310    * 
311    * @param e
312    *          DOCUMENT ME!
313    */
314   public void defaultButton_actionPerformed(ActionEvent e)
315   {
316   }
317
318   public void smoothFont_actionPerformed(ActionEvent e)
319   {
320
321   }
322 }