2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.renderer;
23 import jalview.datamodel.SequenceGroup;
24 import jalview.datamodel.SequenceI;
25 import jalview.util.Comparison;
27 import java.awt.Color;
29 public class OverviewResColourFinder extends ResidueColourFinder
31 final Color GAP_COLOUR; // default colour to use at gaps
33 final Color RESIDUE_COLOUR; // default colour to use at residues
35 final Color HIDDEN_COLOUR; // colour for hidden regions
37 boolean useLegacy = false;
39 public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
41 public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
43 public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
47 * Constructor without colour settings (used by applet)
49 public OverviewResColourFinder()
51 this(false, OVERVIEW_DEFAULT_GAP, OVERVIEW_DEFAULT_HIDDEN);
55 * Constructor with colour settings
57 * @param useLegacyColouring
58 * whether to use legacy gap colouring (white gaps, grey residues)
60 * gap colour if not legacy
62 * hidden region colour (transparency applied by rendering code)
64 public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol,
67 if (useLegacyColouring)
69 GAP_COLOUR = Color.white;
70 RESIDUE_COLOUR = Color.lightGray;
71 HIDDEN_COLOUR = hiddenCol;
76 RESIDUE_COLOUR = Color.white;
77 HIDDEN_COLOUR = hiddenCol;
82 public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
85 Color c = seq.getColor(i);
90 char currentChar = seq.getCharAt(i);
91 // In the overview window, gaps are coloured grey, unless the colour scheme
92 // specifies a gap colour, in which case gaps honour the colour scheme
94 boolean isGap = Comparison.isGap(currentChar);
95 if (shader.getColourScheme() == null)
97 return seq.setColor(i, isGap ? GAP_COLOUR : RESIDUE_COLOUR);
99 return seq.setColor(i,
100 isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
101 : shader.findColour(currentChar, i, seq));
105 * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
106 * overview displays the colours regardless.
109 protected Color getResidueBoxColour(boolean showBoxes,
110 ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
113 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
115 ResidueShaderI currentShader = (currentSequenceGroup == null ? shader
116 : currentSequenceGroup.getGroupColourScheme());
117 return getBoxColour(currentShader, seq, i);
121 * Supply hidden colour
123 * @return colour of hidden regions
125 protected Color getHiddenColour()
127 return HIDDEN_COLOUR;