}
if ((threshold == 0) || aboveThreshold(c, j))
{
- if (ann.annotations != null
- && j < ann.annotations.length
+ if (ann.annotations != null && j < ann.annotations.length
&& ann.annotations[j] != null
&& !jalview.util.Comparison.isGap(c))
{
return currentColour;
}
- private Color shadeCalculation(AlignmentAnnotation ann, int j)
+ /**
+ * Returns a graduated colour for the annotation at the given column. If there
+ * is a threshold value, and it is used as the top/bottom of the colour range,
+ * and the value satisfies the threshold condition, then a colour
+ * proportionate to the range from the threshold is calculated. For all other
+ * cases, a colour proportionate to the annotation's min-max range is
+ * calulated. Note that thresholding is _not_ done here (a colour is computed
+ * even if threshold is not passed), but by the renderer.
+ *
+ * @param ann
+ * @param col
+ * @return
+ */
+ Color shadeCalculation(AlignmentAnnotation ann, int col)
{
-
- // calculate a shade
float range = 1f;
+ float value = ann.annotations[col].value;
if (thresholdIsMinMax && ann.threshold != null
&& aboveAnnotationThreshold == ABOVE_THRESHOLD
- && ann.annotations[j].value >= ann.threshold.value)
+ && value >= ann.threshold.value)
{
- range = (ann.annotations[j].value - ann.threshold.value)
+ range = (value - ann.threshold.value)
/ (ann.graphMax - ann.threshold.value);
}
else if (thresholdIsMinMax && ann.threshold != null
&& aboveAnnotationThreshold == BELOW_THRESHOLD
- && ann.annotations[j].value >= ann.graphMin)
+ && value <= ann.threshold.value)
{
- range = (ann.annotations[j].value - ann.graphMin)
- / (ann.threshold.value - ann.graphMin);
+ range = (value - ann.graphMin) / (ann.threshold.value - ann.graphMin);
}
else
{
if (ann.graphMax != ann.graphMin)
{
- range = (ann.annotations[j].value - ann.graphMin)
- / (ann.graphMax - ann.graphMin);
+ range = (value - ann.graphMin) / (ann.graphMax - ann.graphMin);
}
else
{
int db = (int) (blueRange * range + blueMin);
return new Color(dr, dg, db);
-
}
public boolean isPredefinedColours()