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;
35 import java.util.ArrayList;
36 import java.util.List;
38 import javax.swing.JButton;
39 import javax.swing.JCheckBox;
40 import javax.swing.JColorChooser;
41 import javax.swing.JLabel;
42 import javax.swing.JPanel;
43 import javax.swing.JTextField;
44 import javax.swing.SwingConstants;
45 import javax.swing.colorchooser.AbstractColorChooserPanel;
53 public class GUserDefinedColours extends JPanel
55 protected JColorChooser colorChooser = new JColorChooser();
57 protected JPanel buttonPanel = new JPanel();
59 protected GridLayout gridLayout = new GridLayout();
61 JPanel lowerPanel = new JPanel();
63 protected JButton okButton = new JButton();
65 protected JButton applyButton = new JButton();
67 protected JButton loadbutton = new JButton();
69 protected JButton savebutton = new JButton();
71 protected JButton cancelButton = new JButton();
73 JPanel namePanel = new JPanel();
75 JLabel jLabel1 = new JLabel();
77 protected JTextField schemeName = new JTextField();
79 BorderLayout borderLayout1 = new BorderLayout();
81 JPanel panel1 = new JPanel();
83 JPanel okCancelPanel = new JPanel();
85 JPanel saveLoadPanel = new JPanel();
87 BorderLayout borderLayout3 = new BorderLayout();
89 GridBagLayout gridBagLayout1 = new GridBagLayout();
91 BorderLayout borderLayout2 = new BorderLayout();
93 FlowLayout flowLayout1 = new FlowLayout();
95 BorderLayout borderLayout4 = new BorderLayout();
97 JPanel jPanel4 = new JPanel();
99 BorderLayout borderLayout5 = new BorderLayout();
101 JLabel label = new JLabel();
103 protected JPanel casePanel = new JPanel();
105 protected JCheckBox caseSensitive = new JCheckBox();
107 protected JButton lcaseColour = new JButton();
109 protected List<JButton> selectedButtons;
112 * Creates a new GUserDefinedColours object.
114 public GUserDefinedColours()
119 } catch (Exception e)
132 private void jbInit() throws Exception
134 this.setLayout(borderLayout4);
135 buttonPanel.setLayout(gridLayout);
136 gridLayout.setColumns(4);
137 gridLayout.setRows(5);
138 okButton.setFont(new java.awt.Font("Verdana", 0, 11));
139 okButton.setText(MessageManager.getString("action.ok"));
140 okButton.addActionListener(new java.awt.event.ActionListener()
142 public void actionPerformed(ActionEvent e)
144 okButton_actionPerformed(e);
147 applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
148 applyButton.setText(MessageManager.getString("action.apply"));
149 applyButton.addActionListener(new java.awt.event.ActionListener()
151 public void actionPerformed(ActionEvent e)
153 applyButton_actionPerformed(e);
156 loadbutton.setFont(new java.awt.Font("Verdana", 0, 11));
157 loadbutton.setText(MessageManager.getString("action.load_scheme"));
158 loadbutton.addActionListener(new java.awt.event.ActionListener()
160 public void actionPerformed(ActionEvent e)
162 loadbutton_actionPerformed(e);
165 savebutton.setFont(new java.awt.Font("Verdana", 0, 11));
166 savebutton.setText(MessageManager.getString("action.save_scheme"));
167 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()
178 public void actionPerformed(ActionEvent e)
180 cancelButton_actionPerformed(e);
183 this.setBackground(new Color(212, 208, 223));
184 lowerPanel.setOpaque(false);
185 lowerPanel.setLayout(borderLayout3);
186 colorChooser.setOpaque(false);
187 jLabel1.setFont(JvSwingUtils.getLabelFont());
188 jLabel1.setText(MessageManager.getString("label.name"));
189 namePanel.setMinimumSize(new Dimension(300, 31));
190 namePanel.setOpaque(false);
191 namePanel.setPreferredSize(new Dimension(240, 25));
192 namePanel.setLayout(borderLayout1);
193 schemeName.setFont(JvSwingUtils.getLabelFont());
194 schemeName.setPreferredSize(new Dimension(105, 21));
195 schemeName.setText("");
196 schemeName.setHorizontalAlignment(SwingConstants.CENTER);
197 panel1.setLayout(flowLayout1);
198 panel1.setOpaque(false);
199 okCancelPanel.setOpaque(false);
200 saveLoadPanel.setOpaque(false);
201 jPanel4.setLayout(borderLayout5);
202 label.setFont(new java.awt.Font("Verdana", Font.ITALIC, 10));
203 label.setOpaque(false);
204 label.setPreferredSize(new Dimension(260, 34));
205 label.setText(MessageManager
207 "label.html_content",
208 new String[] { MessageManager
209 .getString("label.save_colour_scheme_with_unique_name_added_to_colour_menu") }));
210 caseSensitive.setText(MessageManager.getString("label.case_sensitive"));
211 caseSensitive.addActionListener(new ActionListener()
213 public void actionPerformed(ActionEvent e)
215 caseSensitive_actionPerformed(e);
219 .setText(MessageManager.getString("label.lower_case_colour"));
220 lcaseColour.addActionListener(new ActionListener()
222 public void actionPerformed(ActionEvent e)
224 lcaseColour_actionPerformed(e);
228 saveLoadPanel.add(savebutton);
229 saveLoadPanel.add(loadbutton);
230 okCancelPanel.add(applyButton);
231 okCancelPanel.add(okButton);
232 okCancelPanel.add(cancelButton);
233 lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH);
234 lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH);
236 namePanel.add(schemeName, java.awt.BorderLayout.CENTER);
237 namePanel.add(jLabel1, java.awt.BorderLayout.WEST);
238 panel1.add(namePanel, null);
239 panel1.add(buttonPanel, null);
240 panel1.add(casePanel);
241 casePanel.add(caseSensitive);
242 casePanel.add(lcaseColour);
243 panel1.add(lowerPanel, null);
246 jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
247 this.add(jPanel4, java.awt.BorderLayout.CENTER);
248 this.add(colorChooser, java.awt.BorderLayout.EAST);
250 AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
251 // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to
252 // swatch picker only
253 if (choosers.length > 3)
255 // Java 7 default has 5 options rather than 3 for choosing colours; keep
258 .setChooserPanels(new AbstractColorChooserPanel[] { choosers[0] });
261 selectedButtons = new ArrayList<JButton>();
270 protected void okButton_actionPerformed(ActionEvent e)
280 protected void applyButton_actionPerformed(ActionEvent e)
290 protected void loadbutton_actionPerformed(ActionEvent e)
300 protected void savebutton_actionPerformed(ActionEvent e)
310 protected void cancelButton_actionPerformed(ActionEvent e)
314 public void caseSensitive_actionPerformed(ActionEvent e)
319 public void lcaseColour_actionPerformed(ActionEvent e)