From e225782ffcac7c0f7019dbcab12d920d0c02bb40 Mon Sep 17 00:00:00 2001
From: stepan <stepan.sindelar@oracle.com>
Date: Thu, 16 Mar 2017 16:19:07 +0100
Subject: [PATCH] FastR Grid: honor fill color + GUI framework independent
 color representation

---
 .../r/library/fastrGrid/ColorNames.java       | 686 ----------------
 .../truffle/r/library/fastrGrid/GPar.java     |  27 +-
 .../r/library/fastrGrid/GridColorUtils.java   | 745 ++++++++++++++++++
 .../truffle/r/library/fastrGrid/LPoints.java  |   6 +-
 .../fastrGrid/device/DrawingContext.java      |  22 +-
 .../r/library/fastrGrid/device/GridColor.java |  58 ++
 .../fastrGrid/device/JFrameDevice.java        |  34 +-
 .../fastrGrid/GridColorUtilsTests.java        |  93 +++
 mx.fastr/copyrights/overrides                 |   2 +-
 mx.fastr/mx_fastr.py                          |   2 +-
 10 files changed, 950 insertions(+), 725 deletions(-)
 delete mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ColorNames.java
 create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridColorUtils.java
 create mode 100644 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/GridColor.java
 create mode 100644 com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastrGrid/GridColorUtilsTests.java

diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ColorNames.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ColorNames.java
deleted file mode 100644
index 18eb3b0964..0000000000
--- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ColorNames.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- * This material is distributed under the GNU General Public License
- * Version 2. You may review the terms of this license at
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * Copyright (c) 1997-2014, The R Core Team
- * Copyright (c) 2003, The R Foundation
- * Copyright (c) 2017, Oracle and/or its affiliates
- *
- * All rights reserved.
- */
-package com.oracle.truffle.r.library.fastrGrid;
-
-import java.util.HashMap;
-
-final class ColorNames {
-    private static HashMap<String, String> synonymToHexName;
-
-    public static String findByName(String synonym) {
-        if (synonymToHexName == null) {
-            initialize();
-        }
-        return synonymToHexName.get(synonym);
-    }
-
-    private static void initialize() {
-        synonymToHexName = new HashMap<>(700);
-        synonymToHexName.put("white", "#FFFFFF");
-        synonymToHexName.put("aliceblue", "#F0F8FF");
-        synonymToHexName.put("antiquewhite", "#FAEBD7");
-        synonymToHexName.put("antiquewhite1", "#FFEFDB");
-        synonymToHexName.put("antiquewhite2", "#EEDFCC");
-        synonymToHexName.put("antiquewhite3", "#CDC0B0");
-        synonymToHexName.put("antiquewhite4", "#8B8378");
-        synonymToHexName.put("aquamarine", "#7FFFD4");
-        synonymToHexName.put("aquamarine1", "#7FFFD4");
-        synonymToHexName.put("aquamarine2", "#76EEC6");
-        synonymToHexName.put("aquamarine3", "#66CDAA");
-        synonymToHexName.put("aquamarine4", "#458B74");
-        synonymToHexName.put("azure", "#F0FFFF");
-        synonymToHexName.put("azure1", "#F0FFFF");
-        synonymToHexName.put("azure2", "#E0EEEE");
-        synonymToHexName.put("azure3", "#C1CDCD");
-        synonymToHexName.put("azure4", "#838B8B");
-        synonymToHexName.put("beige", "#F5F5DC");
-        synonymToHexName.put("bisque", "#FFE4C4");
-        synonymToHexName.put("bisque1", "#FFE4C4");
-        synonymToHexName.put("bisque2", "#EED5B7");
-        synonymToHexName.put("bisque3", "#CDB79E");
-        synonymToHexName.put("bisque4", "#8B7D6B");
-        synonymToHexName.put("black", "#000000");
-        synonymToHexName.put("blanchedalmond", "#FFEBCD");
-        synonymToHexName.put("blue", "#0000FF");
-        synonymToHexName.put("blue1", "#0000FF");
-        synonymToHexName.put("blue2", "#0000EE");
-        synonymToHexName.put("blue3", "#0000CD");
-        synonymToHexName.put("blue4", "#00008B");
-        synonymToHexName.put("blueviolet", "#8A2BE2");
-        synonymToHexName.put("brown", "#A52A2A");
-        synonymToHexName.put("brown1", "#FF4040");
-        synonymToHexName.put("brown2", "#EE3B3B");
-        synonymToHexName.put("brown3", "#CD3333");
-        synonymToHexName.put("brown4", "#8B2323");
-        synonymToHexName.put("burlywood", "#DEB887");
-        synonymToHexName.put("burlywood1", "#FFD39B");
-        synonymToHexName.put("burlywood2", "#EEC591");
-        synonymToHexName.put("burlywood3", "#CDAA7D");
-        synonymToHexName.put("burlywood4", "#8B7355");
-        synonymToHexName.put("cadetblue", "#5F9EA0");
-        synonymToHexName.put("cadetblue1", "#98F5FF");
-        synonymToHexName.put("cadetblue2", "#8EE5EE");
-        synonymToHexName.put("cadetblue3", "#7AC5CD");
-        synonymToHexName.put("cadetblue4", "#53868B");
-        synonymToHexName.put("chartreuse", "#7FFF00");
-        synonymToHexName.put("chartreuse1", "#7FFF00");
-        synonymToHexName.put("chartreuse2", "#76EE00");
-        synonymToHexName.put("chartreuse3", "#66CD00");
-        synonymToHexName.put("chartreuse4", "#458B00");
-        synonymToHexName.put("chocolate", "#D2691E");
-        synonymToHexName.put("chocolate1", "#FF7F24");
-        synonymToHexName.put("chocolate2", "#EE7621");
-        synonymToHexName.put("chocolate3", "#CD661D");
-        synonymToHexName.put("chocolate4", "#8B4513");
-        synonymToHexName.put("coral", "#FF7F50");
-        synonymToHexName.put("coral1", "#FF7256");
-        synonymToHexName.put("coral2", "#EE6A50");
-        synonymToHexName.put("coral3", "#CD5B45");
-        synonymToHexName.put("coral4", "#8B3E2F");
-        synonymToHexName.put("cornflowerblue", "#6495ED");
-        synonymToHexName.put("cornsilk", "#FFF8DC");
-        synonymToHexName.put("cornsilk1", "#FFF8DC");
-        synonymToHexName.put("cornsilk2", "#EEE8CD");
-        synonymToHexName.put("cornsilk3", "#CDC8B1");
-        synonymToHexName.put("cornsilk4", "#8B8878");
-        synonymToHexName.put("cyan", "#00FFFF");
-        synonymToHexName.put("cyan1", "#00FFFF");
-        synonymToHexName.put("cyan2", "#00EEEE");
-        synonymToHexName.put("cyan3", "#00CDCD");
-        synonymToHexName.put("cyan4", "#008B8B");
-        synonymToHexName.put("darkblue", "#00008B");
-        synonymToHexName.put("darkcyan", "#008B8B");
-        synonymToHexName.put("darkgoldenrod", "#B8860B");
-        synonymToHexName.put("darkgoldenrod1", "#FFB90F");
-        synonymToHexName.put("darkgoldenrod2", "#EEAD0E");
-        synonymToHexName.put("darkgoldenrod3", "#CD950C");
-        synonymToHexName.put("darkgoldenrod4", "#8B6508");
-        synonymToHexName.put("darkgray", "#A9A9A9");
-        synonymToHexName.put("darkgreen", "#006400");
-        synonymToHexName.put("darkgrey", "#A9A9A9");
-        synonymToHexName.put("darkkhaki", "#BDB76B");
-        synonymToHexName.put("darkmagenta", "#8B008B");
-        synonymToHexName.put("darkolivegreen", "#556B2F");
-        synonymToHexName.put("darkolivegreen1", "#CAFF70");
-        synonymToHexName.put("darkolivegreen2", "#BCEE68");
-        synonymToHexName.put("darkolivegreen3", "#A2CD5A");
-        synonymToHexName.put("darkolivegreen4", "#6E8B3D");
-        synonymToHexName.put("darkorange", "#FF8C00");
-        synonymToHexName.put("darkorange1", "#FF7F00");
-        synonymToHexName.put("darkorange2", "#EE7600");
-        synonymToHexName.put("darkorange3", "#CD6600");
-        synonymToHexName.put("darkorange4", "#8B4500");
-        synonymToHexName.put("darkorchid", "#9932CC");
-        synonymToHexName.put("darkorchid1", "#BF3EFF");
-        synonymToHexName.put("darkorchid2", "#B23AEE");
-        synonymToHexName.put("darkorchid3", "#9A32CD");
-        synonymToHexName.put("darkorchid4", "#68228B");
-        synonymToHexName.put("darkred", "#8B0000");
-        synonymToHexName.put("darksalmon", "#E9967A");
-        synonymToHexName.put("darkseagreen", "#8FBC8F");
-        synonymToHexName.put("darkseagreen1", "#C1FFC1");
-        synonymToHexName.put("darkseagreen2", "#B4EEB4");
-        synonymToHexName.put("darkseagreen3", "#9BCD9B");
-        synonymToHexName.put("darkseagreen4", "#698B69");
-        synonymToHexName.put("darkslateblue", "#483D8B");
-        synonymToHexName.put("darkslategray", "#2F4F4F");
-        synonymToHexName.put("darkslategray1", "#97FFFF");
-        synonymToHexName.put("darkslategray2", "#8DEEEE");
-        synonymToHexName.put("darkslategray3", "#79CDCD");
-        synonymToHexName.put("darkslategray4", "#528B8B");
-        synonymToHexName.put("darkslategrey", "#2F4F4F");
-        synonymToHexName.put("darkturquoise", "#00CED1");
-        synonymToHexName.put("darkviolet", "#9400D3");
-        synonymToHexName.put("deeppink", "#FF1493");
-        synonymToHexName.put("deeppink1", "#FF1493");
-        synonymToHexName.put("deeppink2", "#EE1289");
-        synonymToHexName.put("deeppink3", "#CD1076");
-        synonymToHexName.put("deeppink4", "#8B0A50");
-        synonymToHexName.put("deepskyblue", "#00BFFF");
-        synonymToHexName.put("deepskyblue1", "#00BFFF");
-        synonymToHexName.put("deepskyblue2", "#00B2EE");
-        synonymToHexName.put("deepskyblue3", "#009ACD");
-        synonymToHexName.put("deepskyblue4", "#00688B");
-        synonymToHexName.put("dimgray", "#696969");
-        synonymToHexName.put("dimgrey", "#696969");
-        synonymToHexName.put("dodgerblue", "#1E90FF");
-        synonymToHexName.put("dodgerblue1", "#1E90FF");
-        synonymToHexName.put("dodgerblue2", "#1C86EE");
-        synonymToHexName.put("dodgerblue3", "#1874CD");
-        synonymToHexName.put("dodgerblue4", "#104E8B");
-        synonymToHexName.put("firebrick", "#B22222");
-        synonymToHexName.put("firebrick1", "#FF3030");
-        synonymToHexName.put("firebrick2", "#EE2C2C");
-        synonymToHexName.put("firebrick3", "#CD2626");
-        synonymToHexName.put("firebrick4", "#8B1A1A");
-        synonymToHexName.put("floralwhite", "#FFFAF0");
-        synonymToHexName.put("forestgreen", "#228B22");
-        synonymToHexName.put("gainsboro", "#DCDCDC");
-        synonymToHexName.put("ghostwhite", "#F8F8FF");
-        synonymToHexName.put("gold", "#FFD700");
-        synonymToHexName.put("gold1", "#FFD700");
-        synonymToHexName.put("gold2", "#EEC900");
-        synonymToHexName.put("gold3", "#CDAD00");
-        synonymToHexName.put("gold4", "#8B7500");
-        synonymToHexName.put("goldenrod", "#DAA520");
-        synonymToHexName.put("goldenrod1", "#FFC125");
-        synonymToHexName.put("goldenrod2", "#EEB422");
-        synonymToHexName.put("goldenrod3", "#CD9B1D");
-        synonymToHexName.put("goldenrod4", "#8B6914");
-        synonymToHexName.put("gray", "#BEBEBE");
-        synonymToHexName.put("gray0", "#000000");
-        synonymToHexName.put("gray1", "#030303");
-        synonymToHexName.put("gray2", "#050505");
-        synonymToHexName.put("gray3", "#080808");
-        synonymToHexName.put("gray4", "#0A0A0A");
-        synonymToHexName.put("gray5", "#0D0D0D");
-        synonymToHexName.put("gray6", "#0F0F0F");
-        synonymToHexName.put("gray7", "#121212");
-        synonymToHexName.put("gray8", "#141414");
-        synonymToHexName.put("gray9", "#171717");
-        synonymToHexName.put("gray10", "#1A1A1A");
-        synonymToHexName.put("gray11", "#1C1C1C");
-        synonymToHexName.put("gray12", "#1F1F1F");
-        synonymToHexName.put("gray13", "#212121");
-        synonymToHexName.put("gray14", "#242424");
-        synonymToHexName.put("gray15", "#262626");
-        synonymToHexName.put("gray16", "#292929");
-        synonymToHexName.put("gray17", "#2B2B2B");
-        synonymToHexName.put("gray18", "#2E2E2E");
-        synonymToHexName.put("gray19", "#303030");
-        synonymToHexName.put("gray20", "#333333");
-        synonymToHexName.put("gray21", "#363636");
-        synonymToHexName.put("gray22", "#383838");
-        synonymToHexName.put("gray23", "#3B3B3B");
-        synonymToHexName.put("gray24", "#3D3D3D");
-        synonymToHexName.put("gray25", "#404040");
-        synonymToHexName.put("gray26", "#424242");
-        synonymToHexName.put("gray27", "#454545");
-        synonymToHexName.put("gray28", "#474747");
-        synonymToHexName.put("gray29", "#4A4A4A");
-        synonymToHexName.put("gray30", "#4D4D4D");
-        synonymToHexName.put("gray31", "#4F4F4F");
-        synonymToHexName.put("gray32", "#525252");
-        synonymToHexName.put("gray33", "#545454");
-        synonymToHexName.put("gray34", "#575757");
-        synonymToHexName.put("gray35", "#595959");
-        synonymToHexName.put("gray36", "#5C5C5C");
-        synonymToHexName.put("gray37", "#5E5E5E");
-        synonymToHexName.put("gray38", "#616161");
-        synonymToHexName.put("gray39", "#636363");
-        synonymToHexName.put("gray40", "#666666");
-        synonymToHexName.put("gray41", "#696969");
-        synonymToHexName.put("gray42", "#6B6B6B");
-        synonymToHexName.put("gray43", "#6E6E6E");
-        synonymToHexName.put("gray44", "#707070");
-        synonymToHexName.put("gray45", "#737373");
-        synonymToHexName.put("gray46", "#757575");
-        synonymToHexName.put("gray47", "#787878");
-        synonymToHexName.put("gray48", "#7A7A7A");
-        synonymToHexName.put("gray49", "#7D7D7D");
-        synonymToHexName.put("gray50", "#7F7F7F");
-        synonymToHexName.put("gray51", "#828282");
-        synonymToHexName.put("gray52", "#858585");
-        synonymToHexName.put("gray53", "#878787");
-        synonymToHexName.put("gray54", "#8A8A8A");
-        synonymToHexName.put("gray55", "#8C8C8C");
-        synonymToHexName.put("gray56", "#8F8F8F");
-        synonymToHexName.put("gray57", "#919191");
-        synonymToHexName.put("gray58", "#949494");
-        synonymToHexName.put("gray59", "#969696");
-        synonymToHexName.put("gray60", "#999999");
-        synonymToHexName.put("gray61", "#9C9C9C");
-        synonymToHexName.put("gray62", "#9E9E9E");
-        synonymToHexName.put("gray63", "#A1A1A1");
-        synonymToHexName.put("gray64", "#A3A3A3");
-        synonymToHexName.put("gray65", "#A6A6A6");
-        synonymToHexName.put("gray66", "#A8A8A8");
-        synonymToHexName.put("gray67", "#ABABAB");
-        synonymToHexName.put("gray68", "#ADADAD");
-        synonymToHexName.put("gray69", "#B0B0B0");
-        synonymToHexName.put("gray70", "#B3B3B3");
-        synonymToHexName.put("gray71", "#B5B5B5");
-        synonymToHexName.put("gray72", "#B8B8B8");
-        synonymToHexName.put("gray73", "#BABABA");
-        synonymToHexName.put("gray74", "#BDBDBD");
-        synonymToHexName.put("gray75", "#BFBFBF");
-        synonymToHexName.put("gray76", "#C2C2C2");
-        synonymToHexName.put("gray77", "#C4C4C4");
-        synonymToHexName.put("gray78", "#C7C7C7");
-        synonymToHexName.put("gray79", "#C9C9C9");
-        synonymToHexName.put("gray80", "#CCCCCC");
-        synonymToHexName.put("gray81", "#CFCFCF");
-        synonymToHexName.put("gray82", "#D1D1D1");
-        synonymToHexName.put("gray83", "#D4D4D4");
-        synonymToHexName.put("gray84", "#D6D6D6");
-        synonymToHexName.put("gray85", "#D9D9D9");
-        synonymToHexName.put("gray86", "#DBDBDB");
-        synonymToHexName.put("gray87", "#DEDEDE");
-        synonymToHexName.put("gray88", "#E0E0E0");
-        synonymToHexName.put("gray89", "#E3E3E3");
-        synonymToHexName.put("gray90", "#E5E5E5");
-        synonymToHexName.put("gray91", "#E8E8E8");
-        synonymToHexName.put("gray92", "#EBEBEB");
-        synonymToHexName.put("gray93", "#EDEDED");
-        synonymToHexName.put("gray94", "#F0F0F0");
-        synonymToHexName.put("gray95", "#F2F2F2");
-        synonymToHexName.put("gray96", "#F5F5F5");
-        synonymToHexName.put("gray97", "#F7F7F7");
-        synonymToHexName.put("gray98", "#FAFAFA");
-        synonymToHexName.put("gray99", "#FCFCFC");
-        synonymToHexName.put("gray100", "#FFFFFF");
-        synonymToHexName.put("green", "#00FF00");
-        synonymToHexName.put("green1", "#00FF00");
-        synonymToHexName.put("green2", "#00EE00");
-        synonymToHexName.put("green3", "#00CD00");
-        synonymToHexName.put("green4", "#008B00");
-        synonymToHexName.put("greenyellow", "#ADFF2F");
-        synonymToHexName.put("grey", "#BEBEBE");
-        synonymToHexName.put("grey0", "#000000");
-        synonymToHexName.put("grey1", "#030303");
-        synonymToHexName.put("grey2", "#050505");
-        synonymToHexName.put("grey3", "#080808");
-        synonymToHexName.put("grey4", "#0A0A0A");
-        synonymToHexName.put("grey5", "#0D0D0D");
-        synonymToHexName.put("grey6", "#0F0F0F");
-        synonymToHexName.put("grey7", "#121212");
-        synonymToHexName.put("grey8", "#141414");
-        synonymToHexName.put("grey9", "#171717");
-        synonymToHexName.put("grey10", "#1A1A1A");
-        synonymToHexName.put("grey11", "#1C1C1C");
-        synonymToHexName.put("grey12", "#1F1F1F");
-        synonymToHexName.put("grey13", "#212121");
-        synonymToHexName.put("grey14", "#242424");
-        synonymToHexName.put("grey15", "#262626");
-        synonymToHexName.put("grey16", "#292929");
-        synonymToHexName.put("grey17", "#2B2B2B");
-        synonymToHexName.put("grey18", "#2E2E2E");
-        synonymToHexName.put("grey19", "#303030");
-        synonymToHexName.put("grey20", "#333333");
-        synonymToHexName.put("grey21", "#363636");
-        synonymToHexName.put("grey22", "#383838");
-        synonymToHexName.put("grey23", "#3B3B3B");
-        synonymToHexName.put("grey24", "#3D3D3D");
-        synonymToHexName.put("grey25", "#404040");
-        synonymToHexName.put("grey26", "#424242");
-        synonymToHexName.put("grey27", "#454545");
-        synonymToHexName.put("grey28", "#474747");
-        synonymToHexName.put("grey29", "#4A4A4A");
-        synonymToHexName.put("grey30", "#4D4D4D");
-        synonymToHexName.put("grey31", "#4F4F4F");
-        synonymToHexName.put("grey32", "#525252");
-        synonymToHexName.put("grey33", "#545454");
-        synonymToHexName.put("grey34", "#575757");
-        synonymToHexName.put("grey35", "#595959");
-        synonymToHexName.put("grey36", "#5C5C5C");
-        synonymToHexName.put("grey37", "#5E5E5E");
-        synonymToHexName.put("grey38", "#616161");
-        synonymToHexName.put("grey39", "#636363");
-        synonymToHexName.put("grey40", "#666666");
-        synonymToHexName.put("grey41", "#696969");
-        synonymToHexName.put("grey42", "#6B6B6B");
-        synonymToHexName.put("grey43", "#6E6E6E");
-        synonymToHexName.put("grey44", "#707070");
-        synonymToHexName.put("grey45", "#737373");
-        synonymToHexName.put("grey46", "#757575");
-        synonymToHexName.put("grey47", "#787878");
-        synonymToHexName.put("grey48", "#7A7A7A");
-        synonymToHexName.put("grey49", "#7D7D7D");
-        synonymToHexName.put("grey50", "#7F7F7F");
-        synonymToHexName.put("grey51", "#828282");
-        synonymToHexName.put("grey52", "#858585");
-        synonymToHexName.put("grey53", "#878787");
-        synonymToHexName.put("grey54", "#8A8A8A");
-        synonymToHexName.put("grey55", "#8C8C8C");
-        synonymToHexName.put("grey56", "#8F8F8F");
-        synonymToHexName.put("grey57", "#919191");
-        synonymToHexName.put("grey58", "#949494");
-        synonymToHexName.put("grey59", "#969696");
-        synonymToHexName.put("grey60", "#999999");
-        synonymToHexName.put("grey61", "#9C9C9C");
-        synonymToHexName.put("grey62", "#9E9E9E");
-        synonymToHexName.put("grey63", "#A1A1A1");
-        synonymToHexName.put("grey64", "#A3A3A3");
-        synonymToHexName.put("grey65", "#A6A6A6");
-        synonymToHexName.put("grey66", "#A8A8A8");
-        synonymToHexName.put("grey67", "#ABABAB");
-        synonymToHexName.put("grey68", "#ADADAD");
-        synonymToHexName.put("grey69", "#B0B0B0");
-        synonymToHexName.put("grey70", "#B3B3B3");
-        synonymToHexName.put("grey71", "#B5B5B5");
-        synonymToHexName.put("grey72", "#B8B8B8");
-        synonymToHexName.put("grey73", "#BABABA");
-        synonymToHexName.put("grey74", "#BDBDBD");
-        synonymToHexName.put("grey75", "#BFBFBF");
-        synonymToHexName.put("grey76", "#C2C2C2");
-        synonymToHexName.put("grey77", "#C4C4C4");
-        synonymToHexName.put("grey78", "#C7C7C7");
-        synonymToHexName.put("grey79", "#C9C9C9");
-        synonymToHexName.put("grey80", "#CCCCCC");
-        synonymToHexName.put("grey81", "#CFCFCF");
-        synonymToHexName.put("grey82", "#D1D1D1");
-        synonymToHexName.put("grey83", "#D4D4D4");
-        synonymToHexName.put("grey84", "#D6D6D6");
-        synonymToHexName.put("grey85", "#D9D9D9");
-        synonymToHexName.put("grey86", "#DBDBDB");
-        synonymToHexName.put("grey87", "#DEDEDE");
-        synonymToHexName.put("grey88", "#E0E0E0");
-        synonymToHexName.put("grey89", "#E3E3E3");
-        synonymToHexName.put("grey90", "#E5E5E5");
-        synonymToHexName.put("grey91", "#E8E8E8");
-        synonymToHexName.put("grey92", "#EBEBEB");
-        synonymToHexName.put("grey93", "#EDEDED");
-        synonymToHexName.put("grey94", "#F0F0F0");
-        synonymToHexName.put("grey95", "#F2F2F2");
-        synonymToHexName.put("grey96", "#F5F5F5");
-        synonymToHexName.put("grey97", "#F7F7F7");
-        synonymToHexName.put("grey98", "#FAFAFA");
-        synonymToHexName.put("grey99", "#FCFCFC");
-        synonymToHexName.put("grey100", "#FFFFFF");
-        synonymToHexName.put("honeydew", "#F0FFF0");
-        synonymToHexName.put("honeydew1", "#F0FFF0");
-        synonymToHexName.put("honeydew2", "#E0EEE0");
-        synonymToHexName.put("honeydew3", "#C1CDC1");
-        synonymToHexName.put("honeydew4", "#838B83");
-        synonymToHexName.put("hotpink", "#FF69B4");
-        synonymToHexName.put("hotpink1", "#FF6EB4");
-        synonymToHexName.put("hotpink2", "#EE6AA7");
-        synonymToHexName.put("hotpink3", "#CD6090");
-        synonymToHexName.put("hotpink4", "#8B3A62");
-        synonymToHexName.put("indianred", "#CD5C5C");
-        synonymToHexName.put("indianred1", "#FF6A6A");
-        synonymToHexName.put("indianred2", "#EE6363");
-        synonymToHexName.put("indianred3", "#CD5555");
-        synonymToHexName.put("indianred4", "#8B3A3A");
-        synonymToHexName.put("ivory", "#FFFFF0");
-        synonymToHexName.put("ivory1", "#FFFFF0");
-        synonymToHexName.put("ivory2", "#EEEEE0");
-        synonymToHexName.put("ivory3", "#CDCDC1");
-        synonymToHexName.put("ivory4", "#8B8B83");
-        synonymToHexName.put("khaki", "#F0E68C");
-        synonymToHexName.put("khaki1", "#FFF68F");
-        synonymToHexName.put("khaki2", "#EEE685");
-        synonymToHexName.put("khaki3", "#CDC673");
-        synonymToHexName.put("khaki4", "#8B864E");
-        synonymToHexName.put("lavender", "#E6E6FA");
-        synonymToHexName.put("lavenderblush", "#FFF0F5");
-        synonymToHexName.put("lavenderblush1", "#FFF0F5");
-        synonymToHexName.put("lavenderblush2", "#EEE0E5");
-        synonymToHexName.put("lavenderblush3", "#CDC1C5");
-        synonymToHexName.put("lavenderblush4", "#8B8386");
-        synonymToHexName.put("lawngreen", "#7CFC00");
-        synonymToHexName.put("lemonchiffon", "#FFFACD");
-        synonymToHexName.put("lemonchiffon1", "#FFFACD");
-        synonymToHexName.put("lemonchiffon2", "#EEE9BF");
-        synonymToHexName.put("lemonchiffon3", "#CDC9A5");
-        synonymToHexName.put("lemonchiffon4", "#8B8970");
-        synonymToHexName.put("lightblue", "#ADD8E6");
-        synonymToHexName.put("lightblue1", "#BFEFFF");
-        synonymToHexName.put("lightblue2", "#B2DFEE");
-        synonymToHexName.put("lightblue3", "#9AC0CD");
-        synonymToHexName.put("lightblue4", "#68838B");
-        synonymToHexName.put("lightcoral", "#F08080");
-        synonymToHexName.put("lightcyan", "#E0FFFF");
-        synonymToHexName.put("lightcyan1", "#E0FFFF");
-        synonymToHexName.put("lightcyan2", "#D1EEEE");
-        synonymToHexName.put("lightcyan3", "#B4CDCD");
-        synonymToHexName.put("lightcyan4", "#7A8B8B");
-        synonymToHexName.put("lightgoldenrod", "#EEDD82");
-        synonymToHexName.put("lightgoldenrod1", "#FFEC8B");
-        synonymToHexName.put("lightgoldenrod2", "#EEDC82");
-        synonymToHexName.put("lightgoldenrod3", "#CDBE70");
-        synonymToHexName.put("lightgoldenrod4", "#8B814C");
-        synonymToHexName.put("lightgoldenrodyellow", "#FAFAD2");
-        synonymToHexName.put("lightgray", "#D3D3D3");
-        synonymToHexName.put("lightgreen", "#90EE90");
-        synonymToHexName.put("lightgrey", "#D3D3D3");
-        synonymToHexName.put("lightpink", "#FFB6C1");
-        synonymToHexName.put("lightpink1", "#FFAEB9");
-        synonymToHexName.put("lightpink2", "#EEA2AD");
-        synonymToHexName.put("lightpink3", "#CD8C95");
-        synonymToHexName.put("lightpink4", "#8B5F65");
-        synonymToHexName.put("lightsalmon", "#FFA07A");
-        synonymToHexName.put("lightsalmon1", "#FFA07A");
-        synonymToHexName.put("lightsalmon2", "#EE9572");
-        synonymToHexName.put("lightsalmon3", "#CD8162");
-        synonymToHexName.put("lightsalmon4", "#8B5742");
-        synonymToHexName.put("lightseagreen", "#20B2AA");
-        synonymToHexName.put("lightskyblue", "#87CEFA");
-        synonymToHexName.put("lightskyblue1", "#B0E2FF");
-        synonymToHexName.put("lightskyblue2", "#A4D3EE");
-        synonymToHexName.put("lightskyblue3", "#8DB6CD");
-        synonymToHexName.put("lightskyblue4", "#607B8B");
-        synonymToHexName.put("lightslateblue", "#8470FF");
-        synonymToHexName.put("lightslategray", "#778899");
-        synonymToHexName.put("lightslategrey", "#778899");
-        synonymToHexName.put("lightsteelblue", "#B0C4DE");
-        synonymToHexName.put("lightsteelblue1", "#CAE1FF");
-        synonymToHexName.put("lightsteelblue2", "#BCD2EE");
-        synonymToHexName.put("lightsteelblue3", "#A2B5CD");
-        synonymToHexName.put("lightsteelblue4", "#6E7B8B");
-        synonymToHexName.put("lightyellow", "#FFFFE0");
-        synonymToHexName.put("lightyellow1", "#FFFFE0");
-        synonymToHexName.put("lightyellow2", "#EEEED1");
-        synonymToHexName.put("lightyellow3", "#CDCDB4");
-        synonymToHexName.put("lightyellow4", "#8B8B7A");
-        synonymToHexName.put("limegreen", "#32CD32");
-        synonymToHexName.put("linen", "#FAF0E6");
-        synonymToHexName.put("magenta", "#FF00FF");
-        synonymToHexName.put("magenta1", "#FF00FF");
-        synonymToHexName.put("magenta2", "#EE00EE");
-        synonymToHexName.put("magenta3", "#CD00CD");
-        synonymToHexName.put("magenta4", "#8B008B");
-        synonymToHexName.put("maroon", "#B03060");
-        synonymToHexName.put("maroon1", "#FF34B3");
-        synonymToHexName.put("maroon2", "#EE30A7");
-        synonymToHexName.put("maroon3", "#CD2990");
-        synonymToHexName.put("maroon4", "#8B1C62");
-        synonymToHexName.put("mediumaquamarine", "#66CDAA");
-        synonymToHexName.put("mediumblue", "#0000CD");
-        synonymToHexName.put("mediumorchid", "#BA55D3");
-        synonymToHexName.put("mediumorchid1", "#E066FF");
-        synonymToHexName.put("mediumorchid2", "#D15FEE");
-        synonymToHexName.put("mediumorchid3", "#B452CD");
-        synonymToHexName.put("mediumorchid4", "#7A378B");
-        synonymToHexName.put("mediumpurple", "#9370DB");
-        synonymToHexName.put("mediumpurple1", "#AB82FF");
-        synonymToHexName.put("mediumpurple2", "#9F79EE");
-        synonymToHexName.put("mediumpurple3", "#8968CD");
-        synonymToHexName.put("mediumpurple4", "#5D478B");
-        synonymToHexName.put("mediumseagreen", "#3CB371");
-        synonymToHexName.put("mediumslateblue", "#7B68EE");
-        synonymToHexName.put("mediumspringgreen", "#00FA9A");
-        synonymToHexName.put("mediumturquoise", "#48D1CC");
-        synonymToHexName.put("mediumvioletred", "#C71585");
-        synonymToHexName.put("midnightblue", "#191970");
-        synonymToHexName.put("mintcream", "#F5FFFA");
-        synonymToHexName.put("mistyrose", "#FFE4E1");
-        synonymToHexName.put("mistyrose1", "#FFE4E1");
-        synonymToHexName.put("mistyrose2", "#EED5D2");
-        synonymToHexName.put("mistyrose3", "#CDB7B5");
-        synonymToHexName.put("mistyrose4", "#8B7D7B");
-        synonymToHexName.put("moccasin", "#FFE4B5");
-        synonymToHexName.put("navajowhite", "#FFDEAD");
-        synonymToHexName.put("navajowhite1", "#FFDEAD");
-        synonymToHexName.put("navajowhite2", "#EECFA1");
-        synonymToHexName.put("navajowhite3", "#CDB38B");
-        synonymToHexName.put("navajowhite4", "#8B795E");
-        synonymToHexName.put("navy", "#000080");
-        synonymToHexName.put("navyblue", "#000080");
-        synonymToHexName.put("oldlace", "#FDF5E6");
-        synonymToHexName.put("olivedrab", "#6B8E23");
-        synonymToHexName.put("olivedrab1", "#C0FF3E");
-        synonymToHexName.put("olivedrab2", "#B3EE3A");
-        synonymToHexName.put("olivedrab3", "#9ACD32");
-        synonymToHexName.put("olivedrab4", "#698B22");
-        synonymToHexName.put("orange", "#FFA500");
-        synonymToHexName.put("orange1", "#FFA500");
-        synonymToHexName.put("orange2", "#EE9A00");
-        synonymToHexName.put("orange3", "#CD8500");
-        synonymToHexName.put("orange4", "#8B5A00");
-        synonymToHexName.put("orangered", "#FF4500");
-        synonymToHexName.put("orangered1", "#FF4500");
-        synonymToHexName.put("orangered2", "#EE4000");
-        synonymToHexName.put("orangered3", "#CD3700");
-        synonymToHexName.put("orangered4", "#8B2500");
-        synonymToHexName.put("orchid", "#DA70D6");
-        synonymToHexName.put("orchid1", "#FF83FA");
-        synonymToHexName.put("orchid2", "#EE7AE9");
-        synonymToHexName.put("orchid3", "#CD69C9");
-        synonymToHexName.put("orchid4", "#8B4789");
-        synonymToHexName.put("palegoldenrod", "#EEE8AA");
-        synonymToHexName.put("palegreen", "#98FB98");
-        synonymToHexName.put("palegreen1", "#9AFF9A");
-        synonymToHexName.put("palegreen2", "#90EE90");
-        synonymToHexName.put("palegreen3", "#7CCD7C");
-        synonymToHexName.put("palegreen4", "#548B54");
-        synonymToHexName.put("paleturquoise", "#AFEEEE");
-        synonymToHexName.put("paleturquoise1", "#BBFFFF");
-        synonymToHexName.put("paleturquoise2", "#AEEEEE");
-        synonymToHexName.put("paleturquoise3", "#96CDCD");
-        synonymToHexName.put("paleturquoise4", "#668B8B");
-        synonymToHexName.put("palevioletred", "#DB7093");
-        synonymToHexName.put("palevioletred1", "#FF82AB");
-        synonymToHexName.put("palevioletred2", "#EE799F");
-        synonymToHexName.put("palevioletred3", "#CD6889");
-        synonymToHexName.put("palevioletred4", "#8B475D");
-        synonymToHexName.put("papayawhip", "#FFEFD5");
-        synonymToHexName.put("peachpuff", "#FFDAB9");
-        synonymToHexName.put("peachpuff1", "#FFDAB9");
-        synonymToHexName.put("peachpuff2", "#EECBAD");
-        synonymToHexName.put("peachpuff3", "#CDAF95");
-        synonymToHexName.put("peachpuff4", "#8B7765");
-        synonymToHexName.put("peru", "#CD853F");
-        synonymToHexName.put("pink", "#FFC0CB");
-        synonymToHexName.put("pink1", "#FFB5C5");
-        synonymToHexName.put("pink2", "#EEA9B8");
-        synonymToHexName.put("pink3", "#CD919E");
-        synonymToHexName.put("pink4", "#8B636C");
-        synonymToHexName.put("plum", "#DDA0DD");
-        synonymToHexName.put("plum1", "#FFBBFF");
-        synonymToHexName.put("plum2", "#EEAEEE");
-        synonymToHexName.put("plum3", "#CD96CD");
-        synonymToHexName.put("plum4", "#8B668B");
-        synonymToHexName.put("powderblue", "#B0E0E6");
-        synonymToHexName.put("purple", "#A020F0");
-        synonymToHexName.put("purple1", "#9B30FF");
-        synonymToHexName.put("purple2", "#912CEE");
-        synonymToHexName.put("purple3", "#7D26CD");
-        synonymToHexName.put("purple4", "#551A8B");
-        synonymToHexName.put("red", "#FF0000");
-        synonymToHexName.put("red1", "#FF0000");
-        synonymToHexName.put("red2", "#EE0000");
-        synonymToHexName.put("red3", "#CD0000");
-        synonymToHexName.put("red4", "#8B0000");
-        synonymToHexName.put("rosybrown", "#BC8F8F");
-        synonymToHexName.put("rosybrown1", "#FFC1C1");
-        synonymToHexName.put("rosybrown2", "#EEB4B4");
-        synonymToHexName.put("rosybrown3", "#CD9B9B");
-        synonymToHexName.put("rosybrown4", "#8B6969");
-        synonymToHexName.put("royalblue", "#4169E1");
-        synonymToHexName.put("royalblue1", "#4876FF");
-        synonymToHexName.put("royalblue2", "#436EEE");
-        synonymToHexName.put("royalblue3", "#3A5FCD");
-        synonymToHexName.put("royalblue4", "#27408B");
-        synonymToHexName.put("snewData.addlebrown", "#8B4513");
-        synonymToHexName.put("salmon", "#FA8072");
-        synonymToHexName.put("salmon1", "#FF8C69");
-        synonymToHexName.put("salmon2", "#EE8262");
-        synonymToHexName.put("salmon3", "#CD7054");
-        synonymToHexName.put("salmon4", "#8B4C39");
-        synonymToHexName.put("sandybrown", "#F4A460");
-        synonymToHexName.put("seagreen", "#2E8B57");
-        synonymToHexName.put("seagreen1", "#54FF9F");
-        synonymToHexName.put("seagreen2", "#4EEE94");
-        synonymToHexName.put("seagreen3", "#43CD80");
-        synonymToHexName.put("seagreen4", "#2E8B57");
-        synonymToHexName.put("seashell", "#FFF5EE");
-        synonymToHexName.put("seashell1", "#FFF5EE");
-        synonymToHexName.put("seashell2", "#EEE5DE");
-        synonymToHexName.put("seashell3", "#CDC5BF");
-        synonymToHexName.put("seashell4", "#8B8682");
-        synonymToHexName.put("sienna", "#A0522D");
-        synonymToHexName.put("sienna1", "#FF8247");
-        synonymToHexName.put("sienna2", "#EE7942");
-        synonymToHexName.put("sienna3", "#CD6839");
-        synonymToHexName.put("sienna4", "#8B4726");
-        synonymToHexName.put("skyblue", "#87CEEB");
-        synonymToHexName.put("skyblue1", "#87CEFF");
-        synonymToHexName.put("skyblue2", "#7EC0EE");
-        synonymToHexName.put("skyblue3", "#6CA6CD");
-        synonymToHexName.put("skyblue4", "#4A708B");
-        synonymToHexName.put("slateblue", "#6A5ACD");
-        synonymToHexName.put("slateblue1", "#836FFF");
-        synonymToHexName.put("slateblue2", "#7A67EE");
-        synonymToHexName.put("slateblue3", "#6959CD");
-        synonymToHexName.put("slateblue4", "#473C8B");
-        synonymToHexName.put("slategray", "#708090");
-        synonymToHexName.put("slategray1", "#C6E2FF");
-        synonymToHexName.put("slategray2", "#B9D3EE");
-        synonymToHexName.put("slategray3", "#9FB6CD");
-        synonymToHexName.put("slategray4", "#6C7B8B");
-        synonymToHexName.put("slategrey", "#708090");
-        synonymToHexName.put("snow", "#FFFAFA");
-        synonymToHexName.put("snow1", "#FFFAFA");
-        synonymToHexName.put("snow2", "#EEE9E9");
-        synonymToHexName.put("snow3", "#CDC9C9");
-        synonymToHexName.put("snow4", "#8B8989");
-        synonymToHexName.put("springgreen", "#00FF7F");
-        synonymToHexName.put("springgreen1", "#00FF7F");
-        synonymToHexName.put("springgreen2", "#00EE76");
-        synonymToHexName.put("springgreen3", "#00CD66");
-        synonymToHexName.put("springgreen4", "#008B45");
-        synonymToHexName.put("steelblue", "#4682B4");
-        synonymToHexName.put("steelblue1", "#63B8FF");
-        synonymToHexName.put("steelblue2", "#5CACEE");
-        synonymToHexName.put("steelblue3", "#4F94CD");
-        synonymToHexName.put("steelblue4", "#36648B");
-        synonymToHexName.put("tan", "#D2B48C");
-        synonymToHexName.put("tan1", "#FFA54F");
-        synonymToHexName.put("tan2", "#EE9A49");
-        synonymToHexName.put("tan3", "#CD853F");
-        synonymToHexName.put("tan4", "#8B5A2B");
-        synonymToHexName.put("thistle", "#D8BFD8");
-        synonymToHexName.put("thistle1", "#FFE1FF");
-        synonymToHexName.put("thistle2", "#EED2EE");
-        synonymToHexName.put("thistle3", "#CDB5CD");
-        synonymToHexName.put("thistle4", "#8B7B8B");
-        synonymToHexName.put("tomato", "#FF6347");
-        synonymToHexName.put("tomato1", "#FF6347");
-        synonymToHexName.put("tomato2", "#EE5C42");
-        synonymToHexName.put("tomato3", "#CD4F39");
-        synonymToHexName.put("tomato4", "#8B3626");
-        synonymToHexName.put("turquoise", "#40E0D0");
-        synonymToHexName.put("turquoise1", "#00F5FF");
-        synonymToHexName.put("turquoise2", "#00E5EE");
-        synonymToHexName.put("turquoise3", "#00C5CD");
-        synonymToHexName.put("turquoise4", "#00868B");
-        synonymToHexName.put("violet", "#EE82EE");
-        synonymToHexName.put("violetred", "#D02090");
-        synonymToHexName.put("violetred1", "#FF3E96");
-        synonymToHexName.put("violetred2", "#EE3A8C");
-        synonymToHexName.put("violetred3", "#CD3278");
-        synonymToHexName.put("violetred4", "#8B2252");
-        synonymToHexName.put("wheat", "#F5DEB3");
-        synonymToHexName.put("wheat1", "#FFE7BA");
-        synonymToHexName.put("wheat2", "#EED8AE");
-        synonymToHexName.put("wheat3", "#CDBA96");
-        synonymToHexName.put("wheat4", "#8B7E66");
-        synonymToHexName.put("whitesmoke", "#F5F5F5");
-        synonymToHexName.put("yellow", "#FFFF00");
-        synonymToHexName.put("yellow1", "#FFFF00");
-        synonymToHexName.put("yellow2", "#EEEE00");
-        synonymToHexName.put("yellow3", "#CDCD00");
-        synonymToHexName.put("yellow4", "#8B8B00");
-        synonymToHexName.put("yellowgreen", "#9ACD32");
-    }
-}
diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GPar.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GPar.java
index 49d587cf37..33d7761a60 100644
--- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GPar.java
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GPar.java
@@ -16,6 +16,7 @@ import static com.oracle.truffle.r.library.fastrGrid.GridUtils.asDouble;
 import java.util.Arrays;
 
 import com.oracle.truffle.r.library.fastrGrid.device.DrawingContext;
+import com.oracle.truffle.r.library.fastrGrid.device.GridColor;
 import com.oracle.truffle.r.runtime.RRuntime;
 import com.oracle.truffle.r.runtime.data.RDataFactory;
 import com.oracle.truffle.r.runtime.data.RList;
@@ -81,7 +82,7 @@ public final class GPar {
     public static RList createNew() {
         Object[] data = new Object[GP_LENGTH];
         Arrays.fill(data, RNull.instance);
-        data[GP_FILL] = "black";
+        data[GP_FILL] = "grey";
         data[GP_COL] = "black";
         data[GP_GAMMA] = newDoubleVec(0);
         data[GP_LTY] = "solid"; // TODO: LineType enum...
@@ -119,13 +120,13 @@ public final class GPar {
         }
 
         @Override
-        public String getColor() {
-            return getHexColor(GP_COL);
+        public GridColor getColor() {
+            return getGridColor(GP_COL);
         }
 
         @Override
-        public void setColor(String hexCode) {
-            data[GP_COL] = hexCode;
+        public void setColor(GridColor color) {
+            data[GP_COL] = GridColorUtils.gridColorToRString(color);
         }
 
         @Override
@@ -139,21 +140,17 @@ public final class GPar {
         }
 
         @Override
-        public String getFillColor() {
-            return getHexColor(GP_FILL);
+        public GridColor getFillColor() {
+            return getGridColor(GP_FILL);
         }
 
         @Override
-        public void setFillColor(String hexCode) {
-            data[GP_FILL] = hexCode;
+        public void setFillColor(GridColor color) {
+            data[GP_FILL] = GridColorUtils.gridColorToRString(color);
         }
 
-        private String getHexColor(int index) {
-            String result = RRuntime.asString(data[index]);
-            if (!result.startsWith("#")) {
-                result = ColorNames.findByName(result);
-            }
-            return result == null ? "#FFFFFF" : result;
+        private GridColor getGridColor(int index) {
+            return GridColorUtils.gridColorFromString(RRuntime.asString(data[index]));
         }
     }
 }
diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridColorUtils.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridColorUtils.java
new file mode 100644
index 0000000000..1fc036ea84
--- /dev/null
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridColorUtils.java
@@ -0,0 +1,745 @@
+/*
+ * This material is distributed under the GNU General Public License
+ * Version 2. You may review the terms of this license at
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * Copyright (c) 1997-2014, The R Core Team
+ * Copyright (c) 2003, The R Foundation
+ * Copyright (c) 2017, Oracle and/or its affiliates
+ *
+ * All rights reserved.
+ */
+package com.oracle.truffle.r.library.fastrGrid;
+
+import java.util.HashMap;
+import java.util.Locale;
+
+import com.oracle.truffle.r.library.fastrGrid.device.GridColor;
+import com.oracle.truffle.r.runtime.RError;
+import com.oracle.truffle.r.runtime.RError.Message;
+
+public class GridColorUtils {
+    private static HashMap<String, Object> synonymToColor;
+
+    /**
+     * Converts the representation of color used within R, e.g. as value for
+     * {@code gpar(col='value')}, to our internal representation that grid device should understand.
+     * The acceptable color formats are: name of known color, HTML style hex value, and HTML style
+     * hex value including alpha.
+     */
+    public static GridColor gridColorFromString(String value) {
+        if (value.startsWith("#") && (value.length() == 7 || value.length() == 9)) {
+            return parseHex(value);
+        }
+
+        Object result = findByName(value);
+        if (result == null) {
+            throw RError.error(RError.NO_CALLER, Message.GENERIC, "Invalid color '" + value + "'.");
+        }
+        if (result instanceof String) {
+            return parseHex((String) result);
+        }
+        assert result instanceof GridColor : "synonyms map should only contain Strings and GridColors";
+        return (GridColor) result;
+    }
+
+    public static String gridColorToRString(GridColor color) {
+        if (color.getAlpha() == GridColor.OPAQUE_ALPHA) {
+            return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
+        }
+        return String.format("#%02x%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
+    }
+
+    private static GridColor parseHex(String value) {
+        // hex format, e.g. #ffffff
+        int red = Integer.parseInt(value.substring(1, 3), 16);
+        int green = Integer.parseInt(value.substring(3, 5), 16);
+        int blue = Integer.parseInt(value.substring(5, 7), 16);
+        int alpha = GridColor.OPAQUE_ALPHA;
+        if (value.length() == 9) {
+            alpha = Integer.parseInt(value.substring(7, 9), 16);
+        }
+        return new GridColor(red, green, blue, alpha);
+    }
+
+    private static Object findByName(String synonym) {
+        if (synonymToColor == null) {
+            initialize();
+        }
+        return synonymToColor.get(normalizeColorName(synonym));
+    }
+
+    // GnuR compares the user given color name to the dictionary ignoring spaces and case. We remove
+    // the spaces and make it lowercase and then use normal string comparison.
+    private static String normalizeColorName(String synonym) {
+        boolean isNormalized = true;
+        for (int i = 0; i < synonym.length(); i++) {
+            char c = synonym.charAt(i);
+            isNormalized &= (!Character.isAlphabetic(c) || Character.isLowerCase(c)) && c != ' ';
+        }
+        return isNormalized ? synonym : synonym.replace(" ", "").toLowerCase(Locale.ROOT);
+    }
+
+    private static void initialize() {
+        synonymToColor = new HashMap<>(700);
+        synonymToColor.put("transparent", GridColor.TRANSPARENT);
+        synonymToColor.put("NA", GridColor.TRANSPARENT);
+        synonymToColor.put("white", "#FFFFFF");
+        synonymToColor.put("aliceblue", "#F0F8FF");
+        synonymToColor.put("antiquewhite", "#FAEBD7");
+        synonymToColor.put("antiquewhite1", "#FFEFDB");
+        synonymToColor.put("antiquewhite2", "#EEDFCC");
+        synonymToColor.put("antiquewhite3", "#CDC0B0");
+        synonymToColor.put("antiquewhite4", "#8B8378");
+        synonymToColor.put("aquamarine", "#7FFFD4");
+        synonymToColor.put("aquamarine1", "#7FFFD4");
+        synonymToColor.put("aquamarine2", "#76EEC6");
+        synonymToColor.put("aquamarine3", "#66CDAA");
+        synonymToColor.put("aquamarine4", "#458B74");
+        synonymToColor.put("azure", "#F0FFFF");
+        synonymToColor.put("azure1", "#F0FFFF");
+        synonymToColor.put("azure2", "#E0EEEE");
+        synonymToColor.put("azure3", "#C1CDCD");
+        synonymToColor.put("azure4", "#838B8B");
+        synonymToColor.put("beige", "#F5F5DC");
+        synonymToColor.put("bisque", "#FFE4C4");
+        synonymToColor.put("bisque1", "#FFE4C4");
+        synonymToColor.put("bisque2", "#EED5B7");
+        synonymToColor.put("bisque3", "#CDB79E");
+        synonymToColor.put("bisque4", "#8B7D6B");
+        synonymToColor.put("black", "#000000");
+        synonymToColor.put("blanchedalmond", "#FFEBCD");
+        synonymToColor.put("blue", "#0000FF");
+        synonymToColor.put("blue1", "#0000FF");
+        synonymToColor.put("blue2", "#0000EE");
+        synonymToColor.put("blue3", "#0000CD");
+        synonymToColor.put("blue4", "#00008B");
+        synonymToColor.put("blueviolet", "#8A2BE2");
+        synonymToColor.put("brown", "#A52A2A");
+        synonymToColor.put("brown1", "#FF4040");
+        synonymToColor.put("brown2", "#EE3B3B");
+        synonymToColor.put("brown3", "#CD3333");
+        synonymToColor.put("brown4", "#8B2323");
+        synonymToColor.put("burlywood", "#DEB887");
+        synonymToColor.put("burlywood1", "#FFD39B");
+        synonymToColor.put("burlywood2", "#EEC591");
+        synonymToColor.put("burlywood3", "#CDAA7D");
+        synonymToColor.put("burlywood4", "#8B7355");
+        synonymToColor.put("cadetblue", "#5F9EA0");
+        synonymToColor.put("cadetblue1", "#98F5FF");
+        synonymToColor.put("cadetblue2", "#8EE5EE");
+        synonymToColor.put("cadetblue3", "#7AC5CD");
+        synonymToColor.put("cadetblue4", "#53868B");
+        synonymToColor.put("chartreuse", "#7FFF00");
+        synonymToColor.put("chartreuse1", "#7FFF00");
+        synonymToColor.put("chartreuse2", "#76EE00");
+        synonymToColor.put("chartreuse3", "#66CD00");
+        synonymToColor.put("chartreuse4", "#458B00");
+        synonymToColor.put("chocolate", "#D2691E");
+        synonymToColor.put("chocolate1", "#FF7F24");
+        synonymToColor.put("chocolate2", "#EE7621");
+        synonymToColor.put("chocolate3", "#CD661D");
+        synonymToColor.put("chocolate4", "#8B4513");
+        synonymToColor.put("coral", "#FF7F50");
+        synonymToColor.put("coral1", "#FF7256");
+        synonymToColor.put("coral2", "#EE6A50");
+        synonymToColor.put("coral3", "#CD5B45");
+        synonymToColor.put("coral4", "#8B3E2F");
+        synonymToColor.put("cornflowerblue", "#6495ED");
+        synonymToColor.put("cornsilk", "#FFF8DC");
+        synonymToColor.put("cornsilk1", "#FFF8DC");
+        synonymToColor.put("cornsilk2", "#EEE8CD");
+        synonymToColor.put("cornsilk3", "#CDC8B1");
+        synonymToColor.put("cornsilk4", "#8B8878");
+        synonymToColor.put("cyan", "#00FFFF");
+        synonymToColor.put("cyan1", "#00FFFF");
+        synonymToColor.put("cyan2", "#00EEEE");
+        synonymToColor.put("cyan3", "#00CDCD");
+        synonymToColor.put("cyan4", "#008B8B");
+        synonymToColor.put("darkblue", "#00008B");
+        synonymToColor.put("darkcyan", "#008B8B");
+        synonymToColor.put("darkgoldenrod", "#B8860B");
+        synonymToColor.put("darkgoldenrod1", "#FFB90F");
+        synonymToColor.put("darkgoldenrod2", "#EEAD0E");
+        synonymToColor.put("darkgoldenrod3", "#CD950C");
+        synonymToColor.put("darkgoldenrod4", "#8B6508");
+        synonymToColor.put("darkgray", "#A9A9A9");
+        synonymToColor.put("darkgreen", "#006400");
+        synonymToColor.put("darkgrey", "#A9A9A9");
+        synonymToColor.put("darkkhaki", "#BDB76B");
+        synonymToColor.put("darkmagenta", "#8B008B");
+        synonymToColor.put("darkolivegreen", "#556B2F");
+        synonymToColor.put("darkolivegreen1", "#CAFF70");
+        synonymToColor.put("darkolivegreen2", "#BCEE68");
+        synonymToColor.put("darkolivegreen3", "#A2CD5A");
+        synonymToColor.put("darkolivegreen4", "#6E8B3D");
+        synonymToColor.put("darkorange", "#FF8C00");
+        synonymToColor.put("darkorange1", "#FF7F00");
+        synonymToColor.put("darkorange2", "#EE7600");
+        synonymToColor.put("darkorange3", "#CD6600");
+        synonymToColor.put("darkorange4", "#8B4500");
+        synonymToColor.put("darkorchid", "#9932CC");
+        synonymToColor.put("darkorchid1", "#BF3EFF");
+        synonymToColor.put("darkorchid2", "#B23AEE");
+        synonymToColor.put("darkorchid3", "#9A32CD");
+        synonymToColor.put("darkorchid4", "#68228B");
+        synonymToColor.put("darkred", "#8B0000");
+        synonymToColor.put("darksalmon", "#E9967A");
+        synonymToColor.put("darkseagreen", "#8FBC8F");
+        synonymToColor.put("darkseagreen1", "#C1FFC1");
+        synonymToColor.put("darkseagreen2", "#B4EEB4");
+        synonymToColor.put("darkseagreen3", "#9BCD9B");
+        synonymToColor.put("darkseagreen4", "#698B69");
+        synonymToColor.put("darkslateblue", "#483D8B");
+        synonymToColor.put("darkslategray", "#2F4F4F");
+        synonymToColor.put("darkslategray1", "#97FFFF");
+        synonymToColor.put("darkslategray2", "#8DEEEE");
+        synonymToColor.put("darkslategray3", "#79CDCD");
+        synonymToColor.put("darkslategray4", "#528B8B");
+        synonymToColor.put("darkslategrey", "#2F4F4F");
+        synonymToColor.put("darkturquoise", "#00CED1");
+        synonymToColor.put("darkviolet", "#9400D3");
+        synonymToColor.put("deeppink", "#FF1493");
+        synonymToColor.put("deeppink1", "#FF1493");
+        synonymToColor.put("deeppink2", "#EE1289");
+        synonymToColor.put("deeppink3", "#CD1076");
+        synonymToColor.put("deeppink4", "#8B0A50");
+        synonymToColor.put("deepskyblue", "#00BFFF");
+        synonymToColor.put("deepskyblue1", "#00BFFF");
+        synonymToColor.put("deepskyblue2", "#00B2EE");
+        synonymToColor.put("deepskyblue3", "#009ACD");
+        synonymToColor.put("deepskyblue4", "#00688B");
+        synonymToColor.put("dimgray", "#696969");
+        synonymToColor.put("dimgrey", "#696969");
+        synonymToColor.put("dodgerblue", "#1E90FF");
+        synonymToColor.put("dodgerblue1", "#1E90FF");
+        synonymToColor.put("dodgerblue2", "#1C86EE");
+        synonymToColor.put("dodgerblue3", "#1874CD");
+        synonymToColor.put("dodgerblue4", "#104E8B");
+        synonymToColor.put("firebrick", "#B22222");
+        synonymToColor.put("firebrick1", "#FF3030");
+        synonymToColor.put("firebrick2", "#EE2C2C");
+        synonymToColor.put("firebrick3", "#CD2626");
+        synonymToColor.put("firebrick4", "#8B1A1A");
+        synonymToColor.put("floralwhite", "#FFFAF0");
+        synonymToColor.put("forestgreen", "#228B22");
+        synonymToColor.put("gainsboro", "#DCDCDC");
+        synonymToColor.put("ghostwhite", "#F8F8FF");
+        synonymToColor.put("gold", "#FFD700");
+        synonymToColor.put("gold1", "#FFD700");
+        synonymToColor.put("gold2", "#EEC900");
+        synonymToColor.put("gold3", "#CDAD00");
+        synonymToColor.put("gold4", "#8B7500");
+        synonymToColor.put("goldenrod", "#DAA520");
+        synonymToColor.put("goldenrod1", "#FFC125");
+        synonymToColor.put("goldenrod2", "#EEB422");
+        synonymToColor.put("goldenrod3", "#CD9B1D");
+        synonymToColor.put("goldenrod4", "#8B6914");
+        synonymToColor.put("gray", "#BEBEBE");
+        synonymToColor.put("gray0", "#000000");
+        synonymToColor.put("gray1", "#030303");
+        synonymToColor.put("gray2", "#050505");
+        synonymToColor.put("gray3", "#080808");
+        synonymToColor.put("gray4", "#0A0A0A");
+        synonymToColor.put("gray5", "#0D0D0D");
+        synonymToColor.put("gray6", "#0F0F0F");
+        synonymToColor.put("gray7", "#121212");
+        synonymToColor.put("gray8", "#141414");
+        synonymToColor.put("gray9", "#171717");
+        synonymToColor.put("gray10", "#1A1A1A");
+        synonymToColor.put("gray11", "#1C1C1C");
+        synonymToColor.put("gray12", "#1F1F1F");
+        synonymToColor.put("gray13", "#212121");
+        synonymToColor.put("gray14", "#242424");
+        synonymToColor.put("gray15", "#262626");
+        synonymToColor.put("gray16", "#292929");
+        synonymToColor.put("gray17", "#2B2B2B");
+        synonymToColor.put("gray18", "#2E2E2E");
+        synonymToColor.put("gray19", "#303030");
+        synonymToColor.put("gray20", "#333333");
+        synonymToColor.put("gray21", "#363636");
+        synonymToColor.put("gray22", "#383838");
+        synonymToColor.put("gray23", "#3B3B3B");
+        synonymToColor.put("gray24", "#3D3D3D");
+        synonymToColor.put("gray25", "#404040");
+        synonymToColor.put("gray26", "#424242");
+        synonymToColor.put("gray27", "#454545");
+        synonymToColor.put("gray28", "#474747");
+        synonymToColor.put("gray29", "#4A4A4A");
+        synonymToColor.put("gray30", "#4D4D4D");
+        synonymToColor.put("gray31", "#4F4F4F");
+        synonymToColor.put("gray32", "#525252");
+        synonymToColor.put("gray33", "#545454");
+        synonymToColor.put("gray34", "#575757");
+        synonymToColor.put("gray35", "#595959");
+        synonymToColor.put("gray36", "#5C5C5C");
+        synonymToColor.put("gray37", "#5E5E5E");
+        synonymToColor.put("gray38", "#616161");
+        synonymToColor.put("gray39", "#636363");
+        synonymToColor.put("gray40", "#666666");
+        synonymToColor.put("gray41", "#696969");
+        synonymToColor.put("gray42", "#6B6B6B");
+        synonymToColor.put("gray43", "#6E6E6E");
+        synonymToColor.put("gray44", "#707070");
+        synonymToColor.put("gray45", "#737373");
+        synonymToColor.put("gray46", "#757575");
+        synonymToColor.put("gray47", "#787878");
+        synonymToColor.put("gray48", "#7A7A7A");
+        synonymToColor.put("gray49", "#7D7D7D");
+        synonymToColor.put("gray50", "#7F7F7F");
+        synonymToColor.put("gray51", "#828282");
+        synonymToColor.put("gray52", "#858585");
+        synonymToColor.put("gray53", "#878787");
+        synonymToColor.put("gray54", "#8A8A8A");
+        synonymToColor.put("gray55", "#8C8C8C");
+        synonymToColor.put("gray56", "#8F8F8F");
+        synonymToColor.put("gray57", "#919191");
+        synonymToColor.put("gray58", "#949494");
+        synonymToColor.put("gray59", "#969696");
+        synonymToColor.put("gray60", "#999999");
+        synonymToColor.put("gray61", "#9C9C9C");
+        synonymToColor.put("gray62", "#9E9E9E");
+        synonymToColor.put("gray63", "#A1A1A1");
+        synonymToColor.put("gray64", "#A3A3A3");
+        synonymToColor.put("gray65", "#A6A6A6");
+        synonymToColor.put("gray66", "#A8A8A8");
+        synonymToColor.put("gray67", "#ABABAB");
+        synonymToColor.put("gray68", "#ADADAD");
+        synonymToColor.put("gray69", "#B0B0B0");
+        synonymToColor.put("gray70", "#B3B3B3");
+        synonymToColor.put("gray71", "#B5B5B5");
+        synonymToColor.put("gray72", "#B8B8B8");
+        synonymToColor.put("gray73", "#BABABA");
+        synonymToColor.put("gray74", "#BDBDBD");
+        synonymToColor.put("gray75", "#BFBFBF");
+        synonymToColor.put("gray76", "#C2C2C2");
+        synonymToColor.put("gray77", "#C4C4C4");
+        synonymToColor.put("gray78", "#C7C7C7");
+        synonymToColor.put("gray79", "#C9C9C9");
+        synonymToColor.put("gray80", "#CCCCCC");
+        synonymToColor.put("gray81", "#CFCFCF");
+        synonymToColor.put("gray82", "#D1D1D1");
+        synonymToColor.put("gray83", "#D4D4D4");
+        synonymToColor.put("gray84", "#D6D6D6");
+        synonymToColor.put("gray85", "#D9D9D9");
+        synonymToColor.put("gray86", "#DBDBDB");
+        synonymToColor.put("gray87", "#DEDEDE");
+        synonymToColor.put("gray88", "#E0E0E0");
+        synonymToColor.put("gray89", "#E3E3E3");
+        synonymToColor.put("gray90", "#E5E5E5");
+        synonymToColor.put("gray91", "#E8E8E8");
+        synonymToColor.put("gray92", "#EBEBEB");
+        synonymToColor.put("gray93", "#EDEDED");
+        synonymToColor.put("gray94", "#F0F0F0");
+        synonymToColor.put("gray95", "#F2F2F2");
+        synonymToColor.put("gray96", "#F5F5F5");
+        synonymToColor.put("gray97", "#F7F7F7");
+        synonymToColor.put("gray98", "#FAFAFA");
+        synonymToColor.put("gray99", "#FCFCFC");
+        synonymToColor.put("gray100", "#FFFFFF");
+        synonymToColor.put("green", "#00FF00");
+        synonymToColor.put("green1", "#00FF00");
+        synonymToColor.put("green2", "#00EE00");
+        synonymToColor.put("green3", "#00CD00");
+        synonymToColor.put("green4", "#008B00");
+        synonymToColor.put("greenyellow", "#ADFF2F");
+        synonymToColor.put("grey", "#BEBEBE");
+        synonymToColor.put("grey0", "#000000");
+        synonymToColor.put("grey1", "#030303");
+        synonymToColor.put("grey2", "#050505");
+        synonymToColor.put("grey3", "#080808");
+        synonymToColor.put("grey4", "#0A0A0A");
+        synonymToColor.put("grey5", "#0D0D0D");
+        synonymToColor.put("grey6", "#0F0F0F");
+        synonymToColor.put("grey7", "#121212");
+        synonymToColor.put("grey8", "#141414");
+        synonymToColor.put("grey9", "#171717");
+        synonymToColor.put("grey10", "#1A1A1A");
+        synonymToColor.put("grey11", "#1C1C1C");
+        synonymToColor.put("grey12", "#1F1F1F");
+        synonymToColor.put("grey13", "#212121");
+        synonymToColor.put("grey14", "#242424");
+        synonymToColor.put("grey15", "#262626");
+        synonymToColor.put("grey16", "#292929");
+        synonymToColor.put("grey17", "#2B2B2B");
+        synonymToColor.put("grey18", "#2E2E2E");
+        synonymToColor.put("grey19", "#303030");
+        synonymToColor.put("grey20", "#333333");
+        synonymToColor.put("grey21", "#363636");
+        synonymToColor.put("grey22", "#383838");
+        synonymToColor.put("grey23", "#3B3B3B");
+        synonymToColor.put("grey24", "#3D3D3D");
+        synonymToColor.put("grey25", "#404040");
+        synonymToColor.put("grey26", "#424242");
+        synonymToColor.put("grey27", "#454545");
+        synonymToColor.put("grey28", "#474747");
+        synonymToColor.put("grey29", "#4A4A4A");
+        synonymToColor.put("grey30", "#4D4D4D");
+        synonymToColor.put("grey31", "#4F4F4F");
+        synonymToColor.put("grey32", "#525252");
+        synonymToColor.put("grey33", "#545454");
+        synonymToColor.put("grey34", "#575757");
+        synonymToColor.put("grey35", "#595959");
+        synonymToColor.put("grey36", "#5C5C5C");
+        synonymToColor.put("grey37", "#5E5E5E");
+        synonymToColor.put("grey38", "#616161");
+        synonymToColor.put("grey39", "#636363");
+        synonymToColor.put("grey40", "#666666");
+        synonymToColor.put("grey41", "#696969");
+        synonymToColor.put("grey42", "#6B6B6B");
+        synonymToColor.put("grey43", "#6E6E6E");
+        synonymToColor.put("grey44", "#707070");
+        synonymToColor.put("grey45", "#737373");
+        synonymToColor.put("grey46", "#757575");
+        synonymToColor.put("grey47", "#787878");
+        synonymToColor.put("grey48", "#7A7A7A");
+        synonymToColor.put("grey49", "#7D7D7D");
+        synonymToColor.put("grey50", "#7F7F7F");
+        synonymToColor.put("grey51", "#828282");
+        synonymToColor.put("grey52", "#858585");
+        synonymToColor.put("grey53", "#878787");
+        synonymToColor.put("grey54", "#8A8A8A");
+        synonymToColor.put("grey55", "#8C8C8C");
+        synonymToColor.put("grey56", "#8F8F8F");
+        synonymToColor.put("grey57", "#919191");
+        synonymToColor.put("grey58", "#949494");
+        synonymToColor.put("grey59", "#969696");
+        synonymToColor.put("grey60", "#999999");
+        synonymToColor.put("grey61", "#9C9C9C");
+        synonymToColor.put("grey62", "#9E9E9E");
+        synonymToColor.put("grey63", "#A1A1A1");
+        synonymToColor.put("grey64", "#A3A3A3");
+        synonymToColor.put("grey65", "#A6A6A6");
+        synonymToColor.put("grey66", "#A8A8A8");
+        synonymToColor.put("grey67", "#ABABAB");
+        synonymToColor.put("grey68", "#ADADAD");
+        synonymToColor.put("grey69", "#B0B0B0");
+        synonymToColor.put("grey70", "#B3B3B3");
+        synonymToColor.put("grey71", "#B5B5B5");
+        synonymToColor.put("grey72", "#B8B8B8");
+        synonymToColor.put("grey73", "#BABABA");
+        synonymToColor.put("grey74", "#BDBDBD");
+        synonymToColor.put("grey75", "#BFBFBF");
+        synonymToColor.put("grey76", "#C2C2C2");
+        synonymToColor.put("grey77", "#C4C4C4");
+        synonymToColor.put("grey78", "#C7C7C7");
+        synonymToColor.put("grey79", "#C9C9C9");
+        synonymToColor.put("grey80", "#CCCCCC");
+        synonymToColor.put("grey81", "#CFCFCF");
+        synonymToColor.put("grey82", "#D1D1D1");
+        synonymToColor.put("grey83", "#D4D4D4");
+        synonymToColor.put("grey84", "#D6D6D6");
+        synonymToColor.put("grey85", "#D9D9D9");
+        synonymToColor.put("grey86", "#DBDBDB");
+        synonymToColor.put("grey87", "#DEDEDE");
+        synonymToColor.put("grey88", "#E0E0E0");
+        synonymToColor.put("grey89", "#E3E3E3");
+        synonymToColor.put("grey90", "#E5E5E5");
+        synonymToColor.put("grey91", "#E8E8E8");
+        synonymToColor.put("grey92", "#EBEBEB");
+        synonymToColor.put("grey93", "#EDEDED");
+        synonymToColor.put("grey94", "#F0F0F0");
+        synonymToColor.put("grey95", "#F2F2F2");
+        synonymToColor.put("grey96", "#F5F5F5");
+        synonymToColor.put("grey97", "#F7F7F7");
+        synonymToColor.put("grey98", "#FAFAFA");
+        synonymToColor.put("grey99", "#FCFCFC");
+        synonymToColor.put("grey100", "#FFFFFF");
+        synonymToColor.put("honeydew", "#F0FFF0");
+        synonymToColor.put("honeydew1", "#F0FFF0");
+        synonymToColor.put("honeydew2", "#E0EEE0");
+        synonymToColor.put("honeydew3", "#C1CDC1");
+        synonymToColor.put("honeydew4", "#838B83");
+        synonymToColor.put("hotpink", "#FF69B4");
+        synonymToColor.put("hotpink1", "#FF6EB4");
+        synonymToColor.put("hotpink2", "#EE6AA7");
+        synonymToColor.put("hotpink3", "#CD6090");
+        synonymToColor.put("hotpink4", "#8B3A62");
+        synonymToColor.put("indianred", "#CD5C5C");
+        synonymToColor.put("indianred1", "#FF6A6A");
+        synonymToColor.put("indianred2", "#EE6363");
+        synonymToColor.put("indianred3", "#CD5555");
+        synonymToColor.put("indianred4", "#8B3A3A");
+        synonymToColor.put("ivory", "#FFFFF0");
+        synonymToColor.put("ivory1", "#FFFFF0");
+        synonymToColor.put("ivory2", "#EEEEE0");
+        synonymToColor.put("ivory3", "#CDCDC1");
+        synonymToColor.put("ivory4", "#8B8B83");
+        synonymToColor.put("khaki", "#F0E68C");
+        synonymToColor.put("khaki1", "#FFF68F");
+        synonymToColor.put("khaki2", "#EEE685");
+        synonymToColor.put("khaki3", "#CDC673");
+        synonymToColor.put("khaki4", "#8B864E");
+        synonymToColor.put("lavender", "#E6E6FA");
+        synonymToColor.put("lavenderblush", "#FFF0F5");
+        synonymToColor.put("lavenderblush1", "#FFF0F5");
+        synonymToColor.put("lavenderblush2", "#EEE0E5");
+        synonymToColor.put("lavenderblush3", "#CDC1C5");
+        synonymToColor.put("lavenderblush4", "#8B8386");
+        synonymToColor.put("lawngreen", "#7CFC00");
+        synonymToColor.put("lemonchiffon", "#FFFACD");
+        synonymToColor.put("lemonchiffon1", "#FFFACD");
+        synonymToColor.put("lemonchiffon2", "#EEE9BF");
+        synonymToColor.put("lemonchiffon3", "#CDC9A5");
+        synonymToColor.put("lemonchiffon4", "#8B8970");
+        synonymToColor.put("lightblue", "#ADD8E6");
+        synonymToColor.put("lightblue1", "#BFEFFF");
+        synonymToColor.put("lightblue2", "#B2DFEE");
+        synonymToColor.put("lightblue3", "#9AC0CD");
+        synonymToColor.put("lightblue4", "#68838B");
+        synonymToColor.put("lightcoral", "#F08080");
+        synonymToColor.put("lightcyan", "#E0FFFF");
+        synonymToColor.put("lightcyan1", "#E0FFFF");
+        synonymToColor.put("lightcyan2", "#D1EEEE");
+        synonymToColor.put("lightcyan3", "#B4CDCD");
+        synonymToColor.put("lightcyan4", "#7A8B8B");
+        synonymToColor.put("lightgoldenrod", "#EEDD82");
+        synonymToColor.put("lightgoldenrod1", "#FFEC8B");
+        synonymToColor.put("lightgoldenrod2", "#EEDC82");
+        synonymToColor.put("lightgoldenrod3", "#CDBE70");
+        synonymToColor.put("lightgoldenrod4", "#8B814C");
+        synonymToColor.put("lightgoldenrodyellow", "#FAFAD2");
+        synonymToColor.put("lightgray", "#D3D3D3");
+        synonymToColor.put("lightgreen", "#90EE90");
+        synonymToColor.put("lightgrey", "#D3D3D3");
+        synonymToColor.put("lightpink", "#FFB6C1");
+        synonymToColor.put("lightpink1", "#FFAEB9");
+        synonymToColor.put("lightpink2", "#EEA2AD");
+        synonymToColor.put("lightpink3", "#CD8C95");
+        synonymToColor.put("lightpink4", "#8B5F65");
+        synonymToColor.put("lightsalmon", "#FFA07A");
+        synonymToColor.put("lightsalmon1", "#FFA07A");
+        synonymToColor.put("lightsalmon2", "#EE9572");
+        synonymToColor.put("lightsalmon3", "#CD8162");
+        synonymToColor.put("lightsalmon4", "#8B5742");
+        synonymToColor.put("lightseagreen", "#20B2AA");
+        synonymToColor.put("lightskyblue", "#87CEFA");
+        synonymToColor.put("lightskyblue1", "#B0E2FF");
+        synonymToColor.put("lightskyblue2", "#A4D3EE");
+        synonymToColor.put("lightskyblue3", "#8DB6CD");
+        synonymToColor.put("lightskyblue4", "#607B8B");
+        synonymToColor.put("lightslateblue", "#8470FF");
+        synonymToColor.put("lightslategray", "#778899");
+        synonymToColor.put("lightslategrey", "#778899");
+        synonymToColor.put("lightsteelblue", "#B0C4DE");
+        synonymToColor.put("lightsteelblue1", "#CAE1FF");
+        synonymToColor.put("lightsteelblue2", "#BCD2EE");
+        synonymToColor.put("lightsteelblue3", "#A2B5CD");
+        synonymToColor.put("lightsteelblue4", "#6E7B8B");
+        synonymToColor.put("lightyellow", "#FFFFE0");
+        synonymToColor.put("lightyellow1", "#FFFFE0");
+        synonymToColor.put("lightyellow2", "#EEEED1");
+        synonymToColor.put("lightyellow3", "#CDCDB4");
+        synonymToColor.put("lightyellow4", "#8B8B7A");
+        synonymToColor.put("limegreen", "#32CD32");
+        synonymToColor.put("linen", "#FAF0E6");
+        synonymToColor.put("magenta", "#FF00FF");
+        synonymToColor.put("magenta1", "#FF00FF");
+        synonymToColor.put("magenta2", "#EE00EE");
+        synonymToColor.put("magenta3", "#CD00CD");
+        synonymToColor.put("magenta4", "#8B008B");
+        synonymToColor.put("maroon", "#B03060");
+        synonymToColor.put("maroon1", "#FF34B3");
+        synonymToColor.put("maroon2", "#EE30A7");
+        synonymToColor.put("maroon3", "#CD2990");
+        synonymToColor.put("maroon4", "#8B1C62");
+        synonymToColor.put("mediumaquamarine", "#66CDAA");
+        synonymToColor.put("mediumblue", "#0000CD");
+        synonymToColor.put("mediumorchid", "#BA55D3");
+        synonymToColor.put("mediumorchid1", "#E066FF");
+        synonymToColor.put("mediumorchid2", "#D15FEE");
+        synonymToColor.put("mediumorchid3", "#B452CD");
+        synonymToColor.put("mediumorchid4", "#7A378B");
+        synonymToColor.put("mediumpurple", "#9370DB");
+        synonymToColor.put("mediumpurple1", "#AB82FF");
+        synonymToColor.put("mediumpurple2", "#9F79EE");
+        synonymToColor.put("mediumpurple3", "#8968CD");
+        synonymToColor.put("mediumpurple4", "#5D478B");
+        synonymToColor.put("mediumseagreen", "#3CB371");
+        synonymToColor.put("mediumslateblue", "#7B68EE");
+        synonymToColor.put("mediumspringgreen", "#00FA9A");
+        synonymToColor.put("mediumturquoise", "#48D1CC");
+        synonymToColor.put("mediumvioletred", "#C71585");
+        synonymToColor.put("midnightblue", "#191970");
+        synonymToColor.put("mintcream", "#F5FFFA");
+        synonymToColor.put("mistyrose", "#FFE4E1");
+        synonymToColor.put("mistyrose1", "#FFE4E1");
+        synonymToColor.put("mistyrose2", "#EED5D2");
+        synonymToColor.put("mistyrose3", "#CDB7B5");
+        synonymToColor.put("mistyrose4", "#8B7D7B");
+        synonymToColor.put("moccasin", "#FFE4B5");
+        synonymToColor.put("navajowhite", "#FFDEAD");
+        synonymToColor.put("navajowhite1", "#FFDEAD");
+        synonymToColor.put("navajowhite2", "#EECFA1");
+        synonymToColor.put("navajowhite3", "#CDB38B");
+        synonymToColor.put("navajowhite4", "#8B795E");
+        synonymToColor.put("navy", "#000080");
+        synonymToColor.put("navyblue", "#000080");
+        synonymToColor.put("oldlace", "#FDF5E6");
+        synonymToColor.put("olivedrab", "#6B8E23");
+        synonymToColor.put("olivedrab1", "#C0FF3E");
+        synonymToColor.put("olivedrab2", "#B3EE3A");
+        synonymToColor.put("olivedrab3", "#9ACD32");
+        synonymToColor.put("olivedrab4", "#698B22");
+        synonymToColor.put("orange", "#FFA500");
+        synonymToColor.put("orange1", "#FFA500");
+        synonymToColor.put("orange2", "#EE9A00");
+        synonymToColor.put("orange3", "#CD8500");
+        synonymToColor.put("orange4", "#8B5A00");
+        synonymToColor.put("orangered", "#FF4500");
+        synonymToColor.put("orangered1", "#FF4500");
+        synonymToColor.put("orangered2", "#EE4000");
+        synonymToColor.put("orangered3", "#CD3700");
+        synonymToColor.put("orangered4", "#8B2500");
+        synonymToColor.put("orchid", "#DA70D6");
+        synonymToColor.put("orchid1", "#FF83FA");
+        synonymToColor.put("orchid2", "#EE7AE9");
+        synonymToColor.put("orchid3", "#CD69C9");
+        synonymToColor.put("orchid4", "#8B4789");
+        synonymToColor.put("palegoldenrod", "#EEE8AA");
+        synonymToColor.put("palegreen", "#98FB98");
+        synonymToColor.put("palegreen1", "#9AFF9A");
+        synonymToColor.put("palegreen2", "#90EE90");
+        synonymToColor.put("palegreen3", "#7CCD7C");
+        synonymToColor.put("palegreen4", "#548B54");
+        synonymToColor.put("paleturquoise", "#AFEEEE");
+        synonymToColor.put("paleturquoise1", "#BBFFFF");
+        synonymToColor.put("paleturquoise2", "#AEEEEE");
+        synonymToColor.put("paleturquoise3", "#96CDCD");
+        synonymToColor.put("paleturquoise4", "#668B8B");
+        synonymToColor.put("palevioletred", "#DB7093");
+        synonymToColor.put("palevioletred1", "#FF82AB");
+        synonymToColor.put("palevioletred2", "#EE799F");
+        synonymToColor.put("palevioletred3", "#CD6889");
+        synonymToColor.put("palevioletred4", "#8B475D");
+        synonymToColor.put("papayawhip", "#FFEFD5");
+        synonymToColor.put("peachpuff", "#FFDAB9");
+        synonymToColor.put("peachpuff1", "#FFDAB9");
+        synonymToColor.put("peachpuff2", "#EECBAD");
+        synonymToColor.put("peachpuff3", "#CDAF95");
+        synonymToColor.put("peachpuff4", "#8B7765");
+        synonymToColor.put("peru", "#CD853F");
+        synonymToColor.put("pink", "#FFC0CB");
+        synonymToColor.put("pink1", "#FFB5C5");
+        synonymToColor.put("pink2", "#EEA9B8");
+        synonymToColor.put("pink3", "#CD919E");
+        synonymToColor.put("pink4", "#8B636C");
+        synonymToColor.put("plum", "#DDA0DD");
+        synonymToColor.put("plum1", "#FFBBFF");
+        synonymToColor.put("plum2", "#EEAEEE");
+        synonymToColor.put("plum3", "#CD96CD");
+        synonymToColor.put("plum4", "#8B668B");
+        synonymToColor.put("powderblue", "#B0E0E6");
+        synonymToColor.put("purple", "#A020F0");
+        synonymToColor.put("purple1", "#9B30FF");
+        synonymToColor.put("purple2", "#912CEE");
+        synonymToColor.put("purple3", "#7D26CD");
+        synonymToColor.put("purple4", "#551A8B");
+        synonymToColor.put("red", "#FF0000");
+        synonymToColor.put("red1", "#FF0000");
+        synonymToColor.put("red2", "#EE0000");
+        synonymToColor.put("red3", "#CD0000");
+        synonymToColor.put("red4", "#8B0000");
+        synonymToColor.put("rosybrown", "#BC8F8F");
+        synonymToColor.put("rosybrown1", "#FFC1C1");
+        synonymToColor.put("rosybrown2", "#EEB4B4");
+        synonymToColor.put("rosybrown3", "#CD9B9B");
+        synonymToColor.put("rosybrown4", "#8B6969");
+        synonymToColor.put("royalblue", "#4169E1");
+        synonymToColor.put("royalblue1", "#4876FF");
+        synonymToColor.put("royalblue2", "#436EEE");
+        synonymToColor.put("royalblue3", "#3A5FCD");
+        synonymToColor.put("royalblue4", "#27408B");
+        synonymToColor.put("snewData.addlebrown", "#8B4513");
+        synonymToColor.put("salmon", "#FA8072");
+        synonymToColor.put("salmon1", "#FF8C69");
+        synonymToColor.put("salmon2", "#EE8262");
+        synonymToColor.put("salmon3", "#CD7054");
+        synonymToColor.put("salmon4", "#8B4C39");
+        synonymToColor.put("sandybrown", "#F4A460");
+        synonymToColor.put("seagreen", "#2E8B57");
+        synonymToColor.put("seagreen1", "#54FF9F");
+        synonymToColor.put("seagreen2", "#4EEE94");
+        synonymToColor.put("seagreen3", "#43CD80");
+        synonymToColor.put("seagreen4", "#2E8B57");
+        synonymToColor.put("seashell", "#FFF5EE");
+        synonymToColor.put("seashell1", "#FFF5EE");
+        synonymToColor.put("seashell2", "#EEE5DE");
+        synonymToColor.put("seashell3", "#CDC5BF");
+        synonymToColor.put("seashell4", "#8B8682");
+        synonymToColor.put("sienna", "#A0522D");
+        synonymToColor.put("sienna1", "#FF8247");
+        synonymToColor.put("sienna2", "#EE7942");
+        synonymToColor.put("sienna3", "#CD6839");
+        synonymToColor.put("sienna4", "#8B4726");
+        synonymToColor.put("skyblue", "#87CEEB");
+        synonymToColor.put("skyblue1", "#87CEFF");
+        synonymToColor.put("skyblue2", "#7EC0EE");
+        synonymToColor.put("skyblue3", "#6CA6CD");
+        synonymToColor.put("skyblue4", "#4A708B");
+        synonymToColor.put("slateblue", "#6A5ACD");
+        synonymToColor.put("slateblue1", "#836FFF");
+        synonymToColor.put("slateblue2", "#7A67EE");
+        synonymToColor.put("slateblue3", "#6959CD");
+        synonymToColor.put("slateblue4", "#473C8B");
+        synonymToColor.put("slategray", "#708090");
+        synonymToColor.put("slategray1", "#C6E2FF");
+        synonymToColor.put("slategray2", "#B9D3EE");
+        synonymToColor.put("slategray3", "#9FB6CD");
+        synonymToColor.put("slategray4", "#6C7B8B");
+        synonymToColor.put("slategrey", "#708090");
+        synonymToColor.put("snow", "#FFFAFA");
+        synonymToColor.put("snow1", "#FFFAFA");
+        synonymToColor.put("snow2", "#EEE9E9");
+        synonymToColor.put("snow3", "#CDC9C9");
+        synonymToColor.put("snow4", "#8B8989");
+        synonymToColor.put("springgreen", "#00FF7F");
+        synonymToColor.put("springgreen1", "#00FF7F");
+        synonymToColor.put("springgreen2", "#00EE76");
+        synonymToColor.put("springgreen3", "#00CD66");
+        synonymToColor.put("springgreen4", "#008B45");
+        synonymToColor.put("steelblue", "#4682B4");
+        synonymToColor.put("steelblue1", "#63B8FF");
+        synonymToColor.put("steelblue2", "#5CACEE");
+        synonymToColor.put("steelblue3", "#4F94CD");
+        synonymToColor.put("steelblue4", "#36648B");
+        synonymToColor.put("tan", "#D2B48C");
+        synonymToColor.put("tan1", "#FFA54F");
+        synonymToColor.put("tan2", "#EE9A49");
+        synonymToColor.put("tan3", "#CD853F");
+        synonymToColor.put("tan4", "#8B5A2B");
+        synonymToColor.put("thistle", "#D8BFD8");
+        synonymToColor.put("thistle1", "#FFE1FF");
+        synonymToColor.put("thistle2", "#EED2EE");
+        synonymToColor.put("thistle3", "#CDB5CD");
+        synonymToColor.put("thistle4", "#8B7B8B");
+        synonymToColor.put("tomato", "#FF6347");
+        synonymToColor.put("tomato1", "#FF6347");
+        synonymToColor.put("tomato2", "#EE5C42");
+        synonymToColor.put("tomato3", "#CD4F39");
+        synonymToColor.put("tomato4", "#8B3626");
+        synonymToColor.put("turquoise", "#40E0D0");
+        synonymToColor.put("turquoise1", "#00F5FF");
+        synonymToColor.put("turquoise2", "#00E5EE");
+        synonymToColor.put("turquoise3", "#00C5CD");
+        synonymToColor.put("turquoise4", "#00868B");
+        synonymToColor.put("violet", "#EE82EE");
+        synonymToColor.put("violetred", "#D02090");
+        synonymToColor.put("violetred1", "#FF3E96");
+        synonymToColor.put("violetred2", "#EE3A8C");
+        synonymToColor.put("violetred3", "#CD3278");
+        synonymToColor.put("violetred4", "#8B2252");
+        synonymToColor.put("wheat", "#F5DEB3");
+        synonymToColor.put("wheat1", "#FFE7BA");
+        synonymToColor.put("wheat2", "#EED8AE");
+        synonymToColor.put("wheat3", "#CDBA96");
+        synonymToColor.put("wheat4", "#8B7E66");
+        synonymToColor.put("whitesmoke", "#F5F5F5");
+        synonymToColor.put("yellow", "#FFFF00");
+        synonymToColor.put("yellow1", "#FFFF00");
+        synonymToColor.put("yellow2", "#EEEE00");
+        synonymToColor.put("yellow3", "#CDCD00");
+        synonymToColor.put("yellow4", "#8B8B00");
+        synonymToColor.put("yellowgreen", "#9ACD32");
+    }
+}
diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LPoints.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LPoints.java
index 5c40420695..040c72660f 100644
--- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LPoints.java
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LPoints.java
@@ -21,6 +21,7 @@ import com.oracle.truffle.r.library.fastrGrid.Unit.UnitToInchesNode;
 import com.oracle.truffle.r.library.fastrGrid.ViewPortContext.VPContextFromVPNode;
 import com.oracle.truffle.r.library.fastrGrid.ViewPortTransform.GetViewPortTransformNode;
 import com.oracle.truffle.r.library.fastrGrid.device.DrawingContext;
+import com.oracle.truffle.r.library.fastrGrid.device.GridColor;
 import com.oracle.truffle.r.library.fastrGrid.device.GridDevice;
 import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode;
 import com.oracle.truffle.r.runtime.RError.Message;
@@ -38,7 +39,6 @@ public abstract class LPoints extends RExternalBuiltinNode.Arg4 {
     private static final double TRC0 = 1.55512030155621416073; /* sqrt(4 * pi/(3 * sqrt(3))) */
     private static final double TRC1 = 1.34677368708859836060; /* TRC0 * sqrt(3) / 2 */
     private static final double TRC2 = 0.77756015077810708036; /* TRC0 / 2 */
-    private static final String TRANSPARENT = "white";  // TODO: should be actually transparent
 
     @Child private GetViewPortTransformNode getViewPortTransform = new GetViewPortTransformNode();
     @Child private VPContextFromVPNode vpContextFromVP = new VPContextFromVPNode();
@@ -112,9 +112,9 @@ public abstract class LPoints extends RExternalBuiltinNode.Arg4 {
     private static void drawDot(DrawingContext drawingCtx, GridDevice dev, double cex, double x, double y) {
         // NOTE: we are *filling* a rect with the current colour (we are not drawing the border AND
         // we are not using the current fill colour)
-        String originalFill = drawingCtx.getFillColor();
+        GridColor originalFill = drawingCtx.getFillColor();
         drawingCtx.setFillColor(drawingCtx.getColor());
-        drawingCtx.setColor(TRANSPARENT);
+        drawingCtx.setColor(GridColor.TRANSPARENT);
 
         /*
          * The idea here is to use a 0.01" square, but to be of at least one device unit in each
diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/DrawingContext.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/DrawingContext.java
index 1cd94bdabf..412f80ebf5 100644
--- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/DrawingContext.java
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/DrawingContext.java
@@ -28,17 +28,12 @@ package com.oracle.truffle.r.library.fastrGrid.device;
 public interface DrawingContext {
     double INCH_TO_POINTS_FACTOR = 72;
 
-    /**
-     * @return Hexadecimal string of the color with leading '#', e.g. '#FFA8B2'. Never returns a
-     *         synonym.
-     */
-    String getColor();
+    GridColor getColor();
 
     /**
-     * Alows to set the color. The parameter may also be a synonym defined in
-     * {@link com.oracle.truffle.r.library.fastrGrid.ColorNames}.
+     * Alows to set the color drawing color of shape borders, lines and text.
      */
-    void setColor(String hexCode);
+    void setColor(GridColor color);
 
     /**
      * Gets the font size in points.
@@ -52,15 +47,10 @@ public interface DrawingContext {
      */
     double getLineHeight();
 
-    /**
-     * @return Hexadecimal string of the color with leading '#', e.g. '#FFA8B2'. Never returns a
-     *         synonym.
-     */
-    String getFillColor();
+    GridColor getFillColor();
 
     /**
-     * Alows to set the fill color. The parameter may also be a synonym defined in
-     * {@link com.oracle.truffle.r.library.fastrGrid.ColorNames}.
+     * Alows to set the fill color of shapes.
      */
-    void setFillColor(String hexCode);
+    void setFillColor(GridColor color);
 }
diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/GridColor.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/GridColor.java
new file mode 100644
index 0000000000..e4cdd7517a
--- /dev/null
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/GridColor.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.r.library.fastrGrid.device;
+
+/**
+ * Simple color representation, so that the device interface does not have to depend on a specific
+ * GUI framework.
+ */
+public class GridColor {
+    public static final int OPAQUE_ALPHA = 0xff;
+    private static final int TRANSPARENT_ALPHA = 0;
+    public static final GridColor TRANSPARENT = new GridColor(0, 0, 0, TRANSPARENT_ALPHA);
+
+    private final int value;
+
+    public GridColor(int red, int green, int blue, int alpha) {
+        value = ((alpha & 0xFF) << 24) |
+                        ((red & 0xFF) << 16) |
+                        ((green & 0xFF) << 8) |
+                        (blue & 0xFF);
+    }
+
+    public int getRed() {
+        return (value >> 16) & 0xFF;
+    }
+
+    public int getGreen() {
+        return (value >> 8) & 0xFF;
+    }
+
+    public int getBlue() {
+        return value & 0xFF;
+    }
+
+    public int getAlpha() {
+        return (value >> 24) & 0xff;
+    }
+}
diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/JFrameDevice.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/JFrameDevice.java
index cf13bfd232..ff3c882103 100644
--- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/JFrameDevice.java
+++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/device/JFrameDevice.java
@@ -25,13 +25,17 @@ package com.oracle.truffle.r.library.fastrGrid.device;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Graphics2D;
+import java.awt.Paint;
 import java.awt.RenderingHints;
+import java.awt.Shape;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Ellipse2D;
 import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;
 import java.util.function.Supplier;
 
+import javax.swing.UIManager;
+
 import com.oracle.truffle.r.library.graphics.FastRFrame;
 
 public class JFrameDevice implements GridDevice {
@@ -66,7 +70,7 @@ public class JFrameDevice implements GridDevice {
     @Override
     public void drawRect(DrawingContext ctx, double leftX, double topY, double heigh, double width) {
         setContext(ctx);
-        graphics.draw(new Rectangle2D.Double(leftX, topY, heigh, width));
+        drawShape(ctx, new Rectangle2D.Double(leftX, topY, heigh, width));
     }
 
     @Override
@@ -85,7 +89,7 @@ public class JFrameDevice implements GridDevice {
     @Override
     public void drawCircle(DrawingContext ctx, double centerX, double centerY, double radius) {
         setContext(ctx);
-        graphics.draw(new Ellipse2D.Double(centerX - radius, centerY - radius, radius * 2d, radius * 2d));
+        drawShape(ctx, new Ellipse2D.Double(centerX - radius, centerY - radius, radius * 2d, radius * 2d));
     }
 
     @Override
@@ -127,9 +131,25 @@ public class JFrameDevice implements GridDevice {
         });
     }
 
+    @Override
+    public void initDrawingContext(DrawingContext ctx) {
+        Color color = UIManager.getColor("Panel.background");
+        if (color != null) {
+            ctx.setFillColor(toGridColor(color));
+        }
+    }
+
+    private void drawShape(DrawingContext drawingCtx, Shape shape) {
+        Paint paint = graphics.getPaint();
+        graphics.setPaint(fromGridColor(drawingCtx.getFillColor()));
+        graphics.fill(shape);
+        graphics.setPaint(paint);
+        graphics.draw(shape);
+    }
+
     private void setContext(DrawingContext ctx) {
         graphics.setFont(graphics.getFont().deriveFont((float) ctx.getFontSize()));
-        graphics.setColor(Color.decode(ctx.getColor()));
+        graphics.setColor(fromGridColor(ctx.getColor()));
     }
 
     private <T> T noTranform(Supplier<T> action) {
@@ -139,4 +159,12 @@ public class JFrameDevice implements GridDevice {
         graphics.setTransform(transform);
         return result;
     }
+
+    private static Color fromGridColor(GridColor color) {
+        return new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
+    }
+
+    private static GridColor toGridColor(Color color) {
+        return new GridColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
+    }
 }
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastrGrid/GridColorUtilsTests.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastrGrid/GridColorUtilsTests.java
new file mode 100644
index 0000000000..8e43a26774
--- /dev/null
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastrGrid/GridColorUtilsTests.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.r.test.library.fastrGrid;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.oracle.truffle.r.library.fastrGrid.GridColorUtils;
+import com.oracle.truffle.r.library.fastrGrid.device.GridColor;
+import com.oracle.truffle.r.test.TestBase;
+
+public class GridColorUtilsTests extends TestBase {
+    @Test
+    public void convertFromHex() {
+        GridColor color = GridColorUtils.gridColorFromString("#FF01FE");
+        assertEquals(255, color.getRed());
+        assertEquals(1, color.getGreen());
+        assertEquals(254, color.getBlue());
+        assertEquals(255, color.getAlpha());
+    }
+
+    @Test
+    public void convertFromHexWithAlpha() {
+        GridColor color = GridColorUtils.gridColorFromString("#FF00FE02");
+        assertEquals(255, color.getRed());
+        assertEquals(0, color.getGreen());
+        assertEquals(254, color.getBlue());
+        assertEquals(02, color.getAlpha());
+    }
+
+    @Test
+    public void convertSynonymBlack() {
+        GridColor black = GridColorUtils.gridColorFromString("black");
+        assertEquals(0, black.getRed());
+        assertEquals(0, black.getGreen());
+        assertEquals(0, black.getBlue());
+        assertEquals(255, black.getAlpha());
+    }
+
+    @Test
+    public void convertSynonymUpercaseRed() {
+        GridColor black = GridColorUtils.gridColorFromString("RED");
+        assertEquals(255, black.getRed());
+        assertEquals(0, black.getGreen());
+        assertEquals(0, black.getBlue());
+        assertEquals(255, black.getAlpha());
+    }
+
+    @Test
+    public void convertSynonymLightGreenWithSpace() {
+        GridColor black = GridColorUtils.gridColorFromString("light green");
+        assertEquals(0x90, black.getRed());
+        assertEquals(0xee, black.getGreen());
+        assertEquals(0x90, black.getBlue());
+        assertEquals(255, black.getAlpha());
+    }
+
+    @Test
+    public void convertSynonymLightGreen() {
+        GridColor black = GridColorUtils.gridColorFromString("light green");
+        assertEquals(0x90, black.getRed());
+        assertEquals(0xee, black.getGreen());
+        assertEquals(0x90, black.getBlue());
+        assertEquals(255, black.getAlpha());
+    }
+
+    @Test
+    public void convertSynonymTransparent() {
+        GridColor transparent = GridColorUtils.gridColorFromString("transparent");
+        assertEquals(0, transparent.getAlpha());
+    }
+}
diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides
index 2ed282f563..8cef96974b 100644
--- a/mx.fastr/copyrights/overrides
+++ b/mx.fastr/copyrights/overrides
@@ -786,7 +786,7 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ViewPort
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LLines.java,gnu_r_murrel_core.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ViewPortTransform.java,gnu_r_murrel_core.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LGridDirty.java,gnu_r_murrel_core.copyright
-com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/ColorNames.java,gnu_r.copyright
+com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridColorUtils.java,gnu_r.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/LCircle.java,gnu_r_murrel_core.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/EdgeDetection.java,gnu_r_murrel_core.copyright
 com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridTextNode.java,gnu_r_murrel_core.copyright
diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py
index 782257b532..259351b416 100644
--- a/mx.fastr/mx_fastr.py
+++ b/mx.fastr/mx_fastr.py
@@ -404,7 +404,7 @@ def _test_subpackage(name):
     return '.'.join((_test_package(), name))
 
 def _simple_generated_unit_tests():
-    return ','.join(map(_test_subpackage, ['engine.shell', 'library.base', 'library.grid', 'library.methods', 'library.stats', 'library.utils', 'library.fastr', 'builtins', 'functions', 'parser', 'rng', 'runtime.data', 'S4']))
+    return ','.join(map(_test_subpackage, ['engine.shell', 'library.base', 'library.fastrGrid', 'library.methods', 'library.stats', 'library.utils', 'library.fastr', 'builtins', 'functions', 'parser', 'rng', 'runtime.data', 'S4']))
 
 def _simple_unit_tests():
     return ','.join([_simple_generated_unit_tests(), _test_subpackage('tck')])
-- 
GitLab