Merge branch 'features/JAL-2503_filteronquantitativeannotation' into develop
authorJim Procter <jprocter@issues.jalview.org>
Thu, 4 May 2017 13:10:03 +0000 (14:10 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 4 May 2017 13:10:03 +0000 (14:10 +0100)
1  2 
src/jalview/appletgui/AnnotationColumnChooser.java
src/jalview/gui/AnnotationColumnChooser.java

@@@ -167,22 -167,20 +167,22 @@@ public class AnnotationColumnChooser ex
      }
  
      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()
 +      currentSearchPanel = lastChooser
                .getCurrentSearchPanel();
 -      currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
 +      currentStructureFilterPanel = lastChooser
                .getCurrentStructureFilterPanel();
 -      annotations.select(av.getAnnotationColumnSelectionState()
 +      annotations.select(lastChooser
                .getAnnotations().getSelectedIndex());
 -      threshold.select(av.getAnnotationColumnSelectionState()
 +      threshold.select(lastChooser
                .getThreshold().getSelectedIndex());
 -      actionOption = av.getAnnotationColumnSelectionState()
 +      actionOption = lastChooser
                .getActionOption();
 +      percentThreshold.setState(lastChooser.percentThreshold.getState());
      }
  
      try
      ngStructureFilterPanel = new StructureFilterPanel(this);
  
      thresholdPanel.setTitle("Threshold Filter");
      thresholdPanel.add(getThreshold());
      thresholdPanel.add(slider);
      thresholdPanel.add(thresholdValue);
 +    thresholdPanel.add(percentThreshold);
  
      actionPanel.add(ok);
      actionPanel.add(cancel);
    {
      if (!adjusting)
      {
 -      thresholdValue.setText((slider.getValue() / 1000f) + "");
 +      setThresholdValueText();
        valueChanged(!sliderDragging);
      }
    }
  
      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)
        // 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)
+       if (getCurrentAnnotation().isQuantitative())
        {
          filterParams
                  .setThresholdValue(getCurrentAnnotation().threshold.value);
    {
      String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW;
      if (av.getAlignment().getAlignmentAnnotation()[getAnnotations()
-             .getSelectedIndex()].graph != AlignmentAnnotation.NO_GRAPH)
+             .getSelectedIndex()].isQuantitative())
      {
        currentView = AnnotationColumnChooser.GRAPH_VIEW;
      }
    @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);
      }
@@@ -21,7 -21,6 +21,6 @@@
  
  package jalview.gui;
  
- import jalview.datamodel.AlignmentAnnotation;
  import jalview.datamodel.ColumnSelection;
  import jalview.schemes.AnnotationColourGradient;
  import jalview.util.MessageManager;
@@@ -30,7 -29,6 +29,7 @@@ import jalview.viewmodel.annotationfilt
  import java.awt.BorderLayout;
  import java.awt.CardLayout;
  import java.awt.Color;
 +import java.awt.Dimension;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.ItemEvent;
@@@ -89,10 -87,6 +88,10 @@@ public class AnnotationColumnChooser ex
  
    private ColumnSelection oldColumnSelection;
  
 +  protected int MIN_WIDTH = 420;
 +
 +  protected int MIN_HEIGHT = 430;
 +
    public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap)
    {
      super(av, ap);
      Desktop.addInternalFrame(frame,
              MessageManager.getString("label.select_by_annotation"), 520,
              215);
 +    frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
  
      addSliderChangeListener();
      addSliderMouseListeners();
  
      setAnnotations(new JComboBox<String>(getAnnotationItems(false)));
      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()
 +      currentSearchPanel = lastChooser
                .getCurrentSearchPanel();
 -      currentStructureFilterPanel = av.getAnnotationColumnSelectionState()
 +      currentStructureFilterPanel = lastChooser
                .getCurrentStructureFilterPanel();
 -      annotations.setSelectedIndex(av.getAnnotationColumnSelectionState()
 +      annotations.setSelectedIndex(lastChooser
                .getAnnotations().getSelectedIndex());
 -      threshold.setSelectedIndex(av.getAnnotationColumnSelectionState()
 +      threshold.setSelectedIndex(lastChooser
                .getThreshold().getSelectedIndex());
 -      actionOption = av.getAnnotationColumnSelectionState()
 +      actionOption = lastChooser
                .getActionOption();
 +      percentThreshold.setSelected(lastChooser.percentThreshold
 +              .isSelected());
      }
  
      try
        slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
        slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000));
        
 -      if (percentThreshold.isSelected())
 -      {
 -        thresholdValue
 -                .setText(""
 -                        + ((getCurrentAnnotation().threshold.value - getCurrentAnnotation().graphMin) * 100f / (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin)));
 -      }
 -      else
 -      {
 -        thresholdValue.setText(getCurrentAnnotation().threshold.value + "");
 -      }
 +      setThresholdValueText();
  
        slider.setMajorTickSpacing((int) (range / 10f));
        slider.setEnabled(true);
        // build filter params
        filterParams
                .setThresholdType(AnnotationFilterParameter.ThresholdType.NO_THRESHOLD);
-       if (getCurrentAnnotation().graph != AlignmentAnnotation.NO_GRAPH)
+       if (getCurrentAnnotation().isQuantitative())
        {
          filterParams
                  .setThresholdValue(getCurrentAnnotation().threshold.value);
    public void selectedAnnotationChanged()
    {
      String currentView = AnnotationColumnChooser.NO_GRAPH_VIEW;
-     if (av.getAlignment().getAlignmentAnnotation()[annmap[getAnnotations()
-             .getSelectedIndex()]].graph != AlignmentAnnotation.NO_GRAPH)
+     if (av.getAlignment()
+             .getAlignmentAnnotation()[annmap[getAnnotations()
+             .getSelectedIndex()]].isQuantitative())
      {
        currentView = AnnotationColumnChooser.GRAPH_VIEW;
      }