JAL-2588 Check/fix show boxes settings + unit test updates.
[jalview.git] / src / jalview / renderer / OverviewResColourFinder.java
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   @Override
32   public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
33   {
34     Color resBoxColour = Color.white;
35     char currentChar = seq.getCharAt(i);
36
37     // In the overview window, gaps are coloured grey, unless the colour scheme
38     // specifies a gap colour, in which case gaps honour the colour scheme
39     // settings
40     if (shader.getColourScheme() != null)
41     {
42       if (Comparison.isGap(currentChar)
43               && !shader.getColourScheme().hasGapColour())
44       {
45         resBoxColour = Color.lightGray;
46       }
47       else
48       {
49         resBoxColour = shader.findColour(currentChar, i, seq);
50       }
51     }
52     else if (Comparison.isGap(currentChar))
53     {
54       resBoxColour = Color.lightGray;
55     }
56
57     return resBoxColour;
58   }
59
60   /**
61    * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
62    * overview displays the colours regardless.
63    */
64   @Override
65   protected Color getResidueBoxColour(boolean showBoxes,
66           ResidueShaderI shader,
67           SequenceGroup[] allGroups, SequenceI seq, int i)
68   {
69     ResidueShaderI currentShader;
70     SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
71             i);
72     if (currentSequenceGroup != null)
73     {
74       currentShader = currentSequenceGroup.getGroupColourScheme();
75     }
76     else
77     {
78       currentShader = shader;
79     }
80
81     return getBoxColour(currentShader, seq, i);
82   }
83 }