1 package jalview.appletgui;
3 import jalview.schemes.AnnotationColourGradient;
4 import jalview.util.MessageManager;
6 import java.awt.Button;
7 import java.awt.Checkbox;
8 import java.awt.Choice;
10 import java.awt.Panel;
11 import java.awt.Scrollbar;
12 import java.awt.TextField;
13 import java.awt.event.ActionEvent;
14 import java.util.Vector;
18 @SuppressWarnings("serial")
19 public abstract class AnnotationRowFilter extends Panel
21 protected AlignViewport av;
23 protected AlignmentPanel ap;
25 protected int[] annmap;
27 protected boolean enableSeqAss = false;
29 private jalview.datamodel.AlignmentAnnotation currentAnnotation;
31 protected boolean adjusting = false;
33 protected Checkbox currentColours = new Checkbox();
35 protected Panel minColour = new Panel();
37 protected Panel maxColour = new Panel();
39 protected Checkbox seqAssociated = new Checkbox();
41 protected Checkbox thresholdIsMin = new Checkbox();
43 protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL);
45 protected TextField thresholdValue = new TextField(20);
47 protected Frame frame;
49 protected Button ok = new Button();
51 protected Button cancel = new Button();
54 * enabled if the user is dragging the slider - try to keep updates to a
57 protected boolean sliderDragging = false;
60 public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)
66 public AnnotationRowFilter()
72 public Vector getAnnotationItems(boolean isSeqAssociated)
74 Vector list = new Vector();
76 int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
77 for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
79 if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)
90 String label = av.getAlignment().getAlignmentAnnotation()[i].label;
91 if (!list.contains(label))
93 anmap[list.size()] = i;
101 anmap[list.size()] = i;
102 list.add(label + "_" + (index++));
106 this.annmap = new int[list.size()];
107 System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
111 protected int getSelectedThresholdItem(int indexValue)
113 int selectedThresholdItem = -1;
116 selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;
118 else if (indexValue == 2)
120 selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;
122 return selectedThresholdItem;
125 public void modelChanged()
127 seqAssociated.setEnabled(enableSeqAss);
130 public void ok_actionPerformed(ActionEvent e)
133 frame.setVisible(false);
136 public void cancel_actionPerformed(ActionEvent e)
139 ap.paintAlignment(true);
140 frame.setVisible(false);
143 public void thresholdCheck_actionPerformed(ActionEvent e)
148 public void annotations_actionPerformed(ActionEvent e)
153 public void threshold_actionPerformed(ActionEvent e)
158 public void thresholdValue_actionPerformed(ActionEvent e)
162 float f = Float.parseFloat(thresholdValue.getText());
163 slider.setValue((int) (f * 1000));
165 } catch (NumberFormatException ex)
171 protected void populateThresholdComboBox(Choice threshold)
173 threshold.addItem(MessageManager
174 .getString("label.threshold_feature_no_thereshold"));
175 threshold.addItem(MessageManager
176 .getString("label.threshold_feature_above_thereshold"));
177 threshold.addItem(MessageManager
178 .getString("label.threshold_feature_below_thereshold"));
182 public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()
184 return currentAnnotation;
187 public void setCurrentAnnotation(
188 jalview.datamodel.AlignmentAnnotation currentAnnotation)
190 this.currentAnnotation = currentAnnotation;
193 public abstract void valueChanged(boolean updateAllAnnotation);
195 public abstract void updateView();
197 public abstract void reset();