JAL-1432 updated copyright notices
[jalview.git] / src / jalview / schemes / CovariationColourScheme.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 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 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  * The Jalview Authors are detailed in the 'AUTHORS' file.
18  */
19 package jalview.schemes;
20
21 import java.awt.*;
22 import java.util.Hashtable;
23
24 import jalview.datamodel.AlignmentAnnotation;
25
26 /**
27  * Became RNAHelicesColour.java. Placeholder for true covariation color scheme
28  * 
29  * @author Lauren Michelle Lui
30  * @version 2.5
31  */
32 public class CovariationColourScheme extends ResidueColourScheme
33 {
34   public Hashtable helixcolorhash = new Hashtable();
35
36   public Hashtable positionsToHelix = new Hashtable();
37
38   int numHelix = 0;
39
40   public AlignmentAnnotation annotation;
41
42   /**
43    * Creates a new CovariationColourScheme object.
44    */
45   public CovariationColourScheme(AlignmentAnnotation annotation)
46   {
47     this.annotation = annotation;
48
49     for (int x = 0; x < this.annotation._rnasecstr.length; x++)
50     {
51       // System.out.println(this.annotation._rnasecstr[x] + " Begin" +
52       // this.annotation._rnasecstr[x].getBegin());
53       // System.out.println(this.annotation._rnasecstr[x].getFeatureGroup());
54       // pairs.put(this.annotation._rnasecstr[x].getBegin(),
55       // this.annotation._rnasecstr[x].getEnd());
56
57       positionsToHelix.put(this.annotation._rnasecstr[x].getBegin(),
58               this.annotation._rnasecstr[x].getFeatureGroup());
59       positionsToHelix.put(this.annotation._rnasecstr[x].getEnd(),
60               this.annotation._rnasecstr[x].getFeatureGroup());
61
62       if (Integer.parseInt(this.annotation._rnasecstr[x].getFeatureGroup()) > numHelix)
63       {
64         numHelix = Integer.parseInt(this.annotation._rnasecstr[x]
65                 .getFeatureGroup());
66       }
67
68     }
69
70     for (int j = 0; j <= numHelix; j++)
71     {
72       helixcolorhash.put(Integer.toString(j),
73               jalview.util.ColorUtils.generateRandomColor(Color.white));
74     }
75
76   }
77
78   /**
79    * DOCUMENT ME!
80    * 
81    * @param n
82    *          DOCUMENT ME!
83    * 
84    * @return DOCUMENT ME!
85    */
86   public Color findColour(char c)
87   {
88     // System.out.println("called"); log.debug
89     // Generate a random pastel color
90
91     return ResidueProperties.purinepyrimidine[ResidueProperties.purinepyrimidineIndex[c]];// jalview.util.ColorUtils.generateRandomColor(Color.white);
92   }
93
94   /**
95    * DOCUMENT ME!
96    * 
97    * @param n
98    *          DOCUMENT ME!
99    * @param j
100    *          DOCUMENT ME!
101    * 
102    * @return DOCUMENT ME!
103    */
104   public Color findColour(char c, int j)
105   {
106     Color currentColour = Color.white;
107     String currentHelix = null;
108     // System.out.println(c + " " + j);
109     currentHelix = (String) positionsToHelix.get(j);
110     // System.out.println(positionsToHelix.get(j));
111
112     if (currentHelix != null)
113     {
114       currentColour = (Color) helixcolorhash.get(currentHelix);
115     }
116
117     // System.out.println(c + " " + j + " helix " + currentHelix + " " +
118     // currentColour);
119     return currentColour;
120   }
121
122 }