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(50);
\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
95 * @param ap DOCUMENT ME!
\r
96 * @param cs DOCUMENT ME!
\r
97 * @param source DOCUMENT ME!
\r
99 * @return DOCUMENT ME!
\r
101 public static int setConservationSlider(AlignmentPanel ap,
\r
102 ColourSchemeI cs, String source)
\r
104 SliderPanel sp = null;
\r
105 ConservationColourScheme ccs = (ConservationColourScheme) cs;
\r
107 if (conservationSlider == null)
\r
109 sp = new SliderPanel(ap, ccs.inc, 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 = 50;
\r
181 if (cs instanceof ResidueColourScheme)
\r
183 threshold = (((ResidueColourScheme) cs).getThreshold());
\r
185 else if (cs instanceof ScoreColourScheme)
\r
187 threshold = (((ScoreColourScheme) cs).getThreshold());
\r
190 if (PIDSlider == null)
\r
192 pid = new SliderPanel(ap, threshold, false, cs);
\r
193 PIDSlider = new JInternalFrame();
\r
194 PIDSlider.setContentPane(pid);
\r
195 PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
199 pid = (SliderPanel) PIDSlider.getContentPane();
\r
203 PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")");
\r
205 if (ap.av.alignment.getGroups() != null)
\r
207 pid.setAllGroupsCheckEnabled(true);
\r
211 pid.setAllGroupsCheckEnabled(false);
\r
214 return pid.getValue();
\r
220 public static void showPIDSlider()
\r
224 conservationSlider.setClosed(true);
\r
225 conservationSlider = null;
\r
227 catch (Exception ex)
\r
231 if (!PIDSlider.isVisible())
\r
233 Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90,
\r
235 PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
236 PIDSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
\r
238 public void internalFrameClosed(
\r
239 javax.swing.event.InternalFrameEvent e)
\r
244 PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
\r
251 * @param i DOCUMENT ME!
\r
253 public void valueChanged(int i)
\r
260 ColourSchemeI toChange = null;
\r
261 Vector allGroups = null;
\r
262 int groupIndex = 0;
\r
264 if (allGroupsCheck.isSelected())
\r
266 allGroups = ap.av.alignment.getGroups();
\r
267 groupIndex = allGroups.size() - 1;
\r
274 while (groupIndex > -1)
\r
276 if (allGroups != null)
\r
278 toChange = ((SequenceGroup) allGroups.get(groupIndex)).cs;
\r
280 if (toChange == null)
\r
288 if (forConservation)
\r
290 if (toChange instanceof ConservationColourScheme)
\r
292 ((ConservationColourScheme) toChange).inc = i;
\r
297 ((ResidueColourScheme) toChange).setThreshold(i);
\r
303 ap.seqPanel.seqCanvas.repaint();
\r
309 * @param b DOCUMENT ME!
\r
311 public void setAllGroupsCheckEnabled(boolean b)
\r
313 allGroupsCheck.setEnabled(b);
\r
319 * @param e DOCUMENT ME!
\r
321 public void valueField_actionPerformed(ActionEvent e)
\r
325 int i = Integer.parseInt(valueField.getText());
\r
326 slider.setValue(i);
\r
328 catch (Exception ex)
\r
330 valueField.setText(slider.getValue() + "");
\r
337 * @param value DOCUMENT ME!
\r
339 public void setValue(int value)
\r
341 slider.setValue(value);
\r
347 * @return DOCUMENT ME!
\r
349 public int getValue()
\r
351 return Integer.parseInt(valueField.getText());
\r