default parameter for colours in annotation shading (JAL-234), ensure
[jalview.git] / src / jalview / gui / AnnotationColourChooser.java
index a05ccf1..639140e 100755 (executable)
@@ -24,6 +24,7 @@ import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.event.*;
 
+import jalview.bin.Cache;
 import jalview.datamodel.*;
 import jalview.schemes.*;
 import java.awt.Dimension;
@@ -92,16 +93,21 @@ public class AnnotationColourChooser extends JPanel
       return;
     }
 
+    // Always get default shading from preferences.
+    minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange));
+    maxColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red));
+
     if (oldcs instanceof AnnotationColourGradient)
     {
       AnnotationColourGradient acg = (AnnotationColourGradient) oldcs;
-      minColour.setBackground(acg.getMinColour());
-      maxColour.setBackground(acg.getMaxColour());
-    }
-    else
-    {
-      minColour.setBackground(Color.orange);
-      maxColour.setBackground(Color.red);
+      currentColours.setSelected(acg.predefinedColours);
+      if (acg.predefinedColours)
+      {
+        
+      } else {
+        minColour.setBackground(acg.getMinColour());
+        maxColour.setBackground(acg.getMaxColour());
+      }
     }
 
     adjusting = true;
@@ -122,6 +128,27 @@ public class AnnotationColourChooser extends JPanel
     threshold.addItem("Above Threshold");
     threshold.addItem("Below Threshold");
 
+    if (oldcs instanceof AnnotationColourGradient)
+    {
+      AnnotationColourGradient acg = (AnnotationColourGradient) oldcs;
+      annotations.setSelectedItem(acg.getAnnotation());
+      switch (acg.getAboveThreshold()) {
+      case AnnotationColourGradient.NO_THRESHOLD:
+          threshold.setSelectedItem("No Threshold");
+        break;
+      case AnnotationColourGradient.ABOVE_THRESHOLD:
+          threshold.setSelectedItem("Above Threshold");
+        break;
+      case AnnotationColourGradient.BELOW_THRESHOLD:
+        threshold.setSelectedItem("Below Threshold");
+        break;
+        default:
+          throw new Error("Implementation error: don't know about threshold setting for current AnnotationColourGradient.");
+      }
+      thresholdIsMin.setSelected(acg.thresholdIsMinMax);
+      thresholdValue.setText(""+acg.getAnnotationThreshold());
+    }
+
     try
     {
       jbInit();
@@ -132,6 +159,7 @@ public class AnnotationColourChooser extends JPanel
     adjusting = false;
 
     changeColour();
+    validate();
 
   }
 
@@ -424,8 +452,8 @@ public class AnnotationColourChooser extends JPanel
 
       }
     }
-
-    ap.paintAlignment(false);
+    // ensure all associated views (overviews, structures, etc) are notified of updated colours.
+    ap.paintAlignment(true);
   }
 
   public void ok_actionPerformed(ActionEvent e)