issue JAL-3368 and JAL-3253-applet
[jalview.git] / src / jalview / util / Platform.java
index a1412f2..fe620ed 100644 (file)
@@ -22,6 +22,7 @@ package jalview.util;
 
 import jalview.javascript.json.JSON;
 
+import java.awt.Color;
 import java.awt.Toolkit;
 import java.awt.event.MouseEvent;
 import java.io.BufferedReader;
@@ -697,4 +698,55 @@ public class Platform
     return Regex.perlCode(code);
   }
 
+  /**
+   * @param c
+   */
+  public static Color getColorFromName(String name)
+  {
+    if (name == null)
+    {
+      return null;
+    }
+    /**
+     * @j2sNative
+     * 
+     *            return swingjs.JSUtil.getColorFromName$S(name);
+     */
+    {
+      // or make a static map; or use reflection on the field name
+      switch (name.toLowerCase())
+      {
+      case "black":
+        return Color.black;
+      case "blue":
+        return Color.blue;
+      case "cyan":
+        return Color.cyan;
+      case "darkgray":
+        return Color.darkGray;
+      case "gray":
+        return Color.gray;
+      case "green":
+        return Color.green;
+      case "lightgray":
+        return Color.lightGray;
+      case "magenta":
+        return Color.magenta;
+      case "orange":
+        return Color.orange;
+      case "pink":
+        return Color.pink;
+      case "red":
+        return Color.red;
+      case "white":
+        return Color.white;
+      case "yellow":
+        return Color.yellow;
+      default:
+        return null;
+      }
+
+    }
+  }
+
 }