JAL-2416 order score models by order of addition rather than name
[jalview.git] / src / jalview / jbgui / GSliderPanel.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.jbgui;
22
23 import jalview.util.MessageManager;
24
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;
36
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;
44
45 /**
46  * DOCUMENT ME!
47  * 
48  * @author $author$
49  * @version $Revision$
50  */
51 public class GSliderPanel extends JPanel
52 {
53   // this is used for conservation colours, PID colours and redundancy threshold
54   protected JSlider slider = new JSlider();
55
56   protected JTextField valueField = new JTextField();
57
58   protected JLabel label = new JLabel();
59
60   protected JPanel southPanel = new JPanel();
61
62   GridLayout gridLayout1 = new GridLayout();
63
64   JPanel jPanel2 = new JPanel();
65
66   protected JButton applyButton = new JButton();
67
68   protected JButton undoButton = new JButton();
69
70   FlowLayout flowLayout1 = new FlowLayout();
71
72   protected JCheckBox allGroupsCheck = new JCheckBox();
73
74   BorderLayout borderLayout1 = new BorderLayout();
75
76   JPanel jPanel1 = new JPanel();
77
78   BorderLayout borderLayout2 = new BorderLayout();
79
80   /**
81    * Creates a new GSliderPanel object.
82    */
83   public GSliderPanel()
84   {
85     try
86     {
87       jbInit();
88     } catch (Exception e)
89     {
90       e.printStackTrace();
91     }
92   }
93
94   /**
95    * DOCUMENT ME!
96    * 
97    * @throws Exception
98    *           DOCUMENT ME!
99    */
100   private void jbInit() throws Exception
101   {
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()
110     {
111       @Override
112       public void mouseReleased(MouseEvent e)
113       {
114         slider_mouseReleased(e);
115       }
116     });
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()
123     {
124       @Override
125       public void actionPerformed(ActionEvent e)
126       {
127         valueField_actionPerformed();
128       }
129     });
130     valueField.addFocusListener(new FocusAdapter()
131     {
132       @Override
133       public void focusLost(FocusEvent e)
134       {
135         valueField_actionPerformed();
136       }
137     });
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()
149     {
150       @Override
151       public void actionPerformed(ActionEvent e)
152       {
153         applyButton_actionPerformed(e);
154       }
155     });
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()
161     {
162       @Override
163       public void actionPerformed(ActionEvent e)
164       {
165         undoButton_actionPerformed(e);
166       }
167     });
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()
174     {
175       @Override
176       public void actionPerformed(ActionEvent e)
177       {
178         allGroupsCheck_actionPerformed(e);
179       }
180     });
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);
196   }
197
198   /**
199    * Action on changing the slider text field value
200    */
201   protected void valueField_actionPerformed()
202   {
203     try
204     {
205       int i = Integer.valueOf(valueField.getText());
206       slider.setValue(i);
207     } catch (NumberFormatException ex)
208     {
209       valueField.setText(String.valueOf(slider.getValue()));
210     }
211   }
212
213   /**
214    * DOCUMENT ME!
215    * 
216    * @param e
217    *          DOCUMENT ME!
218    */
219   protected void applyButton_actionPerformed(ActionEvent e)
220   {
221   }
222
223   /**
224    * DOCUMENT ME!
225    * 
226    * @param e
227    *          DOCUMENT ME!
228    */
229   protected void undoButton_actionPerformed(ActionEvent e)
230   {
231   }
232
233   /**
234    * DOCUMENT ME!
235    * 
236    * @param e
237    *          DOCUMENT ME!
238    */
239   protected void allGroupsCheck_actionPerformed(ActionEvent e)
240   {
241   }
242
243   public void slider_mouseReleased(MouseEvent e)
244   {
245
246   }
247 }