JAL-2360 refactoring for JalviewColourScheme enum,
[jalview.git] / src / jalview / schemes / ColourSchemeI.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.schemes;
22
23 import jalview.analysis.Conservation;
24 import jalview.datamodel.AnnotatedCollectionI;
25 import jalview.datamodel.ProfilesI;
26 import jalview.datamodel.SequenceCollectionI;
27 import jalview.datamodel.SequenceI;
28
29 import java.awt.Color;
30 import java.util.Map;
31
32 public interface ColourSchemeI
33 {
34   /**
35    * Returns the fixed colour for the colour scheme. For use when the colour
36    * does not vary.
37    * 
38    * @return
39    */
40   Color findColour();
41
42   /**
43    * Returns the colour for the given character. For use when the colour depends
44    * only on the symbol.
45    * 
46    * @param c
47    * @return
48    */
49   Color findColour(char c);
50
51   /**
52    * Returns the possibly context dependent colour for the given symbol at the
53    * aligned position in the given sequence. For example, the colour may depend
54    * on the symbol's relationship to the consensus residue for the column.
55    * 
56    * @param symbol
57    * @param position
58    * @param seq
59    * @return
60    */
61   Color findColour(char symbol, int position, SequenceI seq);
62
63   /**
64    * Assigns the given consensus profile for the colourscheme
65    */
66   void setConsensus(ProfilesI hconsensus);
67
68   /**
69    * Assigns the given conservation to the colourscheme
70    * 
71    * @param c
72    */
73   void setConservation(Conservation c);
74
75   /**
76    * Enable or disable conservation shading for this colourscheme
77    * 
78    * @param conservationApplied
79    */
80   void setConservationApplied(boolean conservationApplied);
81
82   /**
83    * Answers true if conservation shading is enabled for this colourscheme
84    * 
85    * @return
86    */
87   boolean conservationApplied();
88
89   /**
90    * Sets the scale factor for bleaching of colour in unconserved regions
91    * 
92    * @param i
93    */
94   void setConservationInc(int i);
95
96   /**
97    * Returns the scale factor for bleaching colour in unconserved regions
98    * 
99    * @return
100    */
101   int getConservationInc();
102
103   /**
104    * Returns the percentage identity threshold for applying colourscheme
105    * 
106    * @return
107    */
108   int getThreshold();
109
110   /**
111    * Sets the percentage identity threshold and type of %age identity
112    * calculation for shading
113    * 
114    * @param pct
115    *          0..100 percentage identity for applying this colourscheme
116    * @param ignoreGaps
117    *          when true, calculate PID without including gapped positions
118    */
119   void setThreshold(int pct, boolean ignoreGaps);
120
121   /**
122    * Recalculate dependent data using the given sequence collection, taking
123    * account of hidden rows
124    * 
125    * @param alignment
126    * @param hiddenReps
127    */
128   void alignmentChanged(AnnotatedCollectionI alignment,
129           Map<SequenceI, SequenceCollectionI> hiddenReps);
130
131   /**
132    * Creates and returns a new instance of the colourscheme configured to colour
133    * the given connection
134    * 
135    * @param sg
136    * @param hiddenRepSequences
137    * @return copy of current scheme with any inherited settings transfered
138    */
139   ColourSchemeI applyTo(AnnotatedCollectionI sg,
140           Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
141
142   /**
143    * Answers true if the colour scheme is suitable for the given data, else
144    * false. For example, some colour schemes are specific to either peptide or
145    * nucleotide, or only apply if certain kinds of annotation are present.
146    * 
147    * @param ac
148    * @return
149    */
150   // TODO can make this method static in Java 8
151   boolean isApplicableTo(AnnotatedCollectionI ac);
152
153   /**
154    * Answers the 'official' name of the colour scheme (as used, for example, as
155    * a Jalview startup parameter)
156    * 
157    * @return
158    */
159   String getSchemeName();
160 }