JAL-2055 removed stub first version of colours
[jalview.git] / src / jalview / schemes / GraduatedColor.java
index 4f1cb58..e6aced3 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.schemes;
 
+import jalview.api.FeatureColourI;
 import jalview.datamodel.SequenceFeature;
 
 import java.awt.Color;
@@ -103,6 +104,7 @@ public class GraduatedColor
     thrsh = oldcs.thrsh;
     autoScale = oldcs.autoScale;
     colourByLabel = oldcs.colourByLabel;
+    colourAlternately = oldcs.colourAlternately;
   }
 
   /**
@@ -118,6 +120,11 @@ public class GraduatedColor
     updateBounds(min, max);
   }
 
+  public GraduatedColor(FeatureColourI col)
+  {
+    setColourByLabel(col.isColourByLabel());
+  }
+
   public Color getMinColor()
   {
     return new Color(lr, lg, lb);
@@ -145,7 +152,7 @@ public class GraduatedColor
   public boolean isColored(SequenceFeature feature)
   {
     float val = feature.getScore();
-    if (val == Float.NaN)
+    if (Float.isNaN(val))
     {
       return true;
     }
@@ -153,7 +160,7 @@ public class GraduatedColor
     {
       return true;
     }
-    if (this.thrsh == Float.NaN)
+    if (Float.isNaN(this.thrsh))
     {
       return true;
     }
@@ -176,6 +183,8 @@ public class GraduatedColor
 
   private boolean colourByLabel = false;
 
+  private boolean colourAlternately = false;
+
   /**
    * 
    * @return true if colourByLabel style is set
@@ -206,12 +215,18 @@ public class GraduatedColor
       }
       return ucs.createColourFromName(feature.getDescription());
     }
+    if (colourAlternately)
+    {
+      int minOrMax = feature.getFeatureNumber() % 2;
+      return minOrMax == 0 ? new Color(lr, lg, lb) : new Color(lr + dr, lg
+              + dg, lb + db);
+    }
     if (range == 0.0)
     {
       return getMaxColor();
     }
     float scr = feature.getScore();
-    if (scr == Float.NaN)
+    if (Float.isNaN(scr))
     {
       return getMinColor();
     }
@@ -295,4 +310,14 @@ public class GraduatedColor
       tolow = false;
     }
   }
+
+  public boolean isColourAlternately()
+  {
+    return colourAlternately;
+  }
+
+  public void setColourAlternately(boolean colourAlternately)
+  {
+    this.colourAlternately = colourAlternately;
+  }
 }