@Override
public Color findColour(char c, int j, SequenceI seq)
{
- Color currentColour;
+ Color colour = Color.white;
- if (colors != null && symbolIndex != null && (threshold == 0)
- || aboveThreshold(c, j))
+ if (colors != null && symbolIndex != null)
{
- currentColour = colors[symbolIndex[c]];
+ colour = colors[symbolIndex[c]];
}
- else
+ colour = adjustColour(c, j, colour);
+
+ return colour;
+ }
+
+ /**
+ * Adjusts colour by applying thresholding or conservation shading, if in
+ * force. That is
+ * <ul>
+ * <li>if there is a threshold set for colouring, and the residue doesn't
+ * match the consensus (or a joint consensus) residue, or the consensus score
+ * is not above the threshold, then the colour is set to white</li>
+ * <li>if conservation colouring is selected, the colour is faded by an amount
+ * depending on the conservation score for the column, and the conservation
+ * colour threshold</li>
+ * </ul>
+ *
+ * @param symbol
+ * @param column
+ * @param colour
+ * @return
+ */
+ protected Color adjustColour(char symbol, int column, Color colour)
+ {
+ if (!aboveThreshold(symbol, column))
{
- currentColour = Color.white;
+ colour = Color.white;
}
if (conservationColouring)
{
- currentColour = applyConservation(currentColour, j);
+ colour = applyConservation(colour, column);
}
-
- return currentColour;
+ return colour;
}
/**
*/
public boolean aboveThreshold(char residue, int column)
{
+ if (threshold == 0)
+ {
+ return true;
+ }
if ('a' <= residue && residue <= 'z')
{
// TO UPPERCASE !!!