X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationColumnChooser.java;h=206b132b58534e51a5772ed7719aa048717fd38a;hb=483ecb5e4541537778844529cc93204f9124b68d;hp=bbd01f6f5f950a42eb881460b1c30a2cd2369e08;hpb=0e3f45fa49bd8fb65beb8d94b9908b9b630976d4;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationColumnChooser.java b/src/jalview/appletgui/AnnotationColumnChooser.java index bbd01f6..206b132 100644 --- a/src/jalview/appletgui/AnnotationColumnChooser.java +++ b/src/jalview/appletgui/AnnotationColumnChooser.java @@ -21,7 +21,7 @@ package jalview.appletgui; import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.ColumnSelection; +import jalview.datamodel.HiddenColumns; import jalview.schemes.AnnotationColourGradient; import jalview.util.MessageManager; import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; @@ -46,7 +46,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.TextEvent; import java.awt.event.TextListener; -import java.util.Iterator; import java.util.Vector; //import javax.swing.JPanel; @@ -110,7 +109,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements private int actionOption = ACTION_OPTION_SELECT; - private ColumnSelection oldColumnSelection; + private HiddenColumns oldHiddenColumns; public AnnotationColumnChooser() { @@ -140,9 +139,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements { return; } - setOldColumnSelection(av.getColumnSelection()); + setOldHiddenColumns(av.getAlignment().getHiddenColumns()); adjusting = true; - Vector list = new Vector(); + Vector list = new Vector<>(); int index = 1; for (int i = 0; i < anns.length; i++) { @@ -167,20 +166,18 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } populateThresholdComboBox(threshold); - + AnnotationColumnChooser lastChooser = av + .getAnnotationColumnSelectionState(); // restore Object state from the previous session if one exists - if (av.getAnnotationColumnSelectionState() != null) + if (lastChooser != null) { - currentSearchPanel = av.getAnnotationColumnSelectionState() - .getCurrentSearchPanel(); - currentStructureFilterPanel = av.getAnnotationColumnSelectionState() + currentSearchPanel = lastChooser.getCurrentSearchPanel(); + currentStructureFilterPanel = lastChooser .getCurrentStructureFilterPanel(); - annotations.select(av.getAnnotationColumnSelectionState() - .getAnnotations().getSelectedIndex()); - threshold.select(av.getAnnotationColumnSelectionState() - .getThreshold().getSelectedIndex()); - actionOption = av.getAnnotationColumnSelectionState() - .getActionOption(); + annotations.select(lastChooser.getAnnotations().getSelectedIndex()); + threshold.select(lastChooser.getThreshold().getSelectedIndex()); + actionOption = lastChooser.getActionOption(); + percentThreshold.setState(lastChooser.percentThreshold.getState()); } try @@ -243,10 +240,10 @@ 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); + thresholdPanel.add(percentThreshold); actionPanel.add(ok); actionPanel.add(cancel); @@ -287,28 +284,18 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements @SuppressWarnings("unchecked") public void reset() { - if (this.getOldColumnSelection() != null) + if (this.getOldHiddenColumns() != null) { av.getColumnSelection().clear(); if (av.getAnnotationColumnSelectionState() != null) { - ColumnSelection oldSelection = av - .getAnnotationColumnSelectionState() - .getOldColumnSelection(); - if (oldSelection != null && oldSelection.getHiddenColumns() != null - && !oldSelection.getHiddenColumns().isEmpty()) - { - for (Iterator itr = oldSelection.getHiddenColumns() - .iterator(); itr.hasNext();) - { - int positions[] = itr.next(); - av.hideColumns(positions[0], positions[1]); - } - } - av.setColumnSelection(oldSelection); + HiddenColumns oldHidden = av.getAnnotationColumnSelectionState() + .getOldHiddenColumns(); + av.getAlignment().setHiddenColumns(oldHidden); } - ap.paintAlignment(true); + av.sendSelection(); + ap.paintAlignment(true, true); } } @@ -318,7 +305,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements { if (!adjusting) { - thresholdValue.setText((slider.getValue() / 1000f) + ""); + setThresholdValueText(); valueChanged(!sliderDragging); } } @@ -350,7 +337,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements sliderDragging = false; valueChanged(true); } - ap.paintAlignment(true); + ap.paintAlignment(true, true); } }); } @@ -361,8 +348,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements if (slider.isEnabled()) { getCurrentAnnotation().threshold.value = slider.getValue() / 1000f; - updateView(); - ap.paintAlignment(false); + updateView(); // this also calls paintAlignment(true,true) } } @@ -396,63 +382,66 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } AnnotationFilterParameter filterParams = new AnnotationFilterParameter(); - setCurrentAnnotation(av.getAlignment().getAlignmentAnnotation()[getAnnotations() - .getSelectedIndex()]); + setCurrentAnnotation(av.getAlignment() + .getAlignmentAnnotation()[getAnnotations().getSelectedIndex()]); - int selectedThresholdItem = getSelectedThresholdItem(getThreshold() - .getSelectedIndex()); + int selectedThresholdItem = getSelectedThresholdItem( + getThreshold().getSelectedIndex()); slider.setEnabled(true); thresholdValue.setEnabled(true); + percentThreshold.setEnabled(true); if (selectedThresholdItem == AnnotationColourGradient.NO_THRESHOLD) { slider.setEnabled(false); thresholdValue.setEnabled(false); thresholdValue.setText(""); + percentThreshold.setEnabled(false); // build filter params } else if (selectedThresholdItem != AnnotationColourGradient.NO_THRESHOLD) { if (getCurrentAnnotation().threshold == null) { - getCurrentAnnotation() - .setThreshold( - new jalview.datamodel.GraphLine( - (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin) / 2f, - "Threshold", Color.black)); + getCurrentAnnotation().setThreshold(new jalview.datamodel.GraphLine( + (getCurrentAnnotation().graphMax + - getCurrentAnnotation().graphMin) / 2f, + "Threshold", Color.black)); } adjusting = true; - float range = getCurrentAnnotation().graphMax * 1000 - - getCurrentAnnotation().graphMin * 1000; + // float range = getCurrentAnnotation().graphMax * 1000 + // - getCurrentAnnotation().graphMin * 1000; slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000)); slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000)); - slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000)); + slider.setValue( + (int) (getCurrentAnnotation().threshold.value * 1000)); setThresholdValueText(); // slider.setMajorTickSpacing((int) (range / 10f)); slider.setEnabled(true); thresholdValue.setEnabled(true); + percentThreshold.setEnabled(true); adjusting = false; // build filter params - filterParams - .setThresholdType(AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); - if (getCurrentAnnotation().graph != AlignmentAnnotation.NO_GRAPH) + filterParams.setThresholdType( + AnnotationFilterParameter.ThresholdType.NO_THRESHOLD); + if (getCurrentAnnotation().isQuantitative()) { filterParams .setThresholdValue(getCurrentAnnotation().threshold.value); if (selectedThresholdItem == AnnotationColourGradient.ABOVE_THRESHOLD) { - filterParams - .setThresholdType(AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD); + filterParams.setThresholdType( + AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD); } else if (selectedThresholdItem == AnnotationColourGradient.BELOW_THRESHOLD) { - filterParams - .setThresholdType(AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD); + filterParams.setThresholdType( + AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD); } } } @@ -483,13 +472,13 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements filterParams.setRegexString(currentSearchPanel.searchBox.getText()); if (currentSearchPanel.displayName.getState()) { - filterParams - .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING); + filterParams.addRegexSearchField( + AnnotationFilterParameter.SearchableAnnotationField.DISPLAY_STRING); } if (currentSearchPanel.description.getState()) { - filterParams - .addRegexSearchField(AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION); + filterParams.addRegexSearchField( + AnnotationFilterParameter.SearchableAnnotationField.DESCRIPTION); } } else @@ -499,10 +488,13 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } } + // show hidden columns here, before changing the column selection in + // filterAnnotations, because showing hidden columns has the side effect of + // adding them to the selection + av.showAllHiddenColumns(); av.getColumnSelection().filterAnnotations( getCurrentAnnotation().annotations, filterParams); - av.showAllHiddenColumns(); if (getActionOption() == ACTION_OPTION_HIDE) { av.hideSelectedColumns(); @@ -510,19 +502,20 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements filterParams = null; av.setAnnotationColumnSelectionState(this); - ap.paintAlignment(true); + av.sendSelection(); + ap.paintAlignment(true, true); } - public ColumnSelection getOldColumnSelection() + public HiddenColumns getOldHiddenColumns() { - return oldColumnSelection; + return oldHiddenColumns; } - public void setOldColumnSelection(ColumnSelection currentColumnSelection) + public void setOldHiddenColumns(HiddenColumns currentHiddenColumns) { - if (currentColumnSelection != null) + if (currentHiddenColumns != null) { - this.oldColumnSelection = new ColumnSelection(currentColumnSelection); + this.oldHiddenColumns = new HiddenColumns(currentHiddenColumns); } } @@ -593,7 +586,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements { String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW; if (av.getAlignment().getAlignmentAnnotation()[getAnnotations() - .getSelectedIndex()].graph != AlignmentAnnotation.NO_GRAPH) + .getSelectedIndex()].isQuantitative()) { currentView = AnnotationColumnChooser.GRAPH_VIEW; } @@ -632,7 +625,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements public void syncState() { - if (aColChooser.getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) + if (aColChooser + .getActionOption() == AnnotationColumnChooser.ACTION_OPTION_HIDE) { furtherAction.select("Hide"); } @@ -660,8 +654,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements } } - public class StructureFilterPanel extends TitledPanel implements - ItemListener + public class StructureFilterPanel extends TitledPanel + implements ItemListener { private AnnotationColumnChooser aColChooser; @@ -890,19 +884,8 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements @Override public void actionPerformed(ActionEvent evt) { - if (evt.getSource() == thresholdValue) - { - try - { - float f = new Float(thresholdValue.getText()).floatValue(); - slider.setValue((int) (f * 1000)); - adjustmentValueChanged(null); - } catch (NumberFormatException ex) - { - } - } - else if (evt.getSource() == ok) + if (evt.getSource() == ok) { ok_actionPerformed(null); }