X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FPlatform.java;h=fe620ed5d99e93b95b8d3983b0364b79359286aa;hb=60ade4437409299de040abb15588b052a932bf5c;hp=a1412f2ac7efa1591eb2f1398da97e17672d5509;hpb=8040d18e9deeb76e7c63f31f5499e369081f793c;p=jalview.git diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index a1412f2..fe620ed 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -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; + } + + } + } + }