*/
package jalview.renderer;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
import jalview.util.Comparison;
import java.awt.Color;
public class OverviewResColourFinder extends ResidueColourFinder
{
- @Override
- public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
+ public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
+
+ public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
+
+ public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
+ .darker();
+
+ final Color gapColour; // colour to use for gaps
+
+ final int gapColourInt;
+
+ final Color residueColour; // colour to use for uncoloured residues
+
+ final int residueColourInt;
+
+ final Color hiddenColour; // colour for hidden regions
+
+ boolean useLegacy = false;
+
+ /**
+ * Constructor without colour settings (used by applet)
+ */
+ public OverviewResColourFinder()
{
- Color resBoxColour = Color.white;
- char currentChar = seq.getCharAt(i);
+ this(false, OVERVIEW_DEFAULT_GAP, OVERVIEW_DEFAULT_HIDDEN);
+ }
- if (shader.getColourScheme() != null)
+ /**
+ * Constructor with colour settings
+ *
+ * @param useLegacyColouring
+ * whether to use legacy gap colouring (white gaps, grey residues)
+ * @param gapCol
+ * gap colour if not legacy
+ * @param hiddenCol
+ * hidden region colour (transparency applied by rendering code)
+ */
+ public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol,
+ Color hiddenCol)
+ {
+ if (useLegacyColouring)
{
- if (Comparison.isGap(currentChar)
- && !shader.getColourScheme().hasGapColour())
- {
- resBoxColour = Color.lightGray;
- }
- else
- {
- resBoxColour = shader.findColour(currentChar, i, seq);
- }
+ gapColour = Color.white;
+ residueColour = Color.lightGray;
}
- else if (Comparison.isGap(currentChar))
+ else
+ {
+ gapColour = gapCol;
+ residueColour = Color.WHITE;
+ }
+ gapColourInt = gapColour.getRGB();
+ residueColourInt = residueColour.getRGB();
+ hiddenColour = hiddenCol;
+ }
+
+ @Override
+ public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
+ {
+ return new Color(getBoxColourInt(shader, seq, i));
+ }
+
+ public int getBoxColourInt(ResidueShaderI shader, SequenceI seq, int i)
+ {
+ 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
+ boolean isGap = Comparison.isGap(currentChar);
+ if (shader.getColourScheme() == null)
{
- resBoxColour = Color.lightGray;
+ return (isGap ? gapColourInt : residueColourInt);
}
+ return (isGap && !shader.getColourScheme().hasGapColour() ? gapColourInt
+ : shader.findColourInt(currentChar, i, seq));
+ }
+
+ @Override
+ public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
+ SequenceGroup[] allGroups, final SequenceI seq, int i,
+ FeatureColourFinder finder)
+ {
+ Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq, i);
+
+ // if there's a FeatureColourFinder we might override the residue colour
+ // here with feature colouring
+ col = finder == null || finder.noFeaturesDisplayed() ? col
+ : finder.findFeatureColour(col, seq, i);
+ return col;
+ }
+
+
+ public int getResidueColourInt(boolean showBoxes, ResidueShaderI shader,
+ SequenceGroup[] allGroups, final SequenceI seq, int i,
+ FeatureColourFinder finder)
+ {
+ int col = getResidueBoxColourInt(showBoxes, shader, allGroups, seq, i);
+
+ // if there's a FeatureColourFinder we might override the residue colour
+ // here with feature colouring
+ col = finder == null || finder.noFeaturesDisplayed() ? col
+ : finder.findFeatureColourInt(col, seq, i);
+ return col;
+ }
- return resBoxColour;
+ @Override
+ protected Color getResidueBoxColour(boolean showBoxes,
+ ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
+ int i)
+ {
+ return new Color(
+ getResidueBoxColourInt(showBoxes, shader, allGroups, seq, i));
+ }
+
+ /**
+ * In the overview, the showBoxes setting is ignored, as the overview displays
+ * the colours regardless.
+ */
+ protected int getResidueBoxColourInt(boolean showBoxes,
+ ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
+ int i)
+ {
+ SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
+ i);
+ ResidueShaderI currentShader = (currentSequenceGroup == null ? shader
+ : currentSequenceGroup.getGroupColourScheme());
+ return getBoxColourInt(currentShader, seq, i);
+ }
+
+ /**
+ * Supply hidden colour
+ *
+ * @return colour of hidden regions
+ */
+ protected Color getHiddenColour()
+ {
+ return hiddenColour;
}
}