From 7dca81b51ef65870fcb3276d6256792cb8d3b4a9 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 24 Jul 2009 15:13:34 +0000 Subject: [PATCH] feature colour by label flag/style --- src/jalview/schemes/GraduatedColor.java | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/jalview/schemes/GraduatedColor.java b/src/jalview/schemes/GraduatedColor.java index 3d3f321..a99a2f2 100644 --- a/src/jalview/schemes/GraduatedColor.java +++ b/src/jalview/schemes/GraduatedColor.java @@ -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(); -- 1.7.10.2