X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FOverviewResColourFinder.java;h=8206b32e30ee94962236b51e8b2fdc43a41bf2b3;hb=f300e30df117ff4be7d1df5c781161efd0285e5f;hp=ec638a7a0ac11ac2dc6bcc7df8aad13078f3616c;hpb=d735b6b655d0689760abf7e5063c36200310a544;p=jalview.git diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index ec638a7..8206b32 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -28,58 +28,99 @@ import java.awt.Color; public class OverviewResColourFinder extends ResidueColourFinder { - final Color GAP_COLOUR = new Color(240, 240, 240); + public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray; - @Override - public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) + 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; // RGB value of gapColour + + final Color residueColour; // colour to use for uncoloured residues + + 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); + } - // 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) + /** + * 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 = GAP_COLOUR; - } - else - { - resBoxColour = shader.findColour(currentChar, i, seq); - } + gapColour = Color.white; + residueColour = Color.lightGray; } - else if (Comparison.isGap(currentChar)) + else { - resBoxColour = GAP_COLOUR; + gapColour = gapCol; + residueColour = Color.WHITE; } + gapColourInt = gapColour.getRGB(); + hiddenColour = hiddenCol; + } - return resBoxColour; + /** + * Overrides the method to return the currently configured Overview colours + * for gaps, or residues with no colour scheme set. A custom colour scheme + * which specifies a colour for gaps overrides the normal gap colour. + */ + @Override + public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) + { + char currentChar = seq.getCharAt(i); + boolean isGap = Comparison.isGap(currentChar); + if (shader.getColourScheme() == null) + { + return (isGap ? gapColour : residueColour); + } + return (isGap && !shader.getColourScheme().hasGapColour() ? gapColour + : shader.findColour(currentChar, i, seq)); } /** - * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the - * overview displays the colours regardless. + * In the overview, the showBoxes setting is ignored, as the overview displays + * the colours regardless */ @Override protected Color getResidueBoxColour(boolean showBoxes, - ResidueShaderI shader, - SequenceGroup[] allGroups, SequenceI seq, int i) + ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq, + int i) { - ResidueShaderI currentShader; SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups, i); - if (currentSequenceGroup != null) - { - currentShader = currentSequenceGroup.getGroupColourScheme(); - } - else - { - currentShader = shader; - } - + ResidueShaderI currentShader = (currentSequenceGroup == null ? shader + : currentSequenceGroup.getGroupColourScheme()); return getBoxColour(currentShader, seq, i); } + + /** + * Returns the coloured configured for hidden regions in the Overview + * + * @return + */ + protected Color getHiddenColour() + { + return hiddenColour; + } }