Merge branch 'features/JAL-2432_annotbypercent' into develop
authorJim Procter <jprocter@issues.jalview.org>
Wed, 3 May 2017 11:17:56 +0000 (12:17 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 3 May 2017 11:17:56 +0000 (12:17 +0100)
resources/lang/Messages.properties
src/jalview/analysis/AAFrequency.java
src/jalview/appletgui/AnnotationColumnChooser.java
src/jalview/appletgui/AnnotationRowFilter.java
src/jalview/gui/AnnotationColumnChooser.java
src/jalview/gui/AnnotationRowFilter.java
src/jalview/viewmodel/AlignmentViewport.java

index f28752b..922f482 100644 (file)
@@ -1299,3 +1299,9 @@ warn.name_cannot_be_duplicate = User-defined URL names must be unique and cannot
 label.invalid_name = Invalid Name !
 label.output_seq_details = Output Sequence Details to list all database references
 label.urllinks = Links
+label.quality_descr = Alignment Quality based on Blosum62 scores
+label.conservation_descr = Conservation of total alignment less than {0}% gaps
+label.consensus_descr = PID
+label.complement_consensus_descr = PID for cDNA
+label.strucconsensus_descr = PID for base pairs
+label.occupancy_descr = Number of aligned positions 
\ No newline at end of file
index 3636b5e..b806355 100755 (executable)
@@ -332,9 +332,9 @@ public class AAFrequency
 
       final int gapped = profile.getNonGapped();
 
-      String description = "";
+      String description = "" + gapped;
 
-      gaprow.annotations[i] = new Annotation(description, description,
+      gaprow.annotations[i] = new Annotation("", description,
               '\0', gapped, jalview.util.ColorUtils.bleachColour(
                       Color.DARK_GRAY, (float) scale * gapped));
     }
index bbd01f6..77bb6bb 100644 (file)
@@ -167,20 +167,22 @@ 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()
+      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
@@ -243,10 +245,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);
@@ -318,7 +320,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
   {
     if (!adjusting)
     {
-      thresholdValue.setText((slider.getValue() / 1000f) + "");
+      setThresholdValueText();
       valueChanged(!sliderDragging);
     }
   }
@@ -404,12 +406,14 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
 
     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)
@@ -434,6 +438,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
       // slider.setMajorTickSpacing((int) (range / 10f));
       slider.setEnabled(true);
       thresholdValue.setEnabled(true);
+      percentThreshold.setEnabled(true);
       adjusting = false;
 
       // build filter params
@@ -890,19 +895,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);
     }
index 6ea0fed..315ce3b 100644 (file)
@@ -133,21 +133,26 @@ 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(100 * scl + "");
+      thresholdValue.setText(100f * scl + "");
     }
     else
     {
       thresholdValue.setText((slider.getValue() / 1000f) + "");
     }
     thresholdValue.setCaretPosition(0);
-    adjusting = false;
+    adjusting = oldadj;
   }
   
   public void thresholdValue_actionPerformed(ActionEvent e)
@@ -157,15 +162,15 @@ public abstract class AnnotationRowFilter extends Panel
       float f = Float.parseFloat(thresholdValue.getText());
       if (percentThreshold.getState())
       {
-        slider.setValue(slider.getMinimum()
-                + ((int) ((f / 100f) * (slider.getMaximum() - slider
-                        .getMinimum()))));
+        int pos = slider.getMinimum()
+                + (int) ((slider.getMaximum() - slider.getMinimum()) * f / 100f);
+        slider.setValue(pos);
       }
       else
       {
         slider.setValue((int) (f * 1000));
       }
-      updateView();
+      valueChanged(false);
     } catch (NumberFormatException ex)
     {
     }
index c321e59..d5bc7d1 100644 (file)
@@ -110,20 +110,23 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
 
     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
@@ -315,16 +318,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
       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);
index 1035a6c..a3ce528 100644 (file)
@@ -129,8 +129,13 @@ public abstract class AnnotationRowFilter extends JPanel
     });
   }
 
+  /**
+   * 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.isSelected())
     {
@@ -141,7 +146,7 @@ public abstract class AnnotationRowFilter extends JPanel
     {
       thresholdValue.setText((slider.getValue() / 1000f) + "");
     }
-    adjusting = false;
+    adjusting = oldadj;
   }
   protected void addSliderMouseListeners()
   {
@@ -291,7 +296,7 @@ public abstract class AnnotationRowFilter extends JPanel
     try
     {
       float f = Float.parseFloat(thresholdValue.getText());
-      if (percentThreshold.isEnabled())
+      if (percentThreshold.isSelected())
       {
         slider.setValue(slider.getMinimum()
                 + ((int) ((f / 100f) * (slider.getMaximum() - slider
index 0015299..fa3a8a7 100644 (file)
@@ -62,6 +62,7 @@ import jalview.structure.VamsasSource;
 import jalview.util.Comparison;
 import jalview.util.MapList;
 import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
 import jalview.viewmodel.styles.ViewStyle;
 import jalview.workers.AlignCalcManager;
 import jalview.workers.ComplementConsensusThread;
@@ -1892,7 +1893,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
       {
         initRNAStructure();
       }
-      consensus = new AlignmentAnnotation("Consensus", "PID",
+      consensus = new AlignmentAnnotation("Consensus",
+              MessageManager.getString("label.consensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
       initGapCounts();
@@ -1929,7 +1931,9 @@ public abstract class AlignmentViewport implements AlignViewportI,
         if (doConsensus)
         {
           complementConsensus = new AlignmentAnnotation("cDNA Consensus",
-                  "PID for cDNA", new Annotation[1], 0f, 100f,
+                  MessageManager
+                          .getString("label.complement_consensus_descr"),
+                  new Annotation[1], 0f, 100f,
                   AlignmentAnnotation.BAR_GRAPH);
           initConsensus(complementConsensus);
           return true;
@@ -1957,7 +1961,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
     if (showOccupancy)
     {
       gapcounts = new AlignmentAnnotation("Occupancy",
-              "Number of aligned positions", new Annotation[1], 0f,
+              MessageManager.getString("label.occupancy_descr"),
+              new Annotation[1], 0f,
               alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH);
       gapcounts.hasText = true;
       gapcounts.autoCalculated = true;
@@ -1975,8 +1980,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
       if (conservation == null)
       {
         conservation = new AlignmentAnnotation("Conservation",
-                "Conservation of total alignment less than "
-                        + getConsPercGaps() + "% gaps", new Annotation[1],
+                MessageManager.formatMessage("label.conservation_descr",
+                        getConsPercGaps()), new Annotation[1],
                 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
         conservation.hasText = true;
         conservation.autoCalculated = true;
@@ -1992,7 +1997,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       if (quality == null)
       {
         quality = new AlignmentAnnotation("Quality",
-                "Alignment Quality based on Blosum62 scores",
+                MessageManager.getString("label.quality_descr"),
                 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
         quality.hasText = true;
         quality.autoCalculated = true;
@@ -2005,7 +2010,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
   {
     if (alignment.hasRNAStructure() && strucConsensus == null)
     {
-      strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
+      strucConsensus = new AlignmentAnnotation("StrucConsensus",
+              MessageManager.getString("label.strucconsensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       strucConsensus.hasText = true;
       strucConsensus.autoCalculated = true;