Color names not supported.
col = new Color(value);
} catch (NumberFormatException ex)
{
+ col = Platform.getColorFromName(colour);
}
if (col == null)
*/
public static Color getAWTColorFromName(String name)
{
- if (name == null)
- {
- return null;
- }
- Color col = null;
- name = name.toLowerCase();
-
- // or make a static map; or use reflection on the field name
- switch (name)
- {
- case "black":
- col = Color.black;
- break;
- case "blue":
- col = Color.blue;
- break;
- case "cyan":
- col = Color.cyan;
- break;
- case "darkgray":
- col = Color.darkGray;
- break;
- case "gray":
- col = Color.gray;
- break;
- case "green":
- col = Color.green;
- break;
- case "lightgray":
- col = Color.lightGray;
- break;
- case "magenta":
- col = Color.magenta;
- break;
- case "orange":
- col = Color.orange;
- break;
- case "pink":
- col = Color.pink;
- break;
- case "red":
- col = Color.red;
- break;
- case "white":
- col = Color.white;
- break;
- case "yellow":
- col = Color.yellow;
- break;
- }
-
- return col;
+ return Platform.getColorFromName(name); // BH 2019 -- allows for wide range
+ // of JavaScript colors (for
+ // JavaScript only)
}
}
import jalview.javascript.json.JSON;
+import java.awt.Color;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
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;
+ }
+
+ }
+ }
+
}