-package jalview.appletgui;
-
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.util.MessageManager;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollBar;
-import javax.swing.JTextField;
-import java.awt.event.ActionEvent;
-import java.util.Vector;
-
-
-
-@SuppressWarnings("serial")
-public abstract class AnnotationRowFilter extends JPanel
-{
- protected AlignViewport av;
-
- protected AlignmentPanel ap;
-
- protected int[] annmap;
-
- protected boolean enableSeqAss = false;
-
- private AlignmentAnnotation currentAnnotation;
-
- protected boolean adjusting = false;
-
- protected JCheckBox currentColours = new JCheckBox();
-
- protected JPanel minColour = new JPanel();
-
- protected JPanel maxColour = new JPanel();
-
- protected JCheckBox seqAssociated = new JCheckBox();
-
- protected JCheckBox thresholdIsMin = new JCheckBox();
-
- protected JScrollBar slider = new JScrollBar(JScrollBar.HORIZONTAL);
-
- protected JTextField thresholdValue = new JTextField(20);
-
- protected JFrame frame;
-
- protected JButton ok = new JButton();
-
- protected JButton cancel = new JButton();
-
- /**
- * enabled if the user is dragging the slider - try to keep updates to a
- * minimun
- */
- protected boolean sliderDragging = false;
-
-
- public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)
- {
- this.av = av;
- this.ap = ap;
- }
-
- public AnnotationRowFilter()
- {
-
- }
-
-
- public Vector getAnnotationItems(boolean isSeqAssociated)
- {
- Vector list = new Vector();
- int index = 1;
- int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
- for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
- {
- if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)
- {
- if (isSeqAssociated)
- {
- continue;
- }
- }
- else
- {
- enableSeqAss = true;
- }
- String label = av.getAlignment().getAlignmentAnnotation()[i].label;
- if (!list.contains(label))
- {
- anmap[list.size()] = i;
- list.add(label);
-
- }
- else
- {
- if (!isSeqAssociated)
- {
- anmap[list.size()] = i;
- list.add(label + "_" + (index++));
- }
- }
- }
- this.annmap = new int[list.size()];
- System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
- return list;
- }
-
- protected int getSelectedThresholdItem(int indexValue)
- {
- int selectedThresholdItem = -1;
- if (indexValue == 1)
- {
- selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;
- }
- else if (indexValue == 2)
- {
- selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;
- }
- return selectedThresholdItem;
- }
-
- public void modelChanged()
- {
- seqAssociated.setEnabled(enableSeqAss);
- }
-
- public void ok_actionPerformed(ActionEvent e)
- {
- updateView();
- frame.setVisible(false);
- }
-
- public void cancel_actionPerformed(ActionEvent e)
- {
- reset();
- ap.paintAlignment(true);
- frame.setVisible(false);
- }
-
- public void thresholdCheck_actionPerformed(ActionEvent e)
- {
- updateView();
- }
-
- public void annotations_actionPerformed(ActionEvent e)
- {
- updateView();
- }
-
- public void threshold_actionPerformed(ActionEvent e)
- {
- updateView();
- }
-
- public void thresholdValue_actionPerformed(ActionEvent e)
- {
- try
- {
- float f = Float.parseFloat(thresholdValue.getText());
- slider.setValue((int) (f * 1000));
- updateView();
- } catch (NumberFormatException ex)
- {
- }
- }
-
-
- protected void populateThresholdComboBox(Choice threshold)
- {
- threshold.addItem(MessageManager
- .getString("label.threshold_feature_no_thereshold"));
- threshold.addItem(MessageManager
- .getString("label.threshold_feature_above_thereshold"));
- threshold.addItem(MessageManager
- .getString("label.threshold_feature_below_thereshold"));
- }
-
-
- public AlignmentAnnotation getCurrentAnnotation()
- {
- return currentAnnotation;
- }
-
- public void setCurrentAnnotation(AlignmentAnnotation currentAnnotation)
- {
- this.currentAnnotation = currentAnnotation;
- }
-
- public abstract void valueChanged(boolean updateAllAnnotation);
-
- public abstract void updateView();
-
- public abstract void reset();
+package jalview.appletgui;\r
+\r
+import jalview.datamodel.AlignmentAnnotation;\r
+import jalview.schemes.AnnotationColourGradient;\r
+import jalview.util.MessageManager;\r
+\r
+import javax.swing.JButton;\r
+import javax.swing.JCheckBox;\r
+import javax.swing.JFrame;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollBar;\r
+import javax.swing.JTextField;\r
+import java.awt.event.ActionEvent;\r
+import java.util.Vector;\r
+\r
+\r
+\r
+@SuppressWarnings("serial")\r
+public abstract class AnnotationRowFilter extends JPanel\r
+{\r
+ protected AlignViewport av;\r
+\r
+ protected AlignmentPanel ap;\r
+\r
+ protected int[] annmap;\r
+\r
+ protected boolean enableSeqAss = false;\r
+\r
+ private AlignmentAnnotation currentAnnotation;\r
+\r
+ protected boolean adjusting = false;\r
+\r
+ protected JCheckBox currentColours = new JCheckBox();\r
+\r
+ protected JPanel minColour = new JPanel();\r
+\r
+ protected JPanel maxColour = new JPanel();\r
+\r
+ protected JCheckBox seqAssociated = new JCheckBox();\r
+\r
+ protected JCheckBox thresholdIsMin = new JCheckBox();\r
+\r
+ protected JScrollBar slider = new JScrollBar(JScrollBar.HORIZONTAL);\r
+\r
+ protected JTextField thresholdValue = new JTextField(20);\r
+\r
+ protected JFrame frame;\r
+\r
+ protected JButton ok = new JButton();\r
+\r
+ protected JButton cancel = new JButton();\r
+\r
+ /**\r
+ * enabled if the user is dragging the slider - try to keep updates to a\r
+ * minimun\r
+ */\r
+ protected boolean sliderDragging = false;\r
+\r
+\r
+ public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap)\r
+ {\r
+ this.av = av;\r
+ this.ap = ap;\r
+ }\r
+\r
+ public AnnotationRowFilter()\r
+ {\r
+\r
+ }\r
+\r
+\r
+ public Vector getAnnotationItems(boolean isSeqAssociated)\r
+ {\r
+ Vector list = new Vector();\r
+ int index = 1;\r
+ int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];\r
+ for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)\r
+ {\r
+ if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)\r
+ {\r
+ if (isSeqAssociated)\r
+ {\r
+ continue;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ enableSeqAss = true;\r
+ }\r
+ String label = av.getAlignment().getAlignmentAnnotation()[i].label;\r
+ if (!list.contains(label))\r
+ {\r
+ anmap[list.size()] = i;\r
+ list.add(label);\r
+\r
+ }\r
+ else\r
+ {\r
+ if (!isSeqAssociated)\r
+ {\r
+ anmap[list.size()] = i;\r
+ list.add(label + "_" + (index++));\r
+ }\r
+ }\r
+ }\r
+ this.annmap = new int[list.size()];\r
+ System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);\r
+ return list;\r
+ }\r
+\r
+ protected int getSelectedThresholdItem(int indexValue)\r
+ {\r
+ int selectedThresholdItem = -1;\r
+ if (indexValue == 1)\r
+ {\r
+ selectedThresholdItem = AnnotationColourGradient.ABOVE_THRESHOLD;\r
+ }\r
+ else if (indexValue == 2)\r
+ {\r
+ selectedThresholdItem = AnnotationColourGradient.BELOW_THRESHOLD;\r
+ }\r
+ return selectedThresholdItem;\r
+ }\r
+\r
+ public void modelChanged()\r
+ {\r
+ seqAssociated.setEnabled(enableSeqAss);\r
+ }\r
+\r
+ public void ok_actionPerformed(ActionEvent e)\r
+ {\r
+ updateView();\r
+ frame.setVisible(false);\r
+ }\r
+\r
+ public void cancel_actionPerformed(ActionEvent e)\r
+ {\r
+ reset();\r
+ ap.paintAlignment(true);\r
+ frame.setVisible(false);\r
+ }\r
+\r
+ public void thresholdCheck_actionPerformed(ActionEvent e)\r
+ {\r
+ updateView();\r
+ }\r
+\r
+ public void annotations_actionPerformed(ActionEvent e)\r
+ {\r
+ updateView();\r
+ }\r
+\r
+ public void threshold_actionPerformed(ActionEvent e)\r
+ {\r
+ updateView();\r
+ }\r
+\r
+ public void thresholdValue_actionPerformed(ActionEvent e)\r
+ {\r
+ try\r
+ {\r
+ float f = Float.parseFloat(thresholdValue.getText());\r
+ slider.setValue((int) (f * 1000));\r
+ updateView();\r
+ } catch (NumberFormatException ex)\r
+ {\r
+ }\r
+ }\r
+\r
+\r
+ protected void populateThresholdComboBox(Choice threshold)\r
+ {\r
+ threshold.addItem(MessageManager\r
+ .getString("label.threshold_feature_no_thereshold"));\r
+ threshold.addItem(MessageManager\r
+ .getString("label.threshold_feature_above_thereshold"));\r
+ threshold.addItem(MessageManager\r
+ .getString("label.threshold_feature_below_thereshold"));\r
+ }\r
+\r
+\r
+ public AlignmentAnnotation getCurrentAnnotation()\r
+ {\r
+ return currentAnnotation;\r
+ }\r
+\r
+ public void setCurrentAnnotation(AlignmentAnnotation currentAnnotation)\r
+ {\r
+ this.currentAnnotation = currentAnnotation;\r
+ }\r
+\r
+ public abstract void valueChanged(boolean updateAllAnnotation);\r
+\r
+ public abstract void updateView();\r
+\r
+ public abstract void reset();\r
}
\ No newline at end of file