Clover icon

Coverage Report

  1. Project Clover database Mon Sep 2 2024 17:57:51 BST
  2. Package jalview.jbgui

File GSliderPanel.java

 

Coverage histogram

../../img/srcFileCovDistChart8.png
21% of files have more coverage

Code metrics

0
60
11
1
225
152
13
0.22
5.45
11
1.18

Classes

Class Line # Actions
GSliderPanel 52 60 13
0.7323943473.2%
 

Contributing tests

This file is covered by 4 tests. .

Source view

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.Font;
30    import java.awt.GridLayout;
31    import java.awt.event.ActionEvent;
32    import java.awt.event.ActionListener;
33    import java.awt.event.FocusAdapter;
34    import java.awt.event.FocusEvent;
35    import java.awt.event.MouseAdapter;
36    import java.awt.event.MouseEvent;
37   
38    import javax.swing.JButton;
39    import javax.swing.JCheckBox;
40    import javax.swing.JLabel;
41    import javax.swing.JPanel;
42    import javax.swing.JSlider;
43    import javax.swing.JTextField;
44    import javax.swing.SwingConstants;
45   
46    /**
47    * DOCUMENT ME!
48    *
49    * @author $author$
50    * @version $Revision$
51    */
 
52    public class GSliderPanel extends JPanel
53    {
54    private static final Font VERDANA_11 = new java.awt.Font("Verdana", 0,
55    11);
56   
57    protected static final int FRAME_WIDTH = 420;
58   
59    protected static final int FRAME_HEIGHT = 120;
60   
61    // this is used for conservation colours, PID colours and redundancy threshold
62    protected JSlider slider = new JSlider();
63   
64    protected JTextField valueField = new JTextField();
65   
66    protected JLabel label = new JLabel();
67   
68    protected JPanel southPanel = new JPanel();
69   
70    protected JButton applyButton = new JButton();
71   
72    protected JButton undoButton = new JButton();
73   
74    protected JCheckBox allGroupsCheck = new JCheckBox();
75   
76    /**
77    * Creates a new GSliderPanel object.
78    */
 
79  17 toggle public GSliderPanel()
80    {
81  17 try
82    {
83  17 jbInit();
84    } catch (Exception e)
85    {
86  0 e.printStackTrace();
87    }
88    }
89   
90    /**
91    * Constructs and lays out the controls
92    */
 
93  17 toggle private void jbInit()
94    {
95  17 slider.setMajorTickSpacing(10);
96  17 slider.setMinorTickSpacing(1);
97  17 slider.setPaintTicks(true);
98  17 slider.setBackground(Color.white);
99  17 slider.setFont(VERDANA_11);
100  17 slider.setDoubleBuffered(true);
101  17 slider.addMouseListener(new MouseAdapter()
102    {
 
103  0 toggle @Override
104    public void mouseReleased(MouseEvent e)
105    {
106  0 slider_mouseReleased(e);
107    }
108    });
109  17 valueField.setFont(VERDANA_11);
110  17 valueField.setMinimumSize(new Dimension(6, 14));
111  17 valueField.setPreferredSize(new Dimension(50, 12));
112  17 valueField.setText("");
113  17 valueField.setHorizontalAlignment(SwingConstants.CENTER);
114  17 valueField.addActionListener(new ActionListener()
115    {
 
116  0 toggle @Override
117    public void actionPerformed(ActionEvent e)
118    {
119  0 valueField_actionPerformed();
120    }
121    });
122  17 valueField.addFocusListener(new FocusAdapter()
123    {
 
124  0 toggle @Override
125    public void focusLost(FocusEvent e)
126    {
127  0 valueField_actionPerformed();
128    }
129    });
130  17 label.setFont(VERDANA_11);
131  17 label.setOpaque(false);
132  17 label.setHorizontalAlignment(SwingConstants.CENTER);
133  17 label.setText(MessageManager.getString("label.set_this_label_text"));
134   
135  17 applyButton.setFont(VERDANA_11);
136  17 applyButton.setOpaque(false);
137  17 applyButton.setText(MessageManager.getString("action.apply"));
138  17 applyButton.addActionListener(new ActionListener()
139    {
 
140  0 toggle @Override
141    public void actionPerformed(ActionEvent e)
142    {
143  0 applyButton_actionPerformed(e);
144    }
145    });
146  17 undoButton.setEnabled(false);
147  17 undoButton.setFont(VERDANA_11);
148  17 undoButton.setOpaque(false);
149  17 undoButton.setText(MessageManager.getString("action.undo"));
150  17 undoButton.addActionListener(new ActionListener()
151    {
 
152  0 toggle @Override
153    public void actionPerformed(ActionEvent e)
154    {
155  0 undoButton_actionPerformed(e);
156    }
157    });
158  17 allGroupsCheck.setEnabled(false);
159  17 allGroupsCheck.setFont(VERDANA_11);
160  17 allGroupsCheck.setOpaque(false);
161  17 allGroupsCheck
162    .setText(MessageManager.getString("action.apply_all_groups"));
163   
164  17 this.setLayout(new GridLayout(2, 0));
165  17 this.setBackground(Color.white);
166   
167  17 JPanel firstRow = new JPanel(new FlowLayout());
168  17 firstRow.setOpaque(false);
169  17 firstRow.add(label);
170  17 firstRow.add(applyButton);
171  17 firstRow.add(undoButton);
172  17 this.add(firstRow);
173   
174  17 JPanel jPanel1 = new JPanel(new BorderLayout());
175  17 jPanel1.setOpaque(false);
176  17 jPanel1.add(valueField, BorderLayout.CENTER);
177  17 jPanel1.add(allGroupsCheck, BorderLayout.EAST);
178   
179  17 southPanel.setLayout(new BorderLayout());
180  17 southPanel.setOpaque(false);
181  17 southPanel.add(jPanel1, BorderLayout.EAST);
182  17 southPanel.add(slider, BorderLayout.CENTER);
183  17 this.add(southPanel);
184    }
185   
186    /**
187    * Action on changing the slider text field value
188    */
 
189  0 toggle protected void valueField_actionPerformed()
190    {
191  0 try
192    {
193  0 int i = Integer.valueOf(valueField.getText());
194  0 slider.setValue(i);
195    } catch (NumberFormatException ex)
196    {
197  0 valueField.setText(String.valueOf(slider.getValue()));
198    }
199    }
200   
201    /**
202    * DOCUMENT ME!
203    *
204    * @param e
205    * DOCUMENT ME!
206    */
 
207  0 toggle protected void applyButton_actionPerformed(ActionEvent e)
208    {
209    }
210   
211    /**
212    * DOCUMENT ME!
213    *
214    * @param e
215    * DOCUMENT ME!
216    */
 
217  0 toggle protected void undoButton_actionPerformed(ActionEvent e)
218    {
219    }
220   
 
221  0 toggle public void slider_mouseReleased(MouseEvent e)
222    {
223   
224    }
225    }