Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:38:20 GMT
  2. Package jalview.renderer

File OverviewResColourFinder.java

 

Coverage histogram

../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
22
7
1
158
75
12
0.55
3.14
7
1.71

Classes

Class Line # Actions
OverviewResColourFinder 29 22 12
0.945945994.6%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.renderer;
22   
23    import java.awt.Color;
24   
25    import jalview.datamodel.SequenceGroup;
26    import jalview.datamodel.SequenceI;
27    import jalview.util.Comparison;
28   
 
29    public class OverviewResColourFinder extends ResidueColourFinder
30    {
31    /*
32    * colour for gaps (unless overridden by colour scheme)
33    * - as set in Preferences, _or_ read from a project file
34    */
35    Color gapColour;
36   
37    /*
38    * colour for residues if no colour scheme set (before feature colouring)
39    * - as set in Preferences, _or_ read from a project file
40    */
41    Color residueColour;
42   
43    /*
44    * colour for hidden regions
45    * - as set in Preferences, _or_ read from a project file
46    */
47    Color hiddenColour;
48   
49    /**
50    * Constructor without colour settings (used by applet)
51    *
52    * @deprecated
53    */
 
54  3 toggle @Deprecated
55    public OverviewResColourFinder()
56    {
57  3 this(Color.lightGray, Color.white, Color.darkGray.darker());
58    }
59   
60    /**
61    * Constructor given default colours for gaps, residues and hidden regions
62    *
63    * @param gaps
64    * @param residues
65    * @param hidden
66    */
 
67  7 toggle public OverviewResColourFinder(Color gaps, Color residues, Color hidden)
68    {
69  7 gapColour = gaps;
70  7 residueColour = residues;
71  7 hiddenColour = hidden;
72    }
73   
 
74  28016 toggle @Override
75    public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
76    {
77  28016 Color resBoxColour = residueColour;
78  28016 char currentChar = seq.getCharAt(i);
79   
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
82    // settings
83  28016 if (shader.getColourScheme() != null)
84    {
85  14 if (Comparison.isGap(currentChar)
86    && (!shader.getColourScheme().hasGapColour()))
87    {
88  4 resBoxColour = gapColour;
89    }
90    else
91    {
92  10 resBoxColour = shader.findColour(currentChar, i, seq);
93    }
94    }
95  28002 else if (Comparison.isGap(currentChar))
96    {
97  4016 resBoxColour = gapColour;
98    }
99   
100  28016 return resBoxColour;
101    }
102   
103    /**
104    * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
105    * overview displays the colours regardless.
106    */
 
107  28016 toggle @Override
108    protected Color getResidueBoxColour(boolean showBoxes,
109    ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
110    int i)
111    {
112  28016 ResidueShaderI currentShader;
113  28016 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
114    i);
115  28016 if (currentSequenceGroup != null)
116    {
117  0 currentShader = currentSequenceGroup.getGroupColourScheme();
118    }
119    else
120    {
121  28016 currentShader = shader;
122    }
123   
124  28016 return getBoxColour(currentShader, seq, i);
125    }
126   
127    /**
128    * Returns the colour used for hidden regions
129    *
130    * @return
131    */
 
132  2 toggle public Color getHiddenColour()
133    {
134  2 return hiddenColour;
135    }
136   
137    /**
138    * Returns the colour used for gaps, if not overridden by the alignment colour
139    * scheme
140    *
141    * @return
142    */
 
143  2 toggle public Color getGapColour()
144    {
145  2 return gapColour;
146    }
147   
148    /**
149    * Returns the colour used for residues (before applying any feature
150    * colouring) if there is no alignment colour scheme
151    *
152    * @return
153    */
 
154  2 toggle public Color getResidueColour()
155    {
156  2 return residueColour;
157    }
158    }