import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.util.Comparison;
import java.awt.Color;
public class ResidueColourFinder
{
+ private static final Color BACKGROUND_COLOUR = Color.white;
+
+ protected Color GAP_COLOUR=Color.white; // default colour to use at gaps
+
+ protected Color RESIDUE_COLOUR=BACKGROUND_COLOUR; // default colour to use at residues
+
public ResidueColourFinder()
{
}
+ public ResidueColourFinder(Color gapColour)
+ {
+ GAP_COLOUR = gapColour;
+ }
/**
* Get the colour of a residue in a sequence
return getBoxColour(shader, seq, i);
}
- return Color.white;
+ return BACKGROUND_COLOUR;
}
/**
}
/**
- * DOCUMENT ME!
+ * Find the colour for a sequence's position in the alignment
*
* @param shader
* the viewport's colour scheme
*/
public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
{
- Color resBoxColour = Color.white;
+ Color resBoxColour = RESIDUE_COLOUR;
+ char currentChar = seq.getCharAt(i);
+
+ // In the overview window, gaps are coloured grey, unless the colour scheme
+ // specifies a gap colour, in which case gaps honour the colour scheme
+ // settings
if (shader.getColourScheme() != null)
{
- resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
+ if (Comparison.isGap(currentChar)
+ && (!shader.getColourScheme().hasGapColour()))
+ {
+ resBoxColour = GAP_COLOUR;
+ }
+ else
+ {
+ resBoxColour = shader.findColour(currentChar, i, seq);
+ }
}
+ else if (Comparison.isGap(currentChar))
+ {
+ resBoxColour = GAP_COLOUR;
+ }
+
return resBoxColour;
}