JAL-1065 JAL-1066 - use direct object reference rather then index into alignment
[jalview.git] / src / jalview / schemes / NucleotideColourScheme.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.schemes;
19
20 import jalview.datamodel.SequenceI;
21
22 import java.awt.Color;
23
24 /**
25  * DOCUMENT ME!
26  * 
27  * @author $author$
28  * @version $Revision$
29  */
30 public class NucleotideColourScheme extends ResidueColourScheme
31 {
32   /**
33    * Creates a new NucleotideColourScheme object.
34    */
35   public NucleotideColourScheme()
36   {
37     super(ResidueProperties.nucleotide, 0);
38   }
39
40   /**
41    * DOCUMENT ME!
42    * 
43    * @param n
44    *          DOCUMENT ME!
45    * 
46    * @return DOCUMENT ME!
47    */
48   @Override
49   public Color findColour(char c)
50   {
51     // System.out.println("called"); log.debug
52     return colors[ResidueProperties.nucleotideIndex[c]];
53   }
54
55   /**
56    * DOCUMENT ME!
57    * 
58    * @param n
59    *          DOCUMENT ME!
60    * @param j
61    *          DOCUMENT ME!
62    * 
63    * @return DOCUMENT ME!
64    */
65   @Override
66   public Color findColour(char c, int j, SequenceI seq)
67   {
68     Color currentColour;
69     if ((threshold == 0) || aboveThreshold(c, j))
70     {
71       try
72       {
73         currentColour = colors[ResidueProperties.nucleotideIndex[c]];
74       } catch (Exception ex)
75       {
76         return Color.white;
77       }
78     }
79     else
80     {
81       return Color.white;
82     }
83
84     if (conservationColouring)
85     {
86       currentColour = applyConservation(currentColour, j);
87     }
88
89     return currentColour;
90   }
91 }