feature colour by label flag/style
authorjprocter <Jim Procter>
Fri, 24 Jul 2009 15:13:34 +0000 (15:13 +0000)
committerjprocter <Jim Procter>
Fri, 24 Jul 2009 15:13:34 +0000 (15:13 +0000)
src/jalview/schemes/GraduatedColor.java

index 3d3f321..a99a2f2 100644 (file)
@@ -84,6 +84,7 @@ public class GraduatedColor
     thresholdState = oldcs.thresholdState;
     thrsh = oldcs.thrsh;
     autoScale = oldcs.autoScale;
+    colourByLabel = oldcs.colourByLabel; 
   }
   /**
    * make a new gradient from an old one with a different scale range
@@ -135,8 +136,38 @@ public class GraduatedColor
       return rtn; //  ? tolow : !tolow;
     }
   }
+  /**
+   * default implementor of a getColourFromString method.
+   * TODO: abstract an interface enabling pluggable colour from string
+   */
+  private UserColourScheme ucs = null;
+  private boolean colourByLabel=true;
+  /**
+   * 
+   * @return true if colourByLabel style is set
+   */
+  public boolean isColourByLabel()
+  {
+    return colourByLabel;
+  }
+  /**
+   * @param colourByLabel the colourByLabel to set
+   */
+  public void setColourByLabel(boolean colourByLabel)
+  {
+    this.colourByLabel = colourByLabel;
+  }
   public Color findColor(SequenceFeature feature)
-  {     
+  {
+    if (colourByLabel)
+    {
+      //TODO: allow user defined feature label colourschemes. Colour space is {type,regex,%anytype%}x{description string, regex, keyword}
+      if (ucs==null)
+      {
+        ucs = new UserColourScheme();
+      }
+      return ucs.createColourFromName(feature.getDescription());
+    }
     if (range==0.0)
     {
       return getMaxColor();