2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
23 import jalview.gui.JvSwingUtils;
24 import jalview.util.MessageManager;
26 import java.awt.BorderLayout;
27 import java.awt.Color;
28 import java.awt.Dimension;
29 import java.awt.FlowLayout;
31 import java.awt.GridBagLayout;
32 import java.awt.GridLayout;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
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;
51 public class GUserDefinedColours extends JPanel
53 protected JColorChooser colorChooser = new JColorChooser();
55 protected JPanel buttonPanel = new JPanel();
57 protected GridLayout gridLayout = new GridLayout();
59 JPanel lowerPanel = new JPanel();
61 protected JButton okButton = new JButton();
63 protected JButton applyButton = new JButton();
65 protected JButton loadbutton = new JButton();
67 protected JButton savebutton = new JButton();
69 protected JButton cancelButton = new JButton();
71 JPanel namePanel = new JPanel();
73 JLabel jLabel1 = new JLabel();
75 protected JTextField schemeName = new JTextField();
77 BorderLayout borderLayout1 = new BorderLayout();
79 JPanel panel1 = new JPanel();
81 JPanel okCancelPanel = new JPanel();
83 JPanel saveLoadPanel = new JPanel();
85 BorderLayout borderLayout3 = new BorderLayout();
87 GridBagLayout gridBagLayout1 = new GridBagLayout();
89 BorderLayout borderLayout2 = new BorderLayout();
91 FlowLayout flowLayout1 = new FlowLayout();
93 BorderLayout borderLayout4 = new BorderLayout();
95 JPanel jPanel4 = new JPanel();
97 BorderLayout borderLayout5 = new BorderLayout();
99 JLabel label = new JLabel();
101 protected JPanel casePanel = new JPanel();
103 protected JCheckBox caseSensitive = new JCheckBox();
105 protected JButton lcaseColour = new JButton();
108 * Creates a new GUserDefinedColours object.
110 public GUserDefinedColours()
115 } catch (Exception e)
128 private void jbInit() throws Exception
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()
138 public void actionPerformed(ActionEvent e)
140 okButton_actionPerformed(e);
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()
147 public void actionPerformed(ActionEvent e)
149 applyButton_actionPerformed(e);
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()
156 public void actionPerformed(ActionEvent e)
158 loadbutton_actionPerformed(e);
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()
165 public void actionPerformed(ActionEvent e)
167 savebutton_actionPerformed(e);
170 cancelButton.setFont(JvSwingUtils.getLabelFont());
171 cancelButton.setText(MessageManager.getString("action.cancel"));
172 cancelButton.addActionListener(new java.awt.event.ActionListener()
174 public void actionPerformed(ActionEvent e)
176 cancelButton_actionPerformed(e);
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
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()
209 public void actionPerformed(ActionEvent e)
211 caseSensitive_actionPerformed(e);
215 .setText(MessageManager.getString("label.lower_case_colour"));
216 lcaseColour.addActionListener(new ActionListener()
218 public void actionPerformed(ActionEvent e)
220 lcaseColour_actionPerformed(e);
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);
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);
242 jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
243 this.add(jPanel4, java.awt.BorderLayout.CENTER);
244 this.add(colorChooser, java.awt.BorderLayout.EAST);
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)
251 // Java 7 default has 5 options rather than 3 for choosing colours; keep
254 .setChooserPanels(new AbstractColorChooserPanel[] { choosers[0] });
264 protected void okButton_actionPerformed(ActionEvent e)
274 protected void applyButton_actionPerformed(ActionEvent e)
284 protected void loadbutton_actionPerformed(ActionEvent e)
294 protected void savebutton_actionPerformed(ActionEvent e)
304 protected void cancelButton_actionPerformed(ActionEvent e)
308 public void caseSensitive_actionPerformed(ActionEvent e)
313 public void lcaseColour_actionPerformed(ActionEvent e)