X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationRowFilter.java;h=5efd177e5c6747b1bb33a4417ffb5eb2cd7cfd21;hb=3d0101179759ef157b088ea135423cd909512d9f;hp=97cfa47c788ba495e86f62f3d5e3cd91f6ef82c9;hpb=838e4f91d4a53dd315640dbc9ff6ef7a815ee576;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationRowFilter.java b/src/jalview/appletgui/AnnotationRowFilter.java index 97cfa47..5efd177 100644 --- a/src/jalview/appletgui/AnnotationRowFilter.java +++ b/src/jalview/appletgui/AnnotationRowFilter.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -31,7 +31,6 @@ import java.awt.Panel; import java.awt.Scrollbar; import java.awt.TextField; import java.awt.event.ActionEvent; -import java.util.Vector; @SuppressWarnings("serial") public abstract class AnnotationRowFilter extends Panel @@ -60,6 +59,8 @@ public abstract class AnnotationRowFilter extends Panel protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL); + protected Checkbox percentThreshold = new Checkbox(); + protected TextField thresholdValue = new TextField(20); protected Frame frame; @@ -85,45 +86,6 @@ public abstract class AnnotationRowFilter extends Panel } - 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; @@ -171,26 +133,63 @@ public abstract class AnnotationRowFilter extends Panel updateView(); } + /** + * update the text field from the threshold slider. preserves state of + * 'adjusting' so safe to call in init. + */ + protected void setThresholdValueText() + { + boolean oldadj = adjusting; + adjusting = true; + if (percentThreshold.getState()) + { + double scl = slider.getMaximum() - slider.getMinimum(); + scl = (slider.getValue() - slider.getMinimum()) / scl; + thresholdValue.setText(100f * scl + ""); + } + else + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + } + thresholdValue.setCaretPosition(0); + adjusting = oldadj; + } + public void thresholdValue_actionPerformed(ActionEvent e) { try { float f = Float.parseFloat(thresholdValue.getText()); - slider.setValue((int) (f * 1000)); - updateView(); + if (percentThreshold.getState()) + { + int pos = slider.getMinimum() + + (int) ((slider.getMaximum() - slider.getMinimum()) * f + / 100f); + slider.setValue(pos); + } + else + { + slider.setValue((int) (f * 1000)); + } + valueChanged(false); } catch (NumberFormatException ex) { } } + protected void percentageValue_actionPerformed() + { + setThresholdValueText(); + } + protected void populateThresholdComboBox(Choice threshold) { threshold.addItem(MessageManager - .getString("label.threshold_feature_no_thereshold")); + .getString("label.threshold_feature_no_threshold")); threshold.addItem(MessageManager - .getString("label.threshold_feature_above_thereshold")); + .getString("label.threshold_feature_above_threshold")); threshold.addItem(MessageManager - .getString("label.threshold_feature_below_thereshold")); + .getString("label.threshold_feature_below_threshold")); } public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()