Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.renderer

File OverviewResColourFinder.java

 

Coverage histogram

../../img/srcFileCovDistChart8.png
19% of files have more coverage

Code metrics

10
24
5
1
143
81
11
0.46
4.8
5
2.2

Classes

Class Line # Actions
OverviewResColourFinder 29 24 11 8
0.794871879.5%
 

Contributing tests

This file is covered by 3 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.util.Comparison;
26   
27    import java.awt.Color;
28   
 
29    public class OverviewResColourFinder extends ResidueColourFinder
30    {
31    final Color GAP_COLOUR; // default colour to use at gaps
32   
33    final Color RESIDUE_COLOUR; // default colour to use at residues
34   
35    final Color HIDDEN_COLOUR; // colour for hidden regions
36   
37    boolean useLegacy = false;
38   
39    public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
40   
41    public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
42   
43    public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
44    .darker();
45   
46    /**
47    * Constructor without colour settings (used by applet)
48    */
 
49  3 toggle public OverviewResColourFinder()
50    {
51  3 this(false, OVERVIEW_DEFAULT_GAP, OVERVIEW_DEFAULT_HIDDEN);
52    }
53   
54    /**
55    * Constructor with colour settings
56    *
57    * @param useLegacyColouring
58    * whether to use legacy gap colouring (white gaps, grey residues)
59    * @param gapCol
60    * gap colour if not legacy
61    * @param hiddenCol
62    * hidden region colour (transparency applied by rendering code)
63    */
 
64  3 toggle public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol,
65    Color hiddenCol)
66    {
67  3 if (useLegacyColouring)
68    {
69  0 GAP_COLOUR = Color.white;
70  0 RESIDUE_COLOUR = Color.lightGray;
71  0 HIDDEN_COLOUR = hiddenCol;
72    }
73    else
74    {
75  3 GAP_COLOUR = gapCol;
76  3 RESIDUE_COLOUR = Color.white;
77  3 HIDDEN_COLOUR = hiddenCol;
78    }
79    }
80   
 
81  18 toggle @Override
82    public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
83    {
84  18 Color resBoxColour = RESIDUE_COLOUR;
85  18 char currentChar = seq.getCharAt(i);
86   
87    // In the overview window, gaps are coloured grey, unless the colour scheme
88    // specifies a gap colour, in which case gaps honour the colour scheme
89    // settings
90  18 if (shader.getColourScheme() != null)
91    {
92  14 if (Comparison.isGap(currentChar)
93    && (!shader.getColourScheme().hasGapColour()))
94    {
95  4 resBoxColour = GAP_COLOUR;
96    }
97    else
98    {
99  10 resBoxColour = shader.findColour(currentChar, i, seq);
100    }
101    }
102  4 else if (Comparison.isGap(currentChar))
103    {
104  2 resBoxColour = GAP_COLOUR;
105    }
106   
107  18 return resBoxColour;
108    }
109   
110    /**
111    * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
112    * overview displays the colours regardless.
113    */
 
114  18 toggle @Override
115    protected Color getResidueBoxColour(boolean showBoxes,
116    ResidueShaderI shader,
117    SequenceGroup[] allGroups, SequenceI seq, int i)
118    {
119  18 ResidueShaderI currentShader;
120  18 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
121    i);
122  18 if (currentSequenceGroup != null)
123    {
124  0 currentShader = currentSequenceGroup.getGroupColourScheme();
125    }
126    else
127    {
128  18 currentShader = shader;
129    }
130   
131  18 return getBoxColour(currentShader, seq, i);
132    }
133   
134    /**
135    * Supply hidden colour
136    *
137    * @return colour of hidden regions
138    */
 
139  0 toggle protected Color getHiddenColour()
140    {
141  0 return HIDDEN_COLOUR;
142    }
143    }