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 java.awt.Color;
25 import jalview.datamodel.SequenceGroup;
26 import jalview.datamodel.SequenceI;
27 import jalview.util.Comparison;
29 public class OverviewResColourFinder extends ResidueColourFinder
32 * colour for gaps (unless overridden by colour scheme)
33 * - as set in Preferences, _or_ read from a project file
38 * colour for residues if no colour scheme set (before feature colouring)
39 * - as set in Preferences, _or_ read from a project file
44 * colour for hidden regions
45 * - as set in Preferences, _or_ read from a project file
50 * Constructor without colour settings (used by applet)
55 public OverviewResColourFinder()
57 this(Color.lightGray, Color.white, Color.darkGray.darker());
61 * Constructor given default colours for gaps, residues and hidden regions
67 public OverviewResColourFinder(Color gaps, Color residues, Color hidden)
70 residueColour = residues;
71 hiddenColour = hidden;
75 public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
77 Color resBoxColour = residueColour;
78 char currentChar = seq.getCharAt(i);
80 // In the overview window, gaps are coloured grey, unless the colour scheme
81 // specifies a gap colour, in which case gaps honour the colour scheme
83 if (shader.getColourScheme() != null)
85 if (Comparison.isGap(currentChar)
86 && (!shader.getColourScheme().hasGapColour()))
88 resBoxColour = gapColour;
92 resBoxColour = shader.findColour(currentChar, i, seq);
95 else if (Comparison.isGap(currentChar))
97 resBoxColour = gapColour;
104 * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
105 * overview displays the colours regardless.
108 protected Color getResidueBoxColour(boolean showBoxes,
109 ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
112 ResidueShaderI currentShader;
113 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
115 if (currentSequenceGroup != null)
117 currentShader = currentSequenceGroup.getGroupColourScheme();
121 currentShader = shader;
124 return getBoxColour(currentShader, seq, i);
128 * Returns the colour used for hidden regions
132 public Color getHiddenColour()
138 * Returns the colour used for gaps, if not overridden by the alignment colour
143 public Color getGapColour()
149 * Returns the colour used for residues (before applying any feature
150 * colouring) if there is no alignment colour scheme
154 public Color getResidueColour()
156 return residueColour;