default parameter for colours in annotation shading (JAL-234), ensure
[jalview.git] / src / jalview / appletgui / AnnotationColourChooser.java
index 485ad5e..25e08b0 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
@@ -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();
@@ -382,13 +404,14 @@ public class AnnotationColourChooser extends Panel implements
     AnnotationColourGradient acg = null;
     if (currentColours.getState())
     {
-      acg = new AnnotationColourGradient(currentAnnotation, av
-              .getGlobalColourScheme(), aboveThreshold);
+      acg = new AnnotationColourGradient(currentAnnotation,
+              av.getGlobalColourScheme(), aboveThreshold);
     }
     else
     {
-      acg = new AnnotationColourGradient(currentAnnotation, minColour
-              .getBackground(), maxColour.getBackground(), aboveThreshold);
+      acg = new AnnotationColourGradient(currentAnnotation,
+              minColour.getBackground(), maxColour.getBackground(),
+              aboveThreshold);
     }
 
     if (currentAnnotation.graphMin == 0f
@@ -421,15 +444,16 @@ public class AnnotationColourChooser extends Panel implements
         }
         else
         {
-          sg.cs = new AnnotationColourGradient(currentAnnotation, minColour
-                  .getBackground(), maxColour.getBackground(),
+          sg.cs = new AnnotationColourGradient(currentAnnotation,
+                  minColour.getBackground(), maxColour.getBackground(),
                   aboveThreshold);
         }
 
       }
     }
 
-    ap.paintAlignment(false);
+    // update colours in linked windows
+    ap.paintAlignment(true);
   }
 
   void reset()