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.renderer.seqfeatures.FeatureColourFinder;
26 import jalview.util.Comparison;
28 import java.awt.Color;
30 public class OverviewResColourFinder extends ResidueColourFinder
32 final int GAP_COLOUR; // default colour to use at gaps
34 final int RESIDUE_COLOUR; // default colour to use at residues
36 final Color HIDDEN_COLOUR; // colour for hidden regions
38 boolean useLegacy = false;
40 public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
42 public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
44 public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
48 * Constructor without colour settings (used by applet)
50 public OverviewResColourFinder()
52 this(false, OVERVIEW_DEFAULT_GAP, OVERVIEW_DEFAULT_HIDDEN);
56 * Constructor with colour settings
58 * @param useLegacyColouring
59 * whether to use legacy gap colouring (white gaps, grey residues)
61 * gap colour if not legacy
63 * hidden region colour (transparency applied by rendering code)
65 public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol,
68 if (useLegacyColouring)
70 GAP_COLOUR = Color.white.getRGB();
71 RESIDUE_COLOUR = Color.lightGray.getRGB();
75 GAP_COLOUR = gapCol.getRGB();
76 RESIDUE_COLOUR = Color.white.getRGB();
78 HIDDEN_COLOUR = hiddenCol;
81 public int getBoxColourInt(ResidueShaderI shader, SequenceI seq, int i)
83 char currentChar = seq.getCharAt(i);
84 // In the overview window, gaps are coloured grey, unless the colour scheme
85 // specifies a gap colour, in which case gaps honour the colour scheme
87 boolean isGap = Comparison.isGap(currentChar);
88 if (shader.getColourScheme() == null)
90 return (isGap ? GAP_COLOUR : RESIDUE_COLOUR);
92 return (isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
93 : shader.findColourInt(currentChar, i, seq));
96 public int getResidueColourInt(boolean showBoxes, ResidueShaderI shader,
97 SequenceGroup[] allGroups, final SequenceI seq, int i,
98 FeatureColourFinder finder)
101 int c = seq.getColor(i);
107 int col = getResidueBoxColourInt(showBoxes, shader, allGroups, seq,
111 // if there's a FeatureColourFinder we might override the residue colour
112 // here with feature colouring
113 return seq.setColor(i,
114 finder == null || finder.noFeaturesDisplayed() ? col
115 : finder.findFeatureColourInt(col, seq, i));
119 * In the overview, the showBoxes setting is ignored, as the overview displays
120 * the colours regardless.
122 protected int getResidueBoxColourInt(boolean showBoxes,
123 ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
126 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
128 ResidueShaderI currentShader = (currentSequenceGroup == null ? shader
129 : currentSequenceGroup.getGroupColourScheme());
130 return getBoxColourInt(currentShader, seq, i);
134 * Supply hidden colour
136 * @return colour of hidden regions
138 protected Color getHiddenColour()
140 return HIDDEN_COLOUR;