1 package jalview.appletgui;
3 import jalview.datamodel.AlignmentAnnotation;
4 import jalview.schemes.AnnotationColourGradient;
5 import jalview.util.MessageManager;
7 import javax.swing.JButton;
8 import javax.swing.JCheckBox;
9 import javax.swing.JFrame;
10 import javax.swing.JPanel;
11 import javax.swing.JScrollBar;
12 import javax.swing.JTextField;
13 import java.awt.event.ActionEvent;
14 import java.util.Vector;
18 @SuppressWarnings("serial")
19 public abstract class AnnotationRowFilter extends JPanel
21 protected AlignViewport av;
23 protected AlignmentPanel ap;
25 protected int[] annmap;
27 protected boolean enableSeqAss = false;
29 private AlignmentAnnotation currentAnnotation;
31 protected boolean adjusting = false;
33 protected JCheckBox currentColours = new JCheckBox();
35 protected JPanel minColour = new JPanel();
37 protected JPanel maxColour = new JPanel();
39 protected JCheckBox seqAssociated = new JCheckBox();
41 protected JCheckBox thresholdIsMin = new JCheckBox();
43 protected JScrollBar slider = new JScrollBar(JScrollBar.HORIZONTAL);
45 protected JTextField thresholdValue = new JTextField(20);
47 protected JFrame frame;
49 protected JButton ok = new JButton();
51 protected JButton cancel = new JButton();
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 AlignmentAnnotation getCurrentAnnotation()
184 return currentAnnotation;
187 public void setCurrentAnnotation(AlignmentAnnotation currentAnnotation)
189 this.currentAnnotation = currentAnnotation;
192 public abstract void valueChanged(boolean updateAllAnnotation);
194 public abstract void updateView();
196 public abstract void reset();