X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FFeatureColour.java;h=c73e32bdfea0551c4c267a5e6fe6978e64f2f47b;hb=3c8a25936a2d805e7e3d7ab82f83b13135406d18;hp=f34478cf0abefd63b2f6f082c99496c8280696df;hpb=aa8a696f0a53363346ac8d41f5501c5ad34497a5;p=jalview.git diff --git a/src/jalview/schemes/FeatureColour.java b/src/jalview/schemes/FeatureColour.java index f34478c..c73e32b 100644 --- a/src/jalview/schemes/FeatureColour.java +++ b/src/jalview/schemes/FeatureColour.java @@ -358,8 +358,8 @@ public class FeatureColour implements FeatureColourI Color maxColour = ColorUtils.parseColourString(maxcol); Color noColour = noValueColour.equals(NO_VALUE_MAX) ? maxColour : (noValueColour.equals(NO_VALUE_NONE) ? null : minColour); - featureColour = new FeatureColour(minColour, maxColour, noColour, min, - max); + featureColour = new FeatureColour(maxColour, minColour, maxColour, + noColour, min, max); featureColour.setColourByLabel(minColour == null); featureColour.setAutoScaled(autoScaled); if (byAttribute) @@ -429,36 +429,25 @@ public class FeatureColour implements FeatureColourI } /** - * Constructor given a simple colour + * Constructor given a simple colour. This also 'primes' a graduated colour + * range, where the maximum colour is the given simple colour, and the minimum + * colour a paler shade of it. This is for convenience when switching from a + * simple colour to a graduated colour scheme. * * @param c */ public FeatureColour(Color c) { - minColour = Color.WHITE; - maxColour = Color.BLACK; - noColour = DEFAULT_NO_COLOUR; - minRed = 0f; - minGreen = 0f; - minBlue = 0f; - deltaRed = 0f; - deltaGreen = 0f; - deltaBlue = 0f; - colour = c; - } + /* + * set max colour to the simple colour, min colour to a paler shade of it + */ + this(c, c == null ? Color.white : ColorUtils.bleachColour(c, 0.9f), + c == null ? Color.black : c, DEFAULT_NO_COLOUR, 0, 0); - /** - * Constructor given a colour range and a score range, defaulting 'no value - * colour' to be the same as minimum colour - * - * @param low - * @param high - * @param min - * @param max - */ - public FeatureColour(Color low, Color high, float min, float max) - { - this(low, high, low, min, max); + /* + * but enforce simple colour for now! + */ + setGraduatedColour(false); } /** @@ -491,29 +480,23 @@ public class FeatureColour implements FeatureColourI } /** - * Copy constructor with new min/max ranges - * - * @param fc - * @param min - * @param max - */ - public FeatureColour(FeatureColour fc, float min, float max) - { - this(fc); - updateBounds(min, max); - } - - /** - * Constructor for a graduated colour + * Constructor that sets both simple and graduated colour values. This allows + * alternative colour schemes to be 'preserved' while switching between them + * to explore their effects on the visualisation. + *

+ * This sets the colour scheme to 'graduated' by default. Override this if + * wanted by calling setGraduatedColour(false) for a simple + * colour, or setColourByLabel(true) for colour by label. * + * @param myColour * @param low * @param high * @param noValueColour * @param min * @param max */ - public FeatureColour(Color low, Color high, Color noValueColour, - float min, float max) + public FeatureColour(Color myColour, Color low, Color high, + Color noValueColour, float min, float max) { if (low == null) { @@ -523,10 +506,10 @@ public class FeatureColour implements FeatureColourI { high = Color.black; } - graduatedColour = true; - colour = null; + colour = myColour; minColour = low; maxColour = high; + setGraduatedColour(true); noColour = noValueColour; threshold = Float.NaN; isHighToLow = min >= max; @@ -558,7 +541,7 @@ public class FeatureColour implements FeatureColourI * Sets the 'graduated colour' flag. If true, also sets 'colour by label' to * false. */ - void setGraduatedColour(boolean b) + public void setGraduatedColour(boolean b) { graduatedColour = b; if (b) @@ -833,9 +816,20 @@ public class FeatureColour implements FeatureColourI sb.append(BAR).append(Format.getHexString(getMinColour())) .append(BAR); sb.append(Format.getHexString(getMaxColour())).append(BAR); - String noValue = minColour.equals(noColour) ? NO_VALUE_MIN - : (maxColour.equals(noColour) ? NO_VALUE_MAX - : NO_VALUE_NONE); + + /* + * 'no value' colour should be null, min or max colour; + * if none of these, coerce to minColour + */ + String noValue = NO_VALUE_MIN; + if (maxColour.equals(noColour)) + { + noValue = NO_VALUE_MAX; + } + if (noColour == null) + { + noValue = NO_VALUE_NONE; + } sb.append(noValue).append(BAR); if (!isAutoScaled()) {