From: Jim Procter Date: Thu, 27 Apr 2017 13:56:28 +0000 (+0100) Subject: JAL-1933 JAL-2432 percentile filter for select/hide columns by annotation in applet X-Git-Tag: Release_2_10_2~3^2~124^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6d6c9b65d01adbdd8b624bea6a766165e4497bb6;p=jalview.git JAL-1933 JAL-2432 percentile filter for select/hide columns by annotation in applet --- diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java index a8dff62..d45befc 100644 --- a/src/jalview/appletgui/AnnotationColumnChooser.java +++ b/src/jalview/appletgui/AnnotationColumnChooser.java @@ -219,6 +219,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements // thresholdPanel.setFont(JvSwingUtils.getLabelFont()); // thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]")); + percentThreshold.setLabel("As percentage"); + percentThreshold.addItemListener(this); + actionPanel.setBackground(Color.white); // actionPanel.setFont(JvSwingUtils.getLabelFont()); @@ -239,6 +242,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements ngStructureFilterPanel = new StructureFilterPanel(this); thresholdPanel.setTitle("Threshold Filter"); + thresholdPanel.add(percentThreshold); thresholdPanel.add(getThreshold()); thresholdPanel.add(slider); thresholdPanel.add(thresholdValue); @@ -425,7 +429,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000)); slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000)); slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000)); - thresholdValue.setText(getCurrentAnnotation().threshold.value + ""); + setThresholdValueText(); // slider.setMajorTickSpacing((int) (range / 10f)); slider.setEnabled(true); thresholdValue.setEnabled(true); @@ -574,6 +578,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements { threshold_actionPerformed(null); } + else if (e.getSource() == percentThreshold) + { + if (!adjusting) + { + percentageValue_actionPerformed(); + } + + } } public void selectedAnnotationChanged() diff --git a/src/jalview/appletgui/AnnotationRowFilter.java b/src/jalview/appletgui/AnnotationRowFilter.java index 8d67d71..f1b97eb 100644 --- a/src/jalview/appletgui/AnnotationRowFilter.java +++ b/src/jalview/appletgui/AnnotationRowFilter.java @@ -60,6 +60,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; @@ -132,18 +134,49 @@ public abstract class AnnotationRowFilter extends Panel updateView(); } + protected void setThresholdValueText() + { + adjusting = true; + if (percentThreshold.getState()) + { + double scl = slider.getMaximum() - slider.getMinimum(); + scl = (slider.getValue() - slider.getMinimum()) / scl; + thresholdValue.setText(100 * scl + ""); + } + else + { + thresholdValue.setText((slider.getValue() / 1000f) + ""); + } + thresholdValue.setCaretPosition(0); + adjusting = false; + } + public void thresholdValue_actionPerformed(ActionEvent e) { try { float f = Float.parseFloat(thresholdValue.getText()); - slider.setValue((int) (f * 1000)); + if (percentThreshold.getState()) + { + 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 populateThresholdComboBox(Choice threshold) { threshold.addItem(MessageManager