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