/* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.renderer; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.util.Comparison; import java.awt.Color; public class OverviewResColourFinder extends ResidueColourFinder { 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; // 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() { 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) { gapColour = Color.white; residueColour = Color.lightGray; } else { gapColour = gapCol; residueColour = Color.WHITE; } gapColourInt = gapColour.getRGB(); hiddenColour = hiddenCol; } /** * 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)); } /** * 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) { SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups, i); 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; } }