Updated for use by preferences panel
authoramwaterhouse <Andrew Waterhouse>
Thu, 28 Apr 2005 15:41:34 +0000 (15:41 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 28 Apr 2005 15:41:34 +0000 (15:41 +0000)
src/jalview/schemes/ColourSchemeProperty.java

index 518f7ab..169f35e 100755 (executable)
@@ -1,28 +1,77 @@
-package jalview.schemes;\r
-\r
-public class ColourSchemeProperty {\r
-  String description;\r
-  String className;\r
-  String menuString = null;\r
-\r
-  public ColourSchemeProperty(String description, String className, String menuString) {\r
-    this.description = new String(description);\r
-    this.className   = new String(className);\r
-    if (menuString != null) {\r
-      this.menuString = new String(menuString);\r
-    }\r
-  }\r
-\r
-  public String getClassName() {\r
-    return className;\r
-  }\r
-  public String getDescription() {\r
-    return description;\r
-  }\r
-  public String getMenuString() {\r
-    return menuString;\r
-  }\r
-  public boolean isMenuItem() {\r
-    return (menuString != null);\r
-  }\r
-}\r
+package jalview.schemes;
+
+public class ColourSchemeProperty
+{
+  public static final int CLUSTAL = 0;
+  public static final int BLOSUM = 1;
+  public static final int PID = 2;
+  public static final int ZAPPO = 3;
+  public static final int HYDROPHOBIC=4;
+  public static final int HELIX=5;
+  public static final int STRAND=6;
+  public static final int TURN = 7;
+  public static final int BURIED = 8;
+  public static final int NUCLEOTIDE = 9;
+  public static final int USER_DEFINED = 10;
+  public static final int NONE = 11;
+
+
+  public static String getColourName(int index)
+  {
+    String ret=null;
+    switch(index)
+    {
+      case CLUSTAL: ret = "Clustal";    break;
+      case BLOSUM:  ret = "Blosum62";   break;
+      case PID:     ret = "% Identity"; break;
+      case ZAPPO:   ret = "Zappo";      break;
+      case HYDROPHOBIC: ret="Hydrophobic";break;
+      case HELIX:   ret="Helix Propensity";break;
+      case STRAND:  ret="Strand Propensity";break;
+      case TURN:    ret="Turn Propensity";break;
+      case BURIED:  ret="Buried Index";break;
+      case NUCLEOTIDE:ret="Nucleotide"; break;
+      case USER_DEFINED:ret="User Defined";break;
+      default: ret = "None"; break;
+    }
+    return ret;
+  }
+
+  public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name)
+  {
+    for(int i=0; i<12; i++)
+    {
+      if(getColourName(i).equals(name))
+        return getColour(al, i);
+    }
+    return null;
+  }
+
+  public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index)
+  {
+    ColourSchemeI cs = null;
+    switch(index)
+    {
+      case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break;
+      case BLOSUM: cs = new Blosum62ColourScheme(); break;
+      case PID: cs = new PIDColourScheme();  break;
+      case ZAPPO: cs = new ZappoColourScheme(); break;
+      case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break;
+      case HELIX: cs = new HelixColourScheme(); break;
+      case STRAND: cs = new StrandColourScheme(); break;
+      case TURN: cs = new TurnColourScheme(); break;
+      case BURIED: cs = new BuriedColourScheme(); break;
+      case NUCLEOTIDE: cs = new NucleotideColourScheme(); break;
+      case USER_DEFINED:
+        if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null)
+        {
+          cs = jalview.gui.UserDefinedColours.loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR"));
+        }
+        break;
+
+      default: break;
+    }
+
+    return cs;
+  }
+}