2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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;
27 import java.awt.event.*;
30 import javax.swing.colorchooser.AbstractColorChooserPanel;
38 public class GUserDefinedColours extends JPanel
40 protected JColorChooser colorChooser = new JColorChooser();
42 protected JPanel buttonPanel = new JPanel();
44 protected GridLayout gridLayout = new GridLayout();
46 JPanel lowerPanel = new JPanel();
48 protected JButton okButton = new JButton();
50 protected JButton applyButton = new JButton();
52 protected JButton loadbutton = new JButton();
54 protected JButton savebutton = new JButton();
56 protected JButton cancelButton = new JButton();
58 JPanel namePanel = new JPanel();
60 JLabel jLabel1 = new JLabel();
62 protected JTextField schemeName = new JTextField();
64 BorderLayout borderLayout1 = new BorderLayout();
66 JPanel panel1 = new JPanel();
68 JPanel okCancelPanel = new JPanel();
70 JPanel saveLoadPanel = new JPanel();
72 BorderLayout borderLayout3 = new BorderLayout();
74 GridBagLayout gridBagLayout1 = new GridBagLayout();
76 BorderLayout borderLayout2 = new BorderLayout();
78 FlowLayout flowLayout1 = new FlowLayout();
80 BorderLayout borderLayout4 = new BorderLayout();
82 JPanel jPanel4 = new JPanel();
84 BorderLayout borderLayout5 = new BorderLayout();
86 JLabel label = new JLabel();
88 protected JPanel casePanel = new JPanel();
90 protected JCheckBox caseSensitive = new JCheckBox();
92 protected JButton lcaseColour = new JButton();
95 * Creates a new GUserDefinedColours object.
97 public GUserDefinedColours()
102 } catch (Exception e)
115 private void jbInit() throws Exception
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()
125 public void actionPerformed(ActionEvent e)
127 okButton_actionPerformed(e);
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()
134 public void actionPerformed(ActionEvent e)
136 applyButton_actionPerformed(e);
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()
143 public void actionPerformed(ActionEvent e)
145 loadbutton_actionPerformed(e);
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()
152 public void actionPerformed(ActionEvent e)
154 savebutton_actionPerformed(e);
157 cancelButton.setFont(JvSwingUtils.getLabelFont());
158 cancelButton.setText(MessageManager.getString("action.cancel"));
159 cancelButton.addActionListener(new java.awt.event.ActionListener()
161 public void actionPerformed(ActionEvent e)
163 cancelButton_actionPerformed(e);
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",
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()
196 public void actionPerformed(ActionEvent e)
198 caseSensitive_actionPerformed(e);
202 .setText(MessageManager.getString("label.lower_case_colour"));
203 lcaseColour.addActionListener(new ActionListener()
205 public void actionPerformed(ActionEvent e)
207 lcaseColour_actionPerformed(e);
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);
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);
229 jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
230 this.add(jPanel4, java.awt.BorderLayout.CENTER);
231 this.add(colorChooser, java.awt.BorderLayout.EAST);
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]});
247 protected void okButton_actionPerformed(ActionEvent e)
257 protected void applyButton_actionPerformed(ActionEvent e)
267 protected void loadbutton_actionPerformed(ActionEvent e)
277 protected void savebutton_actionPerformed(ActionEvent e)
287 protected void cancelButton_actionPerformed(ActionEvent e)
291 public void caseSensitive_actionPerformed(ActionEvent e)
296 public void lcaseColour_actionPerformed(ActionEvent e)