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.gui.Preferences;
26 import jalview.util.Comparison;
28 import java.awt.Color;
30 public class OverviewResColourFinder extends ResidueColourFinder
32 final Color GAP_COLOUR; // default colour to use at gaps
34 final Color RESIDUE_COLOUR; // default colour to use at residues
36 final Color HIDDEN_COLOUR; // colour for hidden regions
38 boolean useLegacy = false;
41 * Constructor without colour settings (used by applet)
43 public OverviewResColourFinder()
45 this(false, Preferences.OVERVIEW_DEFAULT_GAP,
46 Preferences.OVERVIEW_DEFAULT_HIDDEN);
50 * Constructor with colour settings
52 * @param useLegacyColouring
53 * whether to use legacy gap colouring (white gaps, grey residues)
55 * gap colour if not legacy
57 * hidden region colour (transparency applied by rendering code)
59 public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol,
62 if (useLegacyColouring)
64 GAP_COLOUR = Color.white;
65 RESIDUE_COLOUR = Color.lightGray;
66 HIDDEN_COLOUR = hiddenCol;
71 RESIDUE_COLOUR = Color.white;
72 HIDDEN_COLOUR = hiddenCol;
77 public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
79 Color resBoxColour = RESIDUE_COLOUR;
80 char currentChar = seq.getCharAt(i);
82 // In the overview window, gaps are coloured grey, unless the colour scheme
83 // specifies a gap colour, in which case gaps honour the colour scheme
85 if (shader.getColourScheme() != null)
87 if (Comparison.isGap(currentChar)
88 && (!shader.getColourScheme().hasGapColour()))
90 resBoxColour = GAP_COLOUR;
94 resBoxColour = shader.findColour(currentChar, i, seq);
97 else if (Comparison.isGap(currentChar))
99 resBoxColour = GAP_COLOUR;
106 * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
107 * overview displays the colours regardless.
110 protected Color getResidueBoxColour(boolean showBoxes,
111 ResidueShaderI shader,
112 SequenceGroup[] allGroups, SequenceI seq, int i)
114 ResidueShaderI currentShader;
115 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
117 if (currentSequenceGroup != null)
119 currentShader = currentSequenceGroup.getGroupColourScheme();
123 currentShader = shader;
126 return getBoxColour(currentShader, seq, i);
130 * Supply hidden colour
132 * @return colour of hidden regions
134 protected Color getHiddenColour()
136 return HIDDEN_COLOUR;