1 package jalview.appletgui;
3 import jalview.datamodel.AlignmentAnnotation;
4 import jalview.schemes.AnnotationColourGradient;
5 import jalview.util.MessageManager;
7 import awt2swing.Button;
8 import awt2swing.Checkbox;
9 import awt2swing.Choice;
10 import awt2swing.Frame;
11 import awt2swing.Panel;
12 import awt2swing.Scrollbar;
13 import awt2swing.TextField;
14 import java.awt.event.ActionEvent;
15 import java.util.Vector;
19 @SuppressWarnings("serial")
20 public abstract class AnnotationRowFilter extends Panel
22 protected AlignViewport av;
24 protected AlignmentPanel ap;
26 protected int[] annmap;
28 protected boolean enableSeqAss = false;
30 private AlignmentAnnotation currentAnnotation;
32 protected boolean adjusting = false;
34 protected Checkbox currentColours = new Checkbox();
36 protected Panel minColour = new Panel();
38 protected Panel maxColour = new Panel();
40 protected Checkbox seqAssociated = new Checkbox();
42 protected Checkbox thresholdIsMin = new Checkbox();
44 protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL);
46 protected TextField thresholdValue = new TextField(20);
48 protected Frame frame;
50 protected Button ok = new Button();
52 protected Button cancel = new Button();
55 * enabled if the user is dragging the slider - try to keep updates to a
58 protected boolean sliderDragging = false;
61 public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)
67 public AnnotationRowFilter()
73 public Vector getAnnotationItems(boolean isSeqAssociated)
75 Vector list = new Vector();
77 int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
78 for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
80 if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)
91 String label = av.getAlignment().getAlignmentAnnotation()[i].label;
92 if (!list.contains(label))
94 anmap[list.size()] = i;
100 if (!isSeqAssociated)
102 anmap[list.size()] = i;
103 list.add(label + "_" + (index++));
107 this.annmap = new int[list.size()];
108 System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
112 protected int getSelectedThresholdItem(int indexValue)
114 int selectedThresholdItem = -1;
117 selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;
119 else if (indexValue == 2)
121 selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;
123 return selectedThresholdItem;
126 public void modelChanged()
128 seqAssociated.setEnabled(enableSeqAss);
131 public void ok_actionPerformed(ActionEvent e)
134 frame.setVisible(false);
137 public void cancel_actionPerformed(ActionEvent e)
140 ap.paintAlignment(true);
141 frame.setVisible(false);
144 public void thresholdCheck_actionPerformed(ActionEvent e)
149 public void annotations_actionPerformed(ActionEvent e)
154 public void threshold_actionPerformed(ActionEvent e)
159 public void thresholdValue_actionPerformed(ActionEvent e)
163 float f = Float.parseFloat(thresholdValue.getText());
164 slider.setValue((int) (f * 1000));
166 } catch (NumberFormatException ex)
172 protected void populateThresholdComboBox(Choice threshold)
174 threshold.addItem(MessageManager
175 .getString("label.threshold_feature_no_thereshold"));
176 threshold.addItem(MessageManager
177 .getString("label.threshold_feature_above_thereshold"));
178 threshold.addItem(MessageManager
179 .getString("label.threshold_feature_below_thereshold"));
183 public AlignmentAnnotation getCurrentAnnotation()
185 return currentAnnotation;
188 public void setCurrentAnnotation(AlignmentAnnotation currentAnnotation)
190 this.currentAnnotation = currentAnnotation;
193 public abstract void valueChanged(boolean updateAllAnnotation);
195 public abstract void updateView();
197 public abstract void reset();