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)
54 public OverviewResColourFinder()
56 this(Color.lightGray, Color.white, Color.darkGray.darker());
60 * Constructor given default colours for gaps, residues and hidden regions
66 public OverviewResColourFinder(Color gaps, Color residues, Color hidden)
69 residueColour = residues;
70 hiddenColour = hidden;
74 public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
76 Color resBoxColour = residueColour;
77 char currentChar = seq.getCharAt(i);
79 // In the overview window, gaps are coloured grey, unless the colour scheme
80 // specifies a gap colour, in which case gaps honour the colour scheme
82 if (shader.getColourScheme() != null)
84 if (Comparison.isGap(currentChar)
85 && (!shader.getColourScheme().hasGapColour()))
87 resBoxColour = gapColour;
91 resBoxColour = shader.findColour(currentChar, i, seq);
94 else if (Comparison.isGap(currentChar))
96 resBoxColour = gapColour;
103 * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
104 * overview displays the colours regardless.
107 protected Color getResidueBoxColour(boolean showBoxes,
108 ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
111 ResidueShaderI currentShader;
112 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
114 if (currentSequenceGroup != null)
116 currentShader = currentSequenceGroup.getGroupColourScheme();
120 currentShader = shader;
123 return getBoxColour(currentShader, seq, i);
127 * Returns the colour used for hidden regions
131 public Color getHiddenColour()
137 * Returns the colour used for gaps, if not overridden by the alignment colour
142 public Color getGapColour()
148 * Returns the colour used for residues (before applying any feature
149 * colouring) if there is no alignment colour scheme
153 public Color getResidueColour()
155 return residueColour;