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()
139 public void actionPerformed(ActionEvent e)
141 okButton_actionPerformed();
144 applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
145 applyButton.setText(MessageManager.getString("action.apply"));
146 applyButton.addActionListener(new ActionListener()
149 public void actionPerformed(ActionEvent e)
151 applyButton_actionPerformed();
154 loadbutton.setFont(new java.awt.Font("Verdana", 0, 11));
155 loadbutton.setText(MessageManager.getString("action.load_scheme"));
156 loadbutton.addActionListener(new java.awt.event.ActionListener()
159 public void actionPerformed(ActionEvent e)
161 loadbutton_actionPerformed(e);
164 savebutton.setFont(new java.awt.Font("Verdana", 0, 11));
165 savebutton.setText(MessageManager.getString("action.save_scheme"));
166 savebutton.addActionListener(new java.awt.event.ActionListener()
169 public void actionPerformed(ActionEvent e)
171 savebutton_actionPerformed(e);
174 cancelButton.setFont(JvSwingUtils.getLabelFont());
175 cancelButton.setText(MessageManager.getString("action.cancel"));
176 cancelButton.addActionListener(new java.awt.event.ActionListener()
179 public void actionPerformed(ActionEvent e)
181 cancelButton_actionPerformed(e);
184 this.setBackground(new Color(212, 208, 223));
185 lowerPanel.setOpaque(false);
186 lowerPanel.setLayout(borderLayout3);
187 colorChooser.setOpaque(false);
188 jLabel1.setFont(JvSwingUtils.getLabelFont());
189 jLabel1.setText(MessageManager.getString("label.name"));
190 namePanel.setMinimumSize(new Dimension(300, 31));
191 namePanel.setOpaque(false);
192 namePanel.setPreferredSize(new Dimension(240, 25));
193 namePanel.setLayout(borderLayout1);
194 schemeName.setFont(JvSwingUtils.getLabelFont());
195 schemeName.setPreferredSize(new Dimension(105, 21));
196 schemeName.setText("");
197 schemeName.setHorizontalAlignment(SwingConstants.CENTER);
198 panel1.setLayout(flowLayout1);
199 panel1.setOpaque(false);
200 okCancelPanel.setOpaque(false);
201 saveLoadPanel.setOpaque(false);
202 jPanel4.setLayout(borderLayout5);
203 label.setFont(new java.awt.Font("Verdana", Font.ITALIC, 10));
204 label.setOpaque(false);
205 label.setPreferredSize(new Dimension(260, 34));
206 label.setText(MessageManager
208 "label.html_content",
209 new String[] { MessageManager
210 .getString("label.save_colour_scheme_with_unique_name_added_to_colour_menu") }));
211 caseSensitive.setText(MessageManager.getString("label.case_sensitive"));
212 caseSensitive.addActionListener(new ActionListener()
215 public void actionPerformed(ActionEvent e)
217 caseSensitive_actionPerformed(e);
221 .setText(MessageManager.getString("label.lower_case_colour"));
222 lcaseColour.addActionListener(new ActionListener()
225 public void actionPerformed(ActionEvent e)
227 lcaseColour_actionPerformed(e);
231 saveLoadPanel.add(savebutton);
232 saveLoadPanel.add(loadbutton);
233 okCancelPanel.add(applyButton);
234 okCancelPanel.add(okButton);
235 okCancelPanel.add(cancelButton);
236 lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH);
237 lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH);
239 namePanel.add(schemeName, java.awt.BorderLayout.CENTER);
240 namePanel.add(jLabel1, java.awt.BorderLayout.WEST);
241 panel1.add(namePanel, null);
242 panel1.add(buttonPanel, null);
243 panel1.add(casePanel);
244 casePanel.add(caseSensitive);
245 casePanel.add(lcaseColour);
246 panel1.add(lowerPanel, null);
249 jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
250 this.add(jPanel4, java.awt.BorderLayout.CENTER);
251 this.add(colorChooser, java.awt.BorderLayout.EAST);
253 AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
254 // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to
255 // swatch picker only
256 if (choosers.length > 3)
258 // Java 7 default has 5 options rather than 3 for choosing colours; keep
261 .setChooserPanels(new AbstractColorChooserPanel[] { choosers[0] });
268 protected void okButton_actionPerformed()
275 protected void applyButton_actionPerformed()
285 protected void loadbutton_actionPerformed(ActionEvent e)
295 protected void savebutton_actionPerformed(ActionEvent e)
305 protected void cancelButton_actionPerformed(ActionEvent e)
309 public void caseSensitive_actionPerformed(ActionEvent e)
314 public void lcaseColour_actionPerformed(ActionEvent e)