JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / jbgui / GFontChooser.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
3  * Copyright (C) 2015 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   /**
67    * Creates a new GFontChooser object.
68    */
69   public GFontChooser()
70   {
71     try
72     {
73       jbInit();
74     } catch (Exception e)
75     {
76       e.printStackTrace();
77     }
78   }
79
80   /**
81    * DOCUMENT ME!
82    * 
83    * @throws Exception
84    *           DOCUMENT ME!
85    */
86   private void jbInit() throws Exception
87   {
88     this.setLayout(null);
89     this.setBackground(Color.white);
90
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);
95
96     fontSize.setFont(VERDANA_11PT);
97     fontSize.setOpaque(false);
98     fontSize.setPreferredSize(new Dimension(50, 21));
99     fontSize.addActionListener(new java.awt.event.ActionListener()
100     {
101       public void actionPerformed(ActionEvent e)
102       {
103         fontSize_actionPerformed(e);
104       }
105     });
106
107     fontStyle.setFont(VERDANA_11PT);
108     fontStyle.setOpaque(false);
109     fontStyle.setPreferredSize(new Dimension(90, 21));
110     fontStyle.addActionListener(new java.awt.event.ActionListener()
111     {
112       public void actionPerformed(ActionEvent e)
113       {
114         fontStyle_actionPerformed(e);
115       }
116     });
117
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);
122
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);
127
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()
134     {
135       public void actionPerformed(ActionEvent e)
136       {
137         fontName_actionPerformed(e);
138       }
139     });
140
141     JButton ok = new JButton(MessageManager.getString("action.ok"));
142     ok.setFont(VERDANA_11PT);
143     ok.addActionListener(new java.awt.event.ActionListener()
144     {
145       public void actionPerformed(ActionEvent e)
146       {
147         ok_actionPerformed(e);
148       }
149     });
150
151     JButton cancel = new JButton(MessageManager.getString("action.cancel"));
152     cancel.setFont(VERDANA_11PT);
153     cancel.addActionListener(new java.awt.event.ActionListener()
154     {
155       public void actionPerformed(ActionEvent e)
156       {
157         cancel_actionPerformed(e);
158       }
159     });
160
161     defaultButton.setFont(JvSwingUtils.getLabelFont());
162     defaultButton.setText(MessageManager.getString("label.set_as_default"));
163     defaultButton.addActionListener(new ActionListener()
164     {
165       public void actionPerformed(ActionEvent e)
166       {
167         defaultButton_actionPerformed(e);
168       }
169     });
170
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()
176     {
177       public void actionPerformed(ActionEvent e)
178       {
179         smoothFont_actionPerformed(e);
180       }
181     });
182
183     /*
184      * Scale protein as cDNA is only visible in SplitFrame protein alignment
185      */
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()
192     {
193       public void actionPerformed(ActionEvent e)
194       {
195         scaleAsCdna_actionPerformed(e);
196       }
197     });
198
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"));
205
206     /*
207      * jPanel1: Font dropdown, Monospaced checkbox
208      */
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);
216
217     /*
218      * jPanel2: font size dropdown
219      */
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);
226
227     /*
228      * jPanel3: font style dropdown
229      */
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);
236
237     /*
238      * jPanel4: Default and OK buttons
239      */
240     JPanel jPanel4 = new JPanel();
241     jPanel4.setOpaque(false);
242     jPanel4.setBounds(new Rectangle(24, 112, 300, 35));
243     jPanel4.add(defaultButton);
244     jPanel4.add(ok);
245     jPanel4.add(cancel);
246
247     this.add(smoothFont);
248     this.add(scaleAsCdna);
249     this.add(jPanel3, null);
250     this.add(jPanel2, null);
251     this.add(jPanel4);
252     this.add(jPanel1, null);
253   }
254
255   protected void scaleAsCdna_actionPerformed(ActionEvent e)
256   {
257   }
258
259   /**
260    * DOCUMENT ME!
261    * 
262    * @param e
263    *          DOCUMENT ME!
264    */
265   protected void ok_actionPerformed(ActionEvent e)
266   {
267   }
268
269   /**
270    * DOCUMENT ME!
271    * 
272    * @param e
273    *          DOCUMENT ME!
274    */
275   protected void cancel_actionPerformed(ActionEvent e)
276   {
277   }
278
279   /**
280    * DOCUMENT ME!
281    * 
282    * @param e
283    *          DOCUMENT ME!
284    */
285   protected void fontName_actionPerformed(ActionEvent e)
286   {
287   }
288
289   /**
290    * DOCUMENT ME!
291    * 
292    * @param e
293    *          DOCUMENT ME!
294    */
295   protected void fontSize_actionPerformed(ActionEvent e)
296   {
297   }
298
299   /**
300    * DOCUMENT ME!
301    * 
302    * @param e
303    *          DOCUMENT ME!
304    */
305   protected void fontStyle_actionPerformed(ActionEvent e)
306   {
307   }
308
309   /**
310    * DOCUMENT ME!
311    * 
312    * @param e
313    *          DOCUMENT ME!
314    */
315   public void defaultButton_actionPerformed(ActionEvent e)
316   {
317   }
318
319   public void smoothFont_actionPerformed(ActionEvent e)
320   {
321
322   }
323 }