Merge branch 'develop' into features/JAL-2393customMatrices
[jalview.git] / src / jalview / gui / AnnotationColumnChooser.java
index 637eb30..c321e59 100644 (file)
@@ -151,6 +151,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     thresholdPanel.setFont(JvSwingUtils.getLabelFont());
     thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]"));
 
+    percentThreshold.setBackground(Color.white);
+    percentThreshold.setFont(JvSwingUtils.getLabelFont());
+
     JPanel actionPanel = new JPanel();
     actionPanel.setBackground(Color.white);
     actionPanel.setFont(JvSwingUtils.getLabelFont());
@@ -174,8 +177,9 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     ngStructureFilterPanel = new StructureFilterPanel(this);
 
     thresholdPanel.add(getThreshold());
-    thresholdPanel.add(thresholdValue, "wrap");
-    thresholdPanel.add(slider, "grow, span, wrap");
+    thresholdPanel.add(percentThreshold, "wrap");
+    thresholdPanel.add(slider, "grow");
+    thresholdPanel.add(thresholdValue, "span, wrap");
 
     actionPanel.add(ok);
     actionPanel.add(cancel);
@@ -282,12 +286,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)
@@ -308,7 +314,18 @@ 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 + "");
+      
+      if (percentThreshold.isSelected())
+      {
+        thresholdValue
+                .setText(""
+                        + ((getCurrentAnnotation().threshold.value - getCurrentAnnotation().graphMin) * 100f / (getCurrentAnnotation().graphMax - getCurrentAnnotation().graphMin)));
+      }
+      else
+      {
+        thresholdValue.setText(getCurrentAnnotation().threshold.value + "");
+      }
+
       slider.setMajorTickSpacing((int) (range / 10f));
       slider.setEnabled(true);
       thresholdValue.setEnabled(true);
@@ -392,6 +409,7 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
     ap.paintAlignment(true);
   }
 
+
   public ColumnSelection getOldColumnSelection()
   {
     return oldColumnSelection;