X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationRowFilter.java;h=1035a6c72e6f44ded96ec678e74eed295a240967;hb=ad69997e7967bae13b30470ca6d1ab74e0bb3046;hp=c1dcee74ce82c6ce9425ee2d284fe50912be730b;hpb=88f7d0a53dc11d3b23148fe0866b502b4b53b0e9;p=jalview.git diff --git a/src/jalview/gui/AnnotationRowFilter.java b/src/jalview/gui/AnnotationRowFilter.java index c1dcee7..1035a6c 100644 --- a/src/jalview/gui/AnnotationRowFilter.java +++ b/src/jalview/gui/AnnotationRowFilter.java @@ -59,16 +59,10 @@ public abstract class AnnotationRowFilter extends JPanel protected int[] annmap; 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 JCheckBox percentThreshold = new JCheckBox(); protected JSlider slider = new JSlider(); @@ -101,13 +95,13 @@ public abstract class AnnotationRowFilter extends JPanel /** * Constructor * - * @param av - * @param ap + * @param viewport + * @param alignPanel */ - public AnnotationRowFilter(AlignViewport av, final AlignmentPanel ap) + public AnnotationRowFilter(AlignViewport viewport, final AlignmentPanel alignPanel) { - this.av = av; - this.ap = ap; + this.av = viewport; + this.ap = alignPanel; thresholdValue.addFocusListener(new FocusAdapter() { @Override @@ -128,13 +122,27 @@ public abstract class AnnotationRowFilter extends JPanel { if (!adjusting) { - thresholdValue.setText((slider.getValue() / 1000f) + ""); + setThresholdValueText(); valueChanged(!sliderDragging); } } }); } + protected void setThresholdValueText() + { + adjusting = true; + if (percentThreshold.isSelected()) + { + thresholdValue.setText("" + (slider.getValue() - slider.getMinimum()) + * 100f / (slider.getMaximum() - slider.getMinimum())); + } + else + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + } + adjusting = false; + } protected void addSliderMouseListeners() { @@ -167,14 +175,14 @@ public abstract class AnnotationRowFilter extends JPanel }); } - /** - * Builds and returns a list of menu items (display text) for choice of - * annotation. Also builds maps between annotations, their positions in the - * list, and their display labels in the list. - * - * @param isSeqAssociated - * @return - */ +/** + * Builds and returns a list of menu items (display text) for choice of + * annotation. Also builds maps between annotations, their positions in the + * list, and their display labels in the list. + * + * @param isSeqAssociated + * @return + */ public Vector getAnnotationItems(boolean isSeqAssociated) { annotationLabels = new HashMap(); @@ -283,13 +291,27 @@ public abstract class AnnotationRowFilter extends JPanel try { float f = Float.parseFloat(thresholdValue.getText()); - slider.setValue((int) (f * 1000)); + if (percentThreshold.isEnabled()) + { + slider.setValue(slider.getMinimum() + + ((int) ((f / 100f) * (slider.getMaximum() - slider + .getMinimum())))); + } + else + { + slider.setValue((int) (f * 1000)); + } updateView(); } catch (NumberFormatException ex) { } } + protected void percentageValue_actionPerformed() + { + setThresholdValueText(); + } + protected void thresholdIsMin_actionPerformed() { updateView(); @@ -376,9 +398,9 @@ public abstract class AnnotationRowFilter extends JPanel return currentAnnotation; } - protected void setCurrentAnnotation(AlignmentAnnotation currentAnnotation) + protected void setCurrentAnnotation(AlignmentAnnotation annotation) { - this.currentAnnotation = currentAnnotation; + this.currentAnnotation = annotation; } protected abstract void valueChanged(boolean updateAllAnnotation); @@ -447,6 +469,18 @@ public abstract class AnnotationRowFilter extends JPanel } }); + percentThreshold.setText(MessageManager.getString("label.as_percentage")); + percentThreshold.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (!adjusting) + { + percentageValue_actionPerformed(); + } + } + }); slider.setPaintLabels(false); slider.setPaintTicks(true); slider.setBackground(Color.white);