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 TextField thresholdValue = new TextField(20);
65 protected Frame frame;
67 protected Button ok = new Button();
69 protected Button cancel = new Button();
72 * enabled if the user is dragging the slider - try to keep updates to a
75 protected boolean sliderDragging = false;
77 public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)
83 public AnnotationRowFilter()
88 public Vector getAnnotationItems(boolean isSeqAssociated)
90 Vector list = new Vector();
92 int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
93 for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
95 if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)
106 String label = av.getAlignment().getAlignmentAnnotation()[i].label;
107 if (!list.contains(label))
109 anmap[list.size()] = i;
115 if (!isSeqAssociated)
117 anmap[list.size()] = i;
118 list.add(label + "_" + (index++));
122 this.annmap = new int[list.size()];
123 System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
127 protected int getSelectedThresholdItem(int indexValue)
129 int selectedThresholdItem = -1;
132 selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;
134 else if (indexValue == 2)
136 selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;
138 return selectedThresholdItem;
141 public void modelChanged()
143 seqAssociated.setEnabled(enableSeqAss);
146 public void ok_actionPerformed(ActionEvent e)
149 frame.setVisible(false);
152 public void cancel_actionPerformed(ActionEvent e)
155 ap.paintAlignment(true);
156 frame.setVisible(false);
159 public void thresholdCheck_actionPerformed(ActionEvent e)
164 public void annotations_actionPerformed(ActionEvent e)
169 public void threshold_actionPerformed(ActionEvent e)
174 public void thresholdValue_actionPerformed(ActionEvent e)
178 float f = Float.parseFloat(thresholdValue.getText());
179 slider.setValue((int) (f * 1000));
181 } catch (NumberFormatException ex)
186 protected void populateThresholdComboBox(Choice threshold)
188 threshold.addItem(MessageManager
189 .getString("label.threshold_feature_no_thereshold"));
190 threshold.addItem(MessageManager
191 .getString("label.threshold_feature_above_thereshold"));
192 threshold.addItem(MessageManager
193 .getString("label.threshold_feature_below_thereshold"));
196 public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()
198 return currentAnnotation;
201 public void setCurrentAnnotation(
202 jalview.datamodel.AlignmentAnnotation currentAnnotation)
204 this.currentAnnotation = currentAnnotation;
207 public abstract void valueChanged(boolean updateAllAnnotation);
209 public abstract void updateView();
211 public abstract void reset();