522e2e40d404b3c78b744f24cd2b77b3170bd301
[jalview.git] / src / jalview / schemes / NucleotideColourScheme.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3  * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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.nucleotideIndex, ResidueProperties.nucleotide,
38             0);
39   }
40
41   /**
42    * DOCUMENT ME!
43    * 
44    * @param n
45    *          DOCUMENT ME!
46    * 
47    * @return DOCUMENT ME!
48    */
49   @Override
50   public Color findColour(char c)
51   {
52     // System.out.println("called"); log.debug
53     return colors[ResidueProperties.nucleotideIndex[c]];
54   }
55
56   /**
57    * DOCUMENT ME!
58    * 
59    * @param n
60    *          DOCUMENT ME!
61    * @param j
62    *          DOCUMENT ME!
63    * 
64    * @return DOCUMENT ME!
65    */
66   @Override
67   public Color findColour(char c, int j, SequenceI seq)
68   {
69     Color currentColour;
70     if ((threshold == 0) || aboveThreshold(c, j))
71     {
72       try
73       {
74         currentColour = colors[ResidueProperties.nucleotideIndex[c]];
75       } catch (Exception ex)
76       {
77         return Color.white;
78       }
79     }
80     else
81     {
82       return Color.white;
83     }
84
85     if (conservationColouring)
86     {
87       currentColour = applyConservation(currentColour, j);
88     }
89
90     return currentColour;
91   }
92 }