X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FOverviewResColourFinder.java;h=a98f3b30a23a8898f6d09f11ae66eb7b193b2d59;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=c591f5445997c02e9e25108380afb726edcb6172;hpb=9e95025ca7a686639c1acdc630db8edde72ffc61;p=jalview.git diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index c591f54..a98f3b3 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -22,64 +22,153 @@ 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 { - final Color GAP_COLOUR = new Color(240, 240, 240); + final int GAP_COLOUR; // default colour to use at gaps + + final int RESIDUE_COLOUR; // default colour to use at residues + + final Color HIDDEN_COLOUR; // colour for hidden regions + + boolean useLegacy = false; + + 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(); + + /** + * Constructor without colour settings (used by applet) + */ + public OverviewResColourFinder() + { + this(false, OVERVIEW_DEFAULT_GAP, OVERVIEW_DEFAULT_HIDDEN); + } + + /** + * 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) + { + GAP_COLOUR = Color.white.getRGB(); + RESIDUE_COLOUR = Color.lightGray.getRGB(); + } + else + { + GAP_COLOUR = gapCol.getRGB(); + RESIDUE_COLOUR = Color.white.getRGB(); + } + HIDDEN_COLOUR = hiddenCol; + } @Override + /** + * for Test suite only. + */ public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) { - Color resBoxColour = Color.white; - char currentChar = seq.getCharAt(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 - if (shader.getColourScheme() != null) + boolean isGap = Comparison.isGap(currentChar); + if (shader.getColourScheme() == null) { - if (!shader.getColourScheme().hasGapColour() - && Comparison.isGap(currentChar)) - { - resBoxColour = GAP_COLOUR; - } - else - { - resBoxColour = shader.findColour(currentChar, i, seq); - } + return (isGap ? GAP_COLOUR : RESIDUE_COLOUR); } - else if (Comparison.isGap(currentChar)) + return (isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR + : shader.findColourInt(currentChar, i, seq)); + } + + /** + * For test suite only. + */ + @Override + public Color getResidueColour(boolean showBoxes, ResidueShaderI shader, + SequenceGroup[] allGroups, final SequenceI seq, int i, + FeatureColourFinder finder) + { + return new Color(getResidueColourInt(showBoxes, shader, allGroups, seq, + i, finder)); + } + + + public int getResidueColourInt(boolean showBoxes, ResidueShaderI shader, + SequenceGroup[] allGroups, final SequenceI seq, int i, + FeatureColourFinder finder) + { + + int c = seq.getColor(i); + if (c != 0) { - resBoxColour = GAP_COLOUR; + return c; } - return resBoxColour; + int col = getResidueBoxColourInt(showBoxes, shader, allGroups, seq, i); + + // if there's a FeatureColourFinder we might override the residue colour + // here with feature colouring + return seq.setColor(i, + finder == null || finder.noFeaturesDisplayed() ? col + : finder.findFeatureColourInt(col, seq, i)); } /** - * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the - * overview displays the colours regardless. + * For test suite only. */ @Override protected Color getResidueBoxColour(boolean showBoxes, - ResidueShaderI shader, - SequenceGroup[] allGroups, SequenceI seq, int i) + 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) { - ResidueShaderI currentShader; SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups, i); - if (currentSequenceGroup != null) - { - currentShader = currentSequenceGroup.getGroupColourScheme(); - } - else - { - currentShader = shader; - } + ResidueShaderI currentShader = (currentSequenceGroup == null ? shader + : currentSequenceGroup.getGroupColourScheme()); + return getBoxColourInt(currentShader, seq, i); + } - return getBoxColour(currentShader, seq, i); + /** + * Supply hidden colour + * + * @return colour of hidden regions + */ + protected Color getHiddenColour() + { + return HIDDEN_COLOUR; } }