JAL-3368 'web' colour parsing reinstated (for now) JAL-3368_JavaScript_colors
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 17 Oct 2019 09:27:58 +0000 (10:27 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 17 Oct 2019 09:27:58 +0000 (10:27 +0100)
src/jalview/util/Platform.java

index 68e6bb4..feb6bee 100644 (file)
@@ -727,38 +727,51 @@ public class Platform
     {
       return null;
     }
-    // SwingJS can do this natively. Not implemented here because that would
-    // introduce capabilities into JalviewJS that are not in Jalview/Java.
-    switch (name.toLowerCase())
+
+    /*
+     * JSUtil provides code that will convert any web colour name to the
+     * AWT color; but preferred solution is to add these colours for Java
+     * also (preferably read from a resource file).
+     * NB there are some conflicts (differing colours for the same name)
+     * - see JAL-3368
+     */
+    /**
+     * @j2sNative
+     * 
+     *            return swingjs.JSUtil.getColorFromName$S(name);
+     */
     {
-    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;
+      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;
+      }
     }
   }