JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / jbgui / GUserDefinedColours.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.FlowLayout;
30 import java.awt.Font;
31 import java.awt.GridBagLayout;
32 import java.awt.GridLayout;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35
36 import javax.swing.JButton;
37 import javax.swing.JCheckBox;
38 import javax.swing.JColorChooser;
39 import javax.swing.JLabel;
40 import javax.swing.JPanel;
41 import javax.swing.JTextField;
42 import javax.swing.SwingConstants;
43 import javax.swing.colorchooser.AbstractColorChooserPanel;
44
45 /**
46  * DOCUMENT ME!
47  * 
48  * @author $author$
49  * @version $Revision$
50  */
51 public class GUserDefinedColours extends JPanel
52 {
53   protected JColorChooser colorChooser = new JColorChooser();
54
55   protected JPanel buttonPanel = new JPanel();
56
57   protected GridLayout gridLayout = new GridLayout();
58
59   JPanel lowerPanel = new JPanel();
60
61   protected JButton okButton = new JButton();
62
63   protected JButton applyButton = new JButton();
64
65   protected JButton loadbutton = new JButton();
66
67   protected JButton savebutton = new JButton();
68
69   protected JButton cancelButton = new JButton();
70
71   JPanel namePanel = new JPanel();
72
73   JLabel jLabel1 = new JLabel();
74
75   protected JTextField schemeName = new JTextField();
76
77   BorderLayout borderLayout1 = new BorderLayout();
78
79   JPanel panel1 = new JPanel();
80
81   JPanel okCancelPanel = new JPanel();
82
83   JPanel saveLoadPanel = new JPanel();
84
85   BorderLayout borderLayout3 = new BorderLayout();
86
87   GridBagLayout gridBagLayout1 = new GridBagLayout();
88
89   BorderLayout borderLayout2 = new BorderLayout();
90
91   FlowLayout flowLayout1 = new FlowLayout();
92
93   BorderLayout borderLayout4 = new BorderLayout();
94
95   JPanel jPanel4 = new JPanel();
96
97   BorderLayout borderLayout5 = new BorderLayout();
98
99   JLabel label = new JLabel();
100
101   protected JPanel casePanel = new JPanel();
102
103   protected JCheckBox caseSensitive = new JCheckBox();
104
105   protected JButton lcaseColour = new JButton();
106
107   /**
108    * Creates a new GUserDefinedColours object.
109    */
110   public GUserDefinedColours()
111   {
112     try
113     {
114       jbInit();
115     } catch (Exception e)
116     {
117       e.printStackTrace();
118     }
119
120   }
121
122   /**
123    * DOCUMENT ME!
124    * 
125    * @throws Exception
126    *           DOCUMENT ME!
127    */
128   private void jbInit() throws Exception
129   {
130     this.setLayout(borderLayout4);
131     buttonPanel.setLayout(gridLayout);
132     gridLayout.setColumns(4);
133     gridLayout.setRows(5);
134     okButton.setFont(new java.awt.Font("Verdana", 0, 11));
135     okButton.setText(MessageManager.getString("action.ok"));
136     okButton.addActionListener(new java.awt.event.ActionListener()
137     {
138       public void actionPerformed(ActionEvent e)
139       {
140         okButton_actionPerformed(e);
141       }
142     });
143     applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
144     applyButton.setText(MessageManager.getString("action.apply"));
145     applyButton.addActionListener(new java.awt.event.ActionListener()
146     {
147       public void actionPerformed(ActionEvent e)
148       {
149         applyButton_actionPerformed(e);
150       }
151     });
152     loadbutton.setFont(new java.awt.Font("Verdana", 0, 11));
153     loadbutton.setText(MessageManager.getString("action.load_scheme"));
154     loadbutton.addActionListener(new java.awt.event.ActionListener()
155     {
156       public void actionPerformed(ActionEvent e)
157       {
158         loadbutton_actionPerformed(e);
159       }
160     });
161     savebutton.setFont(new java.awt.Font("Verdana", 0, 11));
162     savebutton.setText(MessageManager.getString("action.save_scheme"));
163     savebutton.addActionListener(new java.awt.event.ActionListener()
164     {
165       public void actionPerformed(ActionEvent e)
166       {
167         savebutton_actionPerformed(e);
168       }
169     });
170     cancelButton.setFont(JvSwingUtils.getLabelFont());
171     cancelButton.setText(MessageManager.getString("action.cancel"));
172     cancelButton.addActionListener(new java.awt.event.ActionListener()
173     {
174       public void actionPerformed(ActionEvent e)
175       {
176         cancelButton_actionPerformed(e);
177       }
178     });
179     this.setBackground(new Color(212, 208, 223));
180     lowerPanel.setOpaque(false);
181     lowerPanel.setLayout(borderLayout3);
182     colorChooser.setOpaque(false);
183     jLabel1.setFont(JvSwingUtils.getLabelFont());
184     jLabel1.setText(MessageManager.getString("label.name"));
185     namePanel.setMinimumSize(new Dimension(300, 31));
186     namePanel.setOpaque(false);
187     namePanel.setPreferredSize(new Dimension(240, 25));
188     namePanel.setLayout(borderLayout1);
189     schemeName.setFont(JvSwingUtils.getLabelFont());
190     schemeName.setPreferredSize(new Dimension(105, 21));
191     schemeName.setText("");
192     schemeName.setHorizontalAlignment(SwingConstants.CENTER);
193     panel1.setLayout(flowLayout1);
194     panel1.setOpaque(false);
195     okCancelPanel.setOpaque(false);
196     saveLoadPanel.setOpaque(false);
197     jPanel4.setLayout(borderLayout5);
198     label.setFont(new java.awt.Font("Verdana", Font.ITALIC, 10));
199     label.setOpaque(false);
200     label.setPreferredSize(new Dimension(260, 34));
201     label.setText(MessageManager
202             .formatMessage(
203                     "label.html_content",
204                     new String[] { MessageManager
205                             .getString("label.save_colour_scheme_with_unique_name_added_to_colour_menu") }));
206     caseSensitive.setText(MessageManager.getString("label.case_sensitive"));
207     caseSensitive.addActionListener(new ActionListener()
208     {
209       public void actionPerformed(ActionEvent e)
210       {
211         caseSensitive_actionPerformed(e);
212       }
213     });
214     lcaseColour
215             .setText(MessageManager.getString("label.lower_case_colour"));
216     lcaseColour.addActionListener(new ActionListener()
217     {
218       public void actionPerformed(ActionEvent e)
219       {
220         lcaseColour_actionPerformed(e);
221       }
222     });
223
224     saveLoadPanel.add(savebutton);
225     saveLoadPanel.add(loadbutton);
226     okCancelPanel.add(applyButton);
227     okCancelPanel.add(okButton);
228     okCancelPanel.add(cancelButton);
229     lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH);
230     lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH);
231
232     namePanel.add(schemeName, java.awt.BorderLayout.CENTER);
233     namePanel.add(jLabel1, java.awt.BorderLayout.WEST);
234     panel1.add(namePanel, null);
235     panel1.add(buttonPanel, null);
236     panel1.add(casePanel);
237     casePanel.add(caseSensitive);
238     casePanel.add(lcaseColour);
239     panel1.add(lowerPanel, null);
240     panel1.add(label);
241
242     jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
243     this.add(jPanel4, java.awt.BorderLayout.CENTER);
244     this.add(colorChooser, java.awt.BorderLayout.EAST);
245
246     AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
247     // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to
248     // swatch picker only
249     if (choosers.length > 3)
250     {
251       // Java 7 default has 5 options rather than 3 for choosing colours; keep
252       // the first only
253       colorChooser
254               .setChooserPanels(new AbstractColorChooserPanel[] { choosers[0] });
255     }
256   }
257
258   /**
259    * DOCUMENT ME!
260    * 
261    * @param e
262    *          DOCUMENT ME!
263    */
264   protected void okButton_actionPerformed(ActionEvent e)
265   {
266   }
267
268   /**
269    * DOCUMENT ME!
270    * 
271    * @param e
272    *          DOCUMENT ME!
273    */
274   protected void applyButton_actionPerformed(ActionEvent e)
275   {
276   }
277
278   /**
279    * DOCUMENT ME!
280    * 
281    * @param e
282    *          DOCUMENT ME!
283    */
284   protected void loadbutton_actionPerformed(ActionEvent e)
285   {
286   }
287
288   /**
289    * DOCUMENT ME!
290    * 
291    * @param e
292    *          DOCUMENT ME!
293    */
294   protected void savebutton_actionPerformed(ActionEvent e)
295   {
296   }
297
298   /**
299    * DOCUMENT ME!
300    * 
301    * @param e
302    *          DOCUMENT ME!
303    */
304   protected void cancelButton_actionPerformed(ActionEvent e)
305   {
306   }
307
308   public void caseSensitive_actionPerformed(ActionEvent e)
309   {
310
311   }
312
313   public void lcaseColour_actionPerformed(ActionEvent e)
314   {
315
316   }
317 }