default parameter for colours in annotation shading (JAL-234), ensure
[jalview.git] / src / jalview / appletgui / AnnotationColourChooser.java
index 41c20bd..25e08b0 100755 (executable)
@@ -82,16 +82,17 @@ public class AnnotationColourChooser extends Panel implements
       return;
     }
 
+    minColour.setBackground(av.applet.getDefaultColourParameter("ANNOTATIONCOLOUR_MIN",Color.orange));
+    maxColour.setBackground(av.applet.getDefaultColourParameter("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.setState(acg.predefinedColours);
+      if (!acg.predefinedColours) {
+        minColour.setBackground(acg.getMinColour());
+        maxColour.setBackground(acg.getMaxColour());
+      }
     }
 
     adjusting = true;
@@ -116,6 +117,27 @@ public class AnnotationColourChooser extends Panel implements
     threshold.addItem("Above Threshold");
     threshold.addItem("Below Threshold");
 
+    if (oldcs instanceof AnnotationColourGradient)
+    {
+      AnnotationColourGradient acg = (AnnotationColourGradient) oldcs;
+      annotations.select(acg.getAnnotation());
+      switch (acg.getAboveThreshold()) {
+      case AnnotationColourGradient.NO_THRESHOLD:
+          threshold.select("No Threshold");
+        break;
+      case AnnotationColourGradient.ABOVE_THRESHOLD:
+          threshold.select("Above Threshold");
+        break;
+      case AnnotationColourGradient.BELOW_THRESHOLD:
+        threshold.select("Below Threshold");
+        break;
+        default:
+          throw new Error("Implementation error: don't know about threshold setting for current AnnotationColourGradient.");
+      }
+      thresholdIsMin.setState(acg.thresholdIsMinMax);
+      thresholdValue.setText(""+acg.getAnnotationThreshold());
+    }
+
     adjusting = false;
 
     changeColour();
@@ -430,7 +452,8 @@ public class AnnotationColourChooser extends Panel implements
       }
     }
 
-    ap.paintAlignment(false);
+    // update colours in linked windows
+    ap.paintAlignment(true);
   }
 
   void reset()