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.util.MessageManager;
25 import java.awt.BorderLayout;
26 import java.awt.Color;
27 import java.awt.Dimension;
28 import java.awt.FlowLayout;
29 import java.awt.GridLayout;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
32 import java.awt.event.FocusAdapter;
33 import java.awt.event.FocusEvent;
34 import java.awt.event.MouseAdapter;
35 import java.awt.event.MouseEvent;
37 import javax.swing.JButton;
38 import javax.swing.JCheckBox;
39 import javax.swing.JLabel;
40 import javax.swing.JPanel;
41 import javax.swing.JSlider;
42 import javax.swing.JTextField;
43 import javax.swing.SwingConstants;
51 public class GSliderPanel extends JPanel
53 // this is used for conservation colours, PID colours and redundancy threshold
54 protected JSlider slider = new JSlider();
56 protected JTextField valueField = new JTextField();
58 protected JLabel label = new JLabel();
60 protected JPanel southPanel = new JPanel();
62 GridLayout gridLayout1 = new GridLayout();
64 JPanel jPanel2 = new JPanel();
66 protected JButton applyButton = new JButton();
68 protected JButton undoButton = new JButton();
70 FlowLayout flowLayout1 = new FlowLayout();
72 protected JCheckBox allGroupsCheck = new JCheckBox();
74 BorderLayout borderLayout1 = new BorderLayout();
76 JPanel jPanel1 = new JPanel();
78 BorderLayout borderLayout2 = new BorderLayout();
81 * Creates a new GSliderPanel object.
100 private void jbInit() throws Exception
102 this.setLayout(gridLayout1);
103 slider.setMajorTickSpacing(10);
104 slider.setMinorTickSpacing(1);
105 slider.setPaintTicks(true);
106 slider.setBackground(Color.white);
107 slider.setFont(new java.awt.Font("Verdana", 0, 11));
108 slider.setDoubleBuffered(true);
109 slider.addMouseListener(new MouseAdapter()
112 public void mouseReleased(MouseEvent e)
114 slider_mouseReleased(e);
117 valueField.setFont(new java.awt.Font("Verdana", 0, 11));
118 valueField.setMinimumSize(new Dimension(6, 14));
119 valueField.setPreferredSize(new Dimension(50, 12));
120 valueField.setText("");
121 valueField.setHorizontalAlignment(SwingConstants.CENTER);
122 valueField.addActionListener(new ActionListener()
125 public void actionPerformed(ActionEvent e)
127 valueField_actionPerformed();
130 valueField.addFocusListener(new FocusAdapter()
133 public void focusLost(FocusEvent e)
135 valueField_actionPerformed();
138 label.setFont(new java.awt.Font("Verdana", 0, 11));
139 label.setOpaque(false);
140 label.setHorizontalAlignment(SwingConstants.CENTER);
141 label.setText(MessageManager.getString("label.set_this_label_text"));
142 southPanel.setLayout(borderLayout1);
143 gridLayout1.setRows(2);
144 jPanel2.setLayout(flowLayout1);
145 applyButton.setFont(new java.awt.Font("Verdana", 0, 11));
146 applyButton.setOpaque(false);
147 applyButton.setText(MessageManager.getString("action.apply"));
148 applyButton.addActionListener(new java.awt.event.ActionListener()
151 public void actionPerformed(ActionEvent e)
153 applyButton_actionPerformed(e);
156 undoButton.setEnabled(false);
157 undoButton.setFont(new java.awt.Font("Verdana", 0, 11));
158 undoButton.setOpaque(false);
159 undoButton.setText(MessageManager.getString("action.undo"));
160 undoButton.addActionListener(new java.awt.event.ActionListener()
163 public void actionPerformed(ActionEvent e)
165 undoButton_actionPerformed(e);
168 allGroupsCheck.setEnabled(false);
169 allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11));
170 allGroupsCheck.setOpaque(false);
171 allGroupsCheck.setText(MessageManager
172 .getString("action.apply_all_groups"));
173 allGroupsCheck.addActionListener(new java.awt.event.ActionListener()
176 public void actionPerformed(ActionEvent e)
178 allGroupsCheck_actionPerformed(e);
181 this.setBackground(Color.white);
182 this.setPreferredSize(new Dimension(415, 84));
183 jPanel2.setOpaque(false);
184 southPanel.setOpaque(false);
185 jPanel1.setLayout(borderLayout2);
186 jPanel1.setOpaque(false);
187 this.add(jPanel2, null);
188 jPanel2.add(label, null);
189 jPanel2.add(applyButton, null);
190 jPanel2.add(undoButton, null);
191 this.add(southPanel, null);
192 southPanel.add(jPanel1, java.awt.BorderLayout.EAST);
193 southPanel.add(slider, java.awt.BorderLayout.CENTER);
194 jPanel1.add(valueField, java.awt.BorderLayout.CENTER);
195 jPanel1.add(allGroupsCheck, java.awt.BorderLayout.EAST);
199 * Action on changing the slider text field value
201 protected void valueField_actionPerformed()
205 int i = Integer.valueOf(valueField.getText());
207 } catch (NumberFormatException ex)
209 valueField.setText(String.valueOf(slider.getValue()));
219 protected void applyButton_actionPerformed(ActionEvent e)
229 protected void undoButton_actionPerformed(ActionEvent e)
239 protected void allGroupsCheck_actionPerformed(ActionEvent e)
243 public void slider_mouseReleased(MouseEvent e)