JAL-3691 automatic insertion of Locale.ROOT to toUpperCase() and toLowerCase() and...
[jalview.git] / src / jalview / json / binding / biojson / v1 / ColourSchemeMapper.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.json.binding.biojson.v1;
22
23 import java.util.Locale;
24
25 import jalview.datamodel.AnnotatedCollectionI;
26 import jalview.schemes.Blosum62ColourScheme;
27 import jalview.schemes.BuriedColourScheme;
28 import jalview.schemes.ClustalxColourScheme;
29 import jalview.schemes.ColourSchemeI;
30 import jalview.schemes.HelixColourScheme;
31 import jalview.schemes.HydrophobicColourScheme;
32 import jalview.schemes.NucleotideColourScheme;
33 import jalview.schemes.PIDColourScheme;
34 import jalview.schemes.PurinePyrimidineColourScheme;
35 import jalview.schemes.RNAHelicesColour;
36 import jalview.schemes.RNAInteractionColourScheme;
37 import jalview.schemes.StrandColourScheme;
38 import jalview.schemes.TCoffeeColourScheme;
39 import jalview.schemes.TaylorColourScheme;
40 import jalview.schemes.TurnColourScheme;
41 import jalview.schemes.ZappoColourScheme;
42
43 public class ColourSchemeMapper
44 {
45   private static ColourSchemeI csZappo, csTaylor, csNucleotide, csPurine,
46           csHelix, csTurn, csStrand, csBuried, csHydro,
47           csRNAInteractionType, csPID, csBlosum62 = null;
48   static
49   {
50     csZappo = new ZappoColourScheme();
51     csTaylor = new TaylorColourScheme();
52     csNucleotide = new NucleotideColourScheme();
53     csPurine = new PurinePyrimidineColourScheme();
54     csHelix = new HelixColourScheme();
55     csTurn = new TurnColourScheme();
56     csStrand = new StrandColourScheme();
57     csBuried = new BuriedColourScheme();
58     csHydro = new HydrophobicColourScheme();
59     csRNAInteractionType = new RNAInteractionColourScheme();
60     csPID = new PIDColourScheme();
61     csBlosum62 = new Blosum62ColourScheme();
62   }
63
64   public static ColourSchemeI getJalviewColourScheme(
65           String colourSchemeName, AnnotatedCollectionI annotCol)
66   {
67     switch (colourSchemeName.toUpperCase(Locale.ROOT))
68     {
69     case "ZAPPO":
70       return csZappo;
71     case "TAYLOR":
72       return csTaylor;
73     case "NUCLEOTIDE":
74       return csNucleotide;
75     case "PURINE":
76     case "PURINE/PYRIMIDINE":
77       return csPurine;
78     case "HELIX":
79     case "HELIX PROPENSITY":
80       return csHelix;
81     case "TURN":
82     case "TURN PROPENSITY":
83       return csTurn;
84     case "STRAND":
85     case "STRAND PROPENSITY":
86       return csStrand;
87     case "BURIED":
88     case "BURIED INDEX":
89       return csBuried;
90     case "HYDRO":
91     case "HYDROPHOBIC":
92       return csHydro;
93     case "RNA INTERACTION TYPE":
94       return csRNAInteractionType;
95     case "PID":
96     case "% IDENTITY":
97       return csPID;
98     case "BLOSUM62":
99       return csBlosum62;
100     case "T-COFFEE SCORES":
101       return (annotCol != null) ? new TCoffeeColourScheme(annotCol) : null;
102     case "RNA HELICES":
103       return (annotCol != null) ? new RNAHelicesColour(annotCol) : null;
104     case "CLUSTAL":
105       return (annotCol != null) ? new ClustalxColourScheme(annotCol, null)
106               : null;
107     case "USER DEFINED":
108       return null;
109     default:
110       return null;
111     }
112   }
113 }