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;
16 @SuppressWarnings("serial")
17 public abstract class AnnotationRowFilter extends Panel
19 protected AlignViewport av;
21 protected AlignmentPanel ap;
23 protected int[] annmap;
25 protected boolean enableSeqAss = false;
27 private jalview.datamodel.AlignmentAnnotation currentAnnotation;
29 protected boolean adjusting = false;
31 protected Checkbox currentColours = new Checkbox();
33 protected Panel minColour = new Panel();
35 protected Panel maxColour = new Panel();
37 protected Checkbox seqAssociated = new Checkbox();
39 protected Checkbox thresholdIsMin = new Checkbox();
41 protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL);
43 protected TextField thresholdValue = new TextField(20);
45 protected Frame frame;
47 protected Button ok = new Button();
49 protected Button cancel = new Button();
52 * enabled if the user is dragging the slider - try to keep updates to a
55 protected boolean sliderDragging = false;
57 public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)
63 public AnnotationRowFilter()
68 public Vector getAnnotationItems(boolean isSeqAssociated)
70 Vector list = new Vector();
72 int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
73 for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
75 if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)
86 String label = av.getAlignment().getAlignmentAnnotation()[i].label;
87 if (!list.contains(label))
89 anmap[list.size()] = i;
97 anmap[list.size()] = i;
98 list.add(label + "_" + (index++));
102 this.annmap = new int[list.size()];
103 System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
107 protected int getSelectedThresholdItem(int indexValue)
109 int selectedThresholdItem = -1;
112 selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;
114 else if (indexValue == 2)
116 selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;
118 return selectedThresholdItem;
121 public void modelChanged()
123 seqAssociated.setEnabled(enableSeqAss);
126 public void ok_actionPerformed(ActionEvent e)
129 frame.setVisible(false);
132 public void cancel_actionPerformed(ActionEvent e)
135 ap.paintAlignment(true);
136 frame.setVisible(false);
139 public void thresholdCheck_actionPerformed(ActionEvent e)
144 public void annotations_actionPerformed(ActionEvent e)
149 public void threshold_actionPerformed(ActionEvent e)
154 public void thresholdValue_actionPerformed(ActionEvent e)
158 float f = Float.parseFloat(thresholdValue.getText());
159 slider.setValue((int) (f * 1000));
161 } catch (NumberFormatException ex)
166 protected void populateThresholdComboBox(Choice threshold)
168 threshold.addItem(MessageManager
169 .getString("label.threshold_feature_no_thereshold"));
170 threshold.addItem(MessageManager
171 .getString("label.threshold_feature_above_thereshold"));
172 threshold.addItem(MessageManager
173 .getString("label.threshold_feature_below_thereshold"));
176 public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()
178 return currentAnnotation;
181 public void setCurrentAnnotation(
182 jalview.datamodel.AlignmentAnnotation currentAnnotation)
184 this.currentAnnotation = currentAnnotation;
187 public abstract void valueChanged(boolean updateAllAnnotation);
189 public abstract void updateView();
191 public abstract void reset();