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.bin.Jalview;
24 import jalview.gui.JvSwingUtils;
25 import jalview.util.MessageManager;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Dimension;
30 import java.awt.FlowLayout;
32 import java.awt.GridBagLayout;
33 import java.awt.GridLayout;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.util.ArrayList;
37 import java.util.List;
39 import javax.swing.JButton;
40 import javax.swing.JCheckBox;
41 import javax.swing.JColorChooser;
42 import javax.swing.JLabel;
43 import javax.swing.JPanel;
44 import javax.swing.JTextField;
45 import javax.swing.SwingConstants;
46 import javax.swing.colorchooser.AbstractColorChooserPanel;
54 public class GUserDefinedColours extends JPanel
56 protected JColorChooser colorChooser = new JColorChooser();
58 protected JPanel buttonPanel = new JPanel();
60 protected GridLayout gridLayout = new GridLayout();
62 JPanel lowerPanel = new JPanel();
64 protected JButton okButton = new JButton();
66 protected JButton applyButton = new JButton();
68 protected JButton loadbutton = new JButton();
70 protected JButton savebutton = new JButton();
72 protected JButton cancelButton = new JButton();
74 JPanel namePanel = new JPanel();
76 JLabel jLabel1 = new JLabel();
78 public JTextField schemeName = new JTextField();
80 BorderLayout borderLayout1 = new BorderLayout();
82 JPanel panel1 = new JPanel();
84 JPanel okCancelPanel = new JPanel();
86 JPanel saveLoadPanel = new JPanel();
88 BorderLayout borderLayout3 = new BorderLayout();
90 GridBagLayout gridBagLayout1 = new GridBagLayout();
92 BorderLayout borderLayout2 = new BorderLayout();
94 FlowLayout flowLayout1 = new FlowLayout();
96 BorderLayout borderLayout4 = new BorderLayout();
98 JPanel jPanel4 = new JPanel();
100 BorderLayout borderLayout5 = new BorderLayout();
102 JLabel label = new JLabel();
104 protected JPanel casePanel = new JPanel();
106 public JCheckBox caseSensitive = new JCheckBox();
108 public JCheckBox lcaseColour = new JCheckBox();
110 protected List<JButton> selectedButtons;
113 * Creates a new GUserDefinedColours object.
115 public GUserDefinedColours()
120 } catch (Exception e)
133 private void jbInit() throws Exception
135 this.setLayout(borderLayout4);
136 buttonPanel.setLayout(gridLayout);
137 gridLayout.setColumns(4);
138 gridLayout.setRows(5);
139 okButton.setFont(new java.awt.Font("Verdana", 0, 11));
140 okButton.setText(MessageManager.getString("action.ok"));
141 okButton.addActionListener(new ActionListener()
144 public void actionPerformed(ActionEvent e)
146 okButton_actionPerformed();
149 applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
150 applyButton.setText(MessageManager.getString("action.apply"));
151 applyButton.addActionListener(new ActionListener()
154 public void actionPerformed(ActionEvent e)
156 applyButton_actionPerformed();
159 loadbutton.setFont(new java.awt.Font("Verdana", 0, 11));
160 loadbutton.setText(MessageManager.getString("action.load_scheme"));
161 loadbutton.addActionListener(new ActionListener()
164 public void actionPerformed(ActionEvent e)
166 loadbutton_actionPerformed();
169 savebutton.setFont(new java.awt.Font("Verdana", 0, 11));
170 savebutton.setText(MessageManager.getString("action.save_scheme"));
171 savebutton.addActionListener(new ActionListener()
174 public void actionPerformed(ActionEvent e)
176 savebutton_actionPerformed();
179 cancelButton.setFont(JvSwingUtils.getLabelFont());
180 cancelButton.setText(MessageManager.getString("action.cancel"));
181 cancelButton.addActionListener(new ActionListener()
184 public void actionPerformed(ActionEvent e)
186 cancelButton_actionPerformed();
189 this.setBackground(new Color(212, 208, 223));
190 lowerPanel.setOpaque(false);
191 lowerPanel.setLayout(borderLayout3);
192 colorChooser.setOpaque(false);
193 jLabel1.setFont(JvSwingUtils.getLabelFont());
194 jLabel1.setText(MessageManager.getString("label.name"));
195 namePanel.setMinimumSize(new Dimension(300, 31));
196 namePanel.setOpaque(false);
197 namePanel.setPreferredSize(new Dimension(240, 25));
198 namePanel.setLayout(borderLayout1);
199 schemeName.setFont(JvSwingUtils.getLabelFont());
200 schemeName.setPreferredSize(new Dimension(105, 21));
201 schemeName.setText("");
202 schemeName.setHorizontalAlignment(SwingConstants.CENTER);
203 panel1.setLayout(flowLayout1);
204 panel1.setOpaque(false);
205 okCancelPanel.setOpaque(false);
206 saveLoadPanel.setOpaque(false);
207 jPanel4.setLayout(borderLayout5);
208 label.setFont(new java.awt.Font("Verdana", Font.ITALIC, 10));
209 label.setOpaque(false);
210 label.setPreferredSize(new Dimension(260, 34));
212 MessageManager.formatMessage("label.html_content", new String[]
213 { MessageManager.getString(
214 "label.save_colour_scheme_with_unique_name_added_to_colour_menu") }));
215 caseSensitive.setText(MessageManager.getString("label.case_sensitive"));
216 caseSensitive.addActionListener(new ActionListener()
219 public void actionPerformed(ActionEvent e)
221 caseSensitive_actionPerformed();
225 .setText(MessageManager.getString("label.lower_case_colour"));
226 lcaseColour.setToolTipText(
227 MessageManager.getString("label.lower_case_tip"));
229 saveLoadPanel.add(savebutton);
230 saveLoadPanel.add(loadbutton);
231 okCancelPanel.add(applyButton);
232 okCancelPanel.add(okButton);
233 okCancelPanel.add(cancelButton);
234 lowerPanel.add(saveLoadPanel, java.awt.BorderLayout.NORTH);
235 lowerPanel.add(okCancelPanel, java.awt.BorderLayout.SOUTH);
237 namePanel.add(schemeName, java.awt.BorderLayout.CENTER);
238 namePanel.add(jLabel1, java.awt.BorderLayout.WEST);
239 panel1.add(namePanel, null);
240 panel1.add(buttonPanel, null);
241 panel1.add(casePanel);
242 casePanel.add(caseSensitive);
243 casePanel.add(lcaseColour);
244 panel1.add(lowerPanel, null);
247 jPanel4.add(panel1, java.awt.BorderLayout.CENTER);
248 this.add(jPanel4, java.awt.BorderLayout.CENTER);
249 this.add(colorChooser, java.awt.BorderLayout.EAST);
251 AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
252 // JAL-1360 larger JColorChooser in Java 7 overwrites AA panel; restrict to
253 // swatch picker only
254 if (choosers.length > 3)
256 // Java 7 default has 5 options rather than 3 for choosing colours; keep
259 .setChooserPanels(new AbstractColorChooserPanel[]
263 selectedButtons = new ArrayList<JButton>();
269 protected void okButton_actionPerformed()
276 protected void applyButton_actionPerformed()
286 protected void loadbutton_actionPerformed()
290 protected void savebutton_actionPerformed()
300 protected void cancelButton_actionPerformed()
304 public void caseSensitive_actionPerformed()
309 public void lcaseColour_actionPerformed()