Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 17:27:16 GMT
  2. Package jalview.renderer

File ResidueColourFinder.java

 

Coverage histogram

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

Code metrics

16
21
5
1
155
69
14
0.67
4.2
5
2.8

Classes

Class Line # Actions
ResidueColourFinder 29 21 14
0.9761904597.6%
 

Contributing tests

This file is covered by 193 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 jalview.datamodel.SequenceGroup;
24    import jalview.datamodel.SequenceI;
25    import jalview.renderer.seqfeatures.FeatureColourFinder;
26   
27    import java.awt.Color;
28   
 
29    public class ResidueColourFinder
30    {
 
31  899 toggle public ResidueColourFinder()
32    {
33    }
34   
35    /**
36    * Get the colour of a residue in a sequence
37    *
38    * @param showBoxes
39    * true if the viewport's Show Boxes setting is true
40    * @param shader
41    * the viewport's colour scheme
42    * @param allGroups
43    * all the groups which seq participates in
44    * @param seq
45    * the sequence containing the residue
46    * @param position
47    * the position of the residue in the sequence
48    * @param finder
49    * FeatureColourFinder for the viewport
50    * @return colour of the residue
51    */
 
52  356833 toggle public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
53    SequenceGroup[] allGroups, final SequenceI seq, int position,
54    FeatureColourFinder finder)
55    {
56  356843 Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq,
57    position);
58   
59    // if there's a FeatureColourFinder we might override the residue colour
60    // here with feature colouring
61  356722 if (finder != null)
62    {
63  356667 col = finder.findFeatureColour(col, seq, position);
64    }
65  356758 return col;
66    }
67   
68    /**
69    * Get the residue colour without accounting for any features
70    *
71    * @param showBoxes
72    * true if the viewport's Show Boxes setting is true
73    * @param shader
74    * the viewport's colour scheme
75    * @param allGroups
76    * all the groups which seq participates in
77    * @param seq
78    * the sequence containing the residue
79    * @param i
80    * the position of the residue in the sequence
81    * @return
82    */
 
83  33152 toggle protected Color getResidueBoxColour(boolean showBoxes,
84    ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
85    int i)
86    {
87  33152 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
88    i);
89  33151 if (currentSequenceGroup != null)
90    {
91  1 if (currentSequenceGroup.getDisplayBoxes())
92    {
93  1 return getBoxColour(currentSequenceGroup.getGroupColourScheme(),
94    seq, i);
95    }
96    }
97  33150 else if (showBoxes)
98    {
99  33142 return getBoxColour(shader, seq, i);
100    }
101   
102  8 return Color.white;
103    }
104   
105    /**
106    * Search all the groups for a sequence to find the one which a given res
107    * falls into
108    *
109    * @param allGroups
110    * all the groups a sequence participates in
111    * @param res
112    * the residue to search for
113    * @return a sequence group for res, or null if no sequence group applies
114    */
 
115  1518098 toggle public SequenceGroup getCurrentSequenceGroup(SequenceGroup[] allGroups,
116    int res)
117    {
118  1518281 if (allGroups == null)
119    {
120  34 return null;
121    }
122   
123  1629294 for (int i = 0; i < allGroups.length; i++)
124    {
125  622873 if ((allGroups[i].getStartRes() <= res)
126    && (allGroups[i].getEndRes() >= res))
127    {
128  511784 return (allGroups[i]);
129    }
130    }
131   
132  1006478 return null;
133    }
134   
135    /**
136    * DOCUMENT ME!
137    *
138    * @param shader
139    * the viewport's colour scheme
140    * @param seq
141    * the sequence containing the residue
142    * @param i
143    * the position of the residue in the sequence
144    */
 
145  613859 toggle public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
146    {
147  613860 Color resBoxColour = Color.white;
148  613861 if (shader.getColourScheme() != null)
149    {
150  248040 resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
151    }
152  613861 return resBoxColour;
153    }
154   
155    }