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.appletgui;
23 import jalview.schemes.AnnotationColourGradient;
24 import jalview.util.MessageManager;
26 import java.awt.Button;
27 import java.awt.Checkbox;
28 import java.awt.Choice;
29 import java.awt.Frame;
30 import java.awt.Panel;
31 import java.awt.Scrollbar;
32 import java.awt.TextField;
33 import java.awt.event.ActionEvent;
34 import java.util.Vector;
36 @SuppressWarnings("serial")
37 public abstract class AnnotationRowFilter extends Panel
39 protected AlignViewport av;
41 protected AlignmentPanel ap;
43 protected int[] annmap;
45 protected boolean enableSeqAss = false;
47 private jalview.datamodel.AlignmentAnnotation currentAnnotation;
49 protected boolean adjusting = false;
51 protected Checkbox currentColours = new Checkbox();
53 protected Panel minColour = new Panel();
55 protected Panel maxColour = new Panel();
57 protected Checkbox seqAssociated = new Checkbox();
59 protected Checkbox thresholdIsMin = new Checkbox();
61 protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL);
63 protected Checkbox percentThreshold = new Checkbox();
65 protected TextField thresholdValue = new TextField(20);
67 protected Frame frame;
69 protected Button ok = new Button();
71 protected Button cancel = new Button();
74 * enabled if the user is dragging the slider - try to keep updates to a
77 protected boolean sliderDragging = false;
79 public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)
85 public AnnotationRowFilter()
90 protected int getSelectedThresholdItem(int indexValue)
92 int selectedThresholdItem = -1;
95 selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;
97 else if (indexValue == 2)
99 selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;
101 return selectedThresholdItem;
104 public void modelChanged()
106 seqAssociated.setEnabled(enableSeqAss);
109 public void ok_actionPerformed(ActionEvent e)
112 frame.setVisible(false);
115 public void cancel_actionPerformed(ActionEvent e)
118 ap.paintAlignment(true);
119 frame.setVisible(false);
122 public void thresholdCheck_actionPerformed(ActionEvent e)
127 public void annotations_actionPerformed(ActionEvent e)
132 public void threshold_actionPerformed(ActionEvent e)
137 protected void setThresholdValueText()
140 if (percentThreshold.getState())
142 double scl = slider.getMaximum() - slider.getMinimum();
143 scl = (slider.getValue() - slider.getMinimum()) / scl;
144 thresholdValue.setText(100 * scl + "");
148 thresholdValue.setText((slider.getValue() / 1000f) + "");
150 thresholdValue.setCaretPosition(0);
154 public void thresholdValue_actionPerformed(ActionEvent e)
158 float f = Float.parseFloat(thresholdValue.getText());
159 if (percentThreshold.getState())
161 slider.setValue(slider.getMinimum()
162 + ((int) ((f / 100f) * (slider.getMaximum() - slider
167 slider.setValue((int) (f * 1000));
170 } catch (NumberFormatException ex)
175 protected void percentageValue_actionPerformed()
177 setThresholdValueText();
180 protected void populateThresholdComboBox(Choice threshold)
182 threshold.addItem(MessageManager
183 .getString("label.threshold_feature_no_threshold"));
184 threshold.addItem(MessageManager
185 .getString("label.threshold_feature_above_threshold"));
186 threshold.addItem(MessageManager
187 .getString("label.threshold_feature_below_threshold"));
190 public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()
192 return currentAnnotation;
195 public void setCurrentAnnotation(
196 jalview.datamodel.AlignmentAnnotation currentAnnotation)
198 this.currentAnnotation = currentAnnotation;
201 public abstract void valueChanged(boolean updateAllAnnotation);
203 public abstract void updateView();
205 public abstract void reset();