JAL-2360 code formatting only and if-else changed to switch
[jalview.git] / src / jalview / schemes / ColourSchemeProperty.java
index 0d9c39d..fc703ba 100755 (executable)
@@ -415,8 +415,7 @@ public class ColourSchemeProperty
         try
         {
           // fix the launchApp user defined coloursheme transfer bug
-          jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(
-                  "white");
+          UserColourScheme ucs = new UserColourScheme("white");
           ucs.parseAppletParameter(name);
 
         } catch (Exception e)
@@ -425,7 +424,7 @@ public class ColourSchemeProperty
         }
       }
     }
-    return getColour(alignment, getColourIndexFromName(name));
+    return getColour(alignment, colindex);
   }
 
   /**
@@ -538,61 +537,64 @@ public class ColourSchemeProperty
     return cs;
   }
 
+  /**
+   * Returns the Color constant for a given colour name e.g. "pink", or null if
+   * the name is not recognised
+   * 
+   * @param name
+   * @return
+   */
   public static Color getAWTColorFromName(String name)
   {
+    if (name == null)
+    {
+      return null;
+    }
     Color col = null;
     name = name.toLowerCase();
-    if (name.equals("black"))
+
+    // or make a static map; or use reflection on the field name
+    switch (name)
     {
+    case "black":
       col = Color.black;
-    }
-    else if (name.equals("blue"))
-    {
+      break;
+    case "blue":
       col = Color.blue;
-    }
-    else if (name.equals("cyan"))
-    {
+      break;
+    case "cyan":
       col = Color.cyan;
-    }
-    else if (name.equals("darkGray"))
-    {
+      break;
+    case "darkGray":
       col = Color.darkGray;
-    }
-    else if (name.equals("gray"))
-    {
+      break;
+    case "gray":
       col = Color.gray;
-    }
-    else if (name.equals("green"))
-    {
+      break;
+    case "green":
       col = Color.green;
-    }
-    else if (name.equals("lightGray"))
-    {
+      break;
+    case "lightGray":
       col = Color.lightGray;
-    }
-    else if (name.equals("magenta"))
-    {
+      break;
+    case "magenta":
       col = Color.magenta;
-    }
-    else if (name.equals("orange"))
-    {
+      break;
+    case "orange":
       col = Color.orange;
-    }
-    else if (name.equals("pink"))
-    {
+      break;
+    case "pink":
       col = Color.pink;
-    }
-    else if (name.equals("red"))
-    {
+      break;
+    case "red":
       col = Color.red;
-    }
-    else if (name.equals("white"))
-    {
+      break;
+    case "white":
       col = Color.white;
-    }
-    else if (name.equals("yellow"))
-    {
+      break;
+    case "yellow":
       col = Color.yellow;
+      break;
     }
 
     return col;