Updated for use by preferences panel
[jalview.git] / src / jalview / schemes / ColourSchemeProperty.java
1 package jalview.schemes;
2
3 public class ColourSchemeProperty
4 {
5   public static final int CLUSTAL = 0;
6   public static final int BLOSUM = 1;
7   public static final int PID = 2;
8   public static final int ZAPPO = 3;
9   public static final int HYDROPHOBIC=4;
10   public static final int HELIX=5;
11   public static final int STRAND=6;
12   public static final int TURN = 7;
13   public static final int BURIED = 8;
14   public static final int NUCLEOTIDE = 9;
15   public static final int USER_DEFINED = 10;
16   public static final int NONE = 11;
17
18
19   public static String getColourName(int index)
20   {
21     String ret=null;
22     switch(index)
23     {
24       case CLUSTAL: ret = "Clustal";    break;
25       case BLOSUM:  ret = "Blosum62";   break;
26       case PID:     ret = "% Identity"; break;
27       case ZAPPO:   ret = "Zappo";      break;
28       case HYDROPHOBIC: ret="Hydrophobic";break;
29       case HELIX:   ret="Helix Propensity";break;
30       case STRAND:  ret="Strand Propensity";break;
31       case TURN:    ret="Turn Propensity";break;
32       case BURIED:  ret="Buried Index";break;
33       case NUCLEOTIDE:ret="Nucleotide"; break;
34       case USER_DEFINED:ret="User Defined";break;
35       default: ret = "None"; break;
36     }
37     return ret;
38   }
39
40   public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name)
41   {
42     for(int i=0; i<12; i++)
43     {
44       if(getColourName(i).equals(name))
45         return getColour(al, i);
46     }
47     return null;
48   }
49
50   public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index)
51   {
52     ColourSchemeI cs = null;
53     switch(index)
54     {
55       case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break;
56       case BLOSUM: cs = new Blosum62ColourScheme(); break;
57       case PID: cs = new PIDColourScheme();  break;
58       case ZAPPO: cs = new ZappoColourScheme(); break;
59       case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break;
60       case HELIX: cs = new HelixColourScheme(); break;
61       case STRAND: cs = new StrandColourScheme(); break;
62       case TURN: cs = new TurnColourScheme(); break;
63       case BURIED: cs = new BuriedColourScheme(); break;
64       case NUCLEOTIDE: cs = new NucleotideColourScheme(); break;
65       case USER_DEFINED:
66         if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null)
67         {
68           cs = jalview.gui.UserDefinedColours.loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR"));
69         }
70         break;
71
72       default: break;
73     }
74
75     return cs;
76   }
77 }