X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fschemes%2FFeatureColour.java;h=3d91b585490b39ee12d053f3b847d65be26ca641;hb=155a17a423e980849fd4dc5f857da1a72b0010b9;hp=c73e32bdfea0551c4c267a5e6fe6978e64f2f47b;hpb=3c8a25936a2d805e7e3d7ab82f83b13135406d18;p=jalview.git
diff --git a/src/jalview/schemes/FeatureColour.java b/src/jalview/schemes/FeatureColour.java
index c73e32b..3d91b58 100644
--- a/src/jalview/schemes/FeatureColour.java
+++ b/src/jalview/schemes/FeatureColour.java
@@ -20,11 +20,14 @@
*/
package jalview.schemes;
+import java.util.Locale;
+
import jalview.api.FeatureColourI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.features.FeatureMatcher;
import jalview.util.ColorUtils;
import jalview.util.Format;
+import jalview.util.MessageManager;
import java.awt.Color;
import java.util.StringTokenizer;
@@ -45,11 +48,18 @@ import java.util.StringTokenizer;
*
the range may be the full value range, or may be limited by the threshold
* value
*
- * colour by (text) value of a named attribute graduated colour by
- * (numeric) value of a named attribute
+ * colour by (text) value of a named attribute
+ * graduated colour by (numeric) value of a named attribute
+ *
*/
public class FeatureColour implements FeatureColourI
{
+ private static final String I18N_LABEL = MessageManager
+ .getString("label.label");
+
+ private static final String I18N_SCORE = MessageManager
+ .getString("label.score");
+
private static final String ABSOLUTE = "abso";
private static final String ABOVE = "above";
@@ -187,19 +197,19 @@ public class FeatureColour implements FeatureColourI
"Expected either 'label' or a colour specification in the line: "
+ descriptor);
}
- if (nextToken.toLowerCase().startsWith(LABEL))
+ if (nextToken.toLowerCase(Locale.ROOT).startsWith(LABEL))
{
byLabel = true;
// get the token after the next delimiter:
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null);
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null);
}
- else if (nextToken.toLowerCase().startsWith(SCORE))
+ else if (nextToken.toLowerCase(Locale.ROOT).startsWith(SCORE))
{
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null);
mincol = (gcol.hasMoreTokens() ? gcol.nextToken() : null);
}
- else if (nextToken.toLowerCase().startsWith(ATTRIBUTE))
+ else if (nextToken.toLowerCase(Locale.ROOT).startsWith(ATTRIBUTE))
{
byAttribute = true;
attName = (gcol.hasMoreTokens() ? gcol.nextToken() : null);
@@ -297,7 +307,7 @@ public class FeatureColour implements FeatureColourI
}
gcol.nextToken(); // skip next '|'
- if (tok.toLowerCase().startsWith(ABSOLUTE))
+ if (tok.toLowerCase(Locale.ROOT).startsWith(ABSOLUTE))
{
minval = gcol.nextToken();
gcol.nextToken(); // skip next '|'
@@ -316,7 +326,7 @@ public class FeatureColour implements FeatureColourI
{
if (minval.length() > 0)
{
- min = new Float(minval).floatValue();
+ min = Float.valueOf(minval).floatValue();
}
} catch (Exception e)
{
@@ -328,7 +338,7 @@ public class FeatureColour implements FeatureColourI
{
if (maxval.length() > 0)
{
- max = new Float(maxval).floatValue();
+ max = Float.valueOf(maxval).floatValue();
}
} catch (Exception e)
{
@@ -373,19 +383,19 @@ public class FeatureColour implements FeatureColourI
{
// threshold type and possibly a threshold value
ttype = gcol.nextToken();
- if (ttype.toLowerCase().startsWith(BELOW))
+ if (ttype.toLowerCase(Locale.ROOT).startsWith(BELOW))
{
featureColour.setBelowThreshold(true);
}
- else if (ttype.toLowerCase().startsWith(ABOVE))
+ else if (ttype.toLowerCase(Locale.ROOT).startsWith(ABOVE))
{
featureColour.setAboveThreshold(true);
}
else
{
- if (!ttype.toLowerCase().startsWith("no"))
+ if (!ttype.toLowerCase(Locale.ROOT).startsWith("no"))
{
- System.err.println(
+ jalview.bin.Console.errPrintln(
"Ignoring unrecognised threshold type : " + ttype);
}
}
@@ -396,22 +406,22 @@ public class FeatureColour implements FeatureColourI
{
gcol.nextToken();
tval = gcol.nextToken();
- featureColour.setThreshold(new Float(tval).floatValue());
+ featureColour.setThreshold(Float.valueOf(tval).floatValue());
} catch (Exception e)
{
- System.err.println("Couldn't parse threshold value as a float: ("
+ jalview.bin.Console.errPrintln("Couldn't parse threshold value as a float: ("
+ tval + ")");
}
}
if (gcol.hasMoreTokens())
{
- System.err.println(
+ jalview.bin.Console.errPrintln(
"Ignoring additional tokens in parameters in graduated colour specification\n");
while (gcol.hasMoreTokens())
{
- System.err.println(BAR + gcol.nextToken());
+ jalview.bin.Console.errPrintln(BAR + gcol.nextToken());
}
- System.err.println("\n");
+ jalview.bin.Console.errPrintln("\n");
}
return featureColour;
} catch (Exception e)
@@ -689,8 +699,8 @@ public class FeatureColour implements FeatureColourI
{
String label = attributeName == null ? feature.getDescription()
: feature.getValueAsString(attributeName);
- return label == null ? noColour : ColorUtils
- .createColourFromName(label);
+ return label == null ? noColour
+ : ColorUtils.createColourFromName(label);
}
if (!isGraduatedColour())
@@ -816,7 +826,7 @@ public class FeatureColour implements FeatureColourI
sb.append(BAR).append(Format.getHexString(getMinColour()))
.append(BAR);
sb.append(Format.getHexString(getMaxColour())).append(BAR);
-
+
/*
* 'no value' colour should be null, min or max colour;
* if none of these, coerce to minColour
@@ -915,4 +925,50 @@ public class FeatureColour implements FeatureColourI
|| (isBelowThreshold() && scr >= threshold));
}
+ @Override
+ public String getDescription()
+ {
+ if (isSimpleColour())
+ {
+ return "r=" + colour.getRed() + ",g=" + colour.getGreen() + ",b="
+ + colour.getBlue();
+ }
+ StringBuilder tt = new StringBuilder();
+ String by = null;
+
+ if (getAttributeName() != null)
+ {
+ by = FeatureMatcher.toAttributeDisplayName(getAttributeName());
+ }
+ else if (isColourByLabel())
+ {
+ by = I18N_LABEL;
+ }
+ else
+ {
+ by = I18N_SCORE;
+ }
+ tt.append(MessageManager.formatMessage("action.by_title_param", by));
+
+ /*
+ * add threshold if any
+ */
+ if (isAboveThreshold() || isBelowThreshold())
+ {
+ tt.append(" (");
+ if (isColourByLabel())
+ {
+ /*
+ * Jalview features file supports the combination of
+ * colour by label or attribute text with score threshold
+ */
+ tt.append(I18N_SCORE).append(" ");
+ }
+ tt.append(isAboveThreshold() ? "> " : "< ");
+ tt.append(getThreshold()).append(")");
+ }
+
+ return tt.toString();
+ }
+
}