2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
21 import jalview.datamodel.*;
\r
23 import jalview.jbgui.*;
\r
25 import jalview.schemes.*;
\r
27 import java.awt.event.*;
\r
31 import javax.swing.*;
\r
32 import javax.swing.event.*;
\r
39 * @version $Revision$
\r
41 public class SliderPanel extends GSliderPanel
\r
43 static JInternalFrame conservationSlider;
\r
44 static JInternalFrame PIDSlider;
\r
46 boolean forConservation = true;
\r
50 * Creates a new SliderPanel object.
\r
52 * @param ap DOCUMENT ME!
\r
53 * @param value DOCUMENT ME!
\r
54 * @param forConserve DOCUMENT ME!
\r
55 * @param cs DOCUMENT ME!
\r
57 public SliderPanel(AlignmentPanel ap, int value, boolean forConserve,
\r
62 forConservation = forConserve;
\r
63 undoButton.setVisible(false);
\r
64 applyButton.setVisible(false);
\r
66 if (forConservation)
\r
68 label.setText("Enter value to increase conservation visibility");
\r
69 slider.setMinimum(0);
\r
70 slider.setMaximum(100);
\r
74 label.setText("Enter % identity above which to colour residues");
\r
75 slider.setMinimum(0);
\r
76 slider.setMaximum(100);
\r
79 slider.addChangeListener(new ChangeListener()
\r
81 public void stateChanged(ChangeEvent evt)
\r
83 valueField.setText(slider.getValue() + "");
\r
84 valueChanged(slider.getValue());
\r
88 slider.setValue(value);
\r
89 valueField.setText(value + "");
\r
96 * @param ap DOCUMENT ME!
\r
97 * @param cs DOCUMENT ME!
\r
98 * @param source DOCUMENT ME!
\r
100 * @return DOCUMENT ME!
\r
102 public static int setConservationSlider(AlignmentPanel ap,
\r
103 ColourSchemeI cs, String source)
\r
105 SliderPanel sp = null;
\r
107 if (conservationSlider == null)
\r
109 sp = new SliderPanel(ap, cs.getConservationInc(), true, cs);
\r
110 conservationSlider = new JInternalFrame();
\r
111 conservationSlider.setContentPane(sp);
\r
112 conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
116 sp = (SliderPanel) conservationSlider.getContentPane();
\r
120 conservationSlider.setTitle("Conservation Colour Increment (" +
\r
123 if (ap.av.alignment.getGroups() != null)
\r
125 sp.setAllGroupsCheckEnabled(true);
\r
129 sp.setAllGroupsCheckEnabled(false);
\r
132 return sp.getValue();
\r
138 public static void showConservationSlider()
\r
142 PIDSlider.setClosed(true);
\r
145 catch (Exception ex)
\r
149 if (!conservationSlider.isVisible())
\r
151 Desktop.addInternalFrame(conservationSlider,
\r
152 conservationSlider.getTitle(), 420, 90, false);
\r
153 conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
\r
155 public void internalFrameClosed(
\r
156 javax.swing.event.InternalFrameEvent e)
\r
158 conservationSlider = null;
\r
161 conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
168 * @param ap DOCUMENT ME!
\r
169 * @param cs DOCUMENT ME!
\r
170 * @param source DOCUMENT ME!
\r
172 * @return DOCUMENT ME!
\r
174 public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs,
\r
177 SliderPanel pid = null;
\r
179 int threshold = cs.getThreshold();
\r
181 if (PIDSlider == null)
\r
183 pid = new SliderPanel(ap, threshold, false, cs);
\r
184 PIDSlider = new JInternalFrame();
\r
185 PIDSlider.setContentPane(pid);
\r
186 PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
190 pid = (SliderPanel) PIDSlider.getContentPane();
\r
194 PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")");
\r
196 if (ap.av.alignment.getGroups() != null)
\r
198 pid.setAllGroupsCheckEnabled(true);
\r
202 pid.setAllGroupsCheckEnabled(false);
\r
205 return pid.getValue();
\r
211 public static void showPIDSlider()
\r
215 conservationSlider.setClosed(true);
\r
216 conservationSlider = null;
\r
218 catch (Exception ex)
\r
222 if (!PIDSlider.isVisible())
\r
224 Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90,
\r
226 PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
227 PIDSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
\r
229 public void internalFrameClosed(
\r
230 javax.swing.event.InternalFrameEvent e)
\r
235 PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
242 * @param i DOCUMENT ME!
\r
244 public void valueChanged(int i)
\r
251 ColourSchemeI toChange = null;
\r
252 Vector allGroups = null;
\r
253 int groupIndex = 0;
\r
255 if (allGroupsCheck.isSelected())
\r
257 allGroups = ap.av.alignment.getGroups();
\r
258 groupIndex = allGroups.size() - 1;
\r
266 while (groupIndex > -1)
\r
268 if (allGroups != null)
\r
270 toChange = ((SequenceGroup) allGroups.get(groupIndex)).cs;
\r
272 if (toChange == null)
\r
280 if (forConservation)
\r
282 if (toChange.conservationApplied())
\r
284 toChange.setConservationInc(i);
\r
289 toChange.setThreshold(i, ap.av.getIgnoreGapsConsensus());
\r
295 ap.seqPanel.seqCanvas.repaint();
\r
301 * @param b DOCUMENT ME!
\r
303 public void setAllGroupsCheckEnabled(boolean b)
\r
305 allGroupsCheck.setEnabled(b);
\r
311 * @param e DOCUMENT ME!
\r
313 public void valueField_actionPerformed(ActionEvent e)
\r
317 int i = Integer.parseInt(valueField.getText());
\r
318 slider.setValue(i);
\r
320 catch (NumberFormatException ex)
\r
322 valueField.setText(slider.getValue() + "");
\r
329 * @param value DOCUMENT ME!
\r
331 public void setValue(int value)
\r
333 slider.setValue(value);
\r
339 * @return DOCUMENT ME!
\r
341 public int getValue()
\r
343 return Integer.parseInt(valueField.getText());
\r