001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.mappaint.mapcss;
003
004import java.awt.Color;
005import java.util.HashMap;
006import java.util.Map;
007
008public final class CSSColors {
009    private static final Map<String, Color> CSS_COLORS = new HashMap<>();
010    static {
011        Object[][] CSSCOLORS_INIT = new Object[][] {
012            {"aliceblue", 0xf0f8ff},
013            {"antiquewhite", 0xfaebd7},
014            {"aqua", 0x00ffff},
015            {"aquamarine", 0x7fffd4},
016            {"azure", 0xf0ffff},
017            {"beige", 0xf5f5dc},
018            {"bisque", 0xffe4c4},
019            {"black", 0x000000},
020            {"blanchedalmond", 0xffebcd},
021            {"blue", 0x0000ff},
022            {"blueviolet", 0x8a2be2},
023            {"brown", 0xa52a2a},
024            {"burlywood", 0xdeb887},
025            {"cadetblue", 0x5f9ea0},
026            {"chartreuse", 0x7fff00},
027            {"chocolate", 0xd2691e},
028            {"coral", 0xff7f50},
029            {"cornflowerblue", 0x6495ed},
030            {"cornsilk", 0xfff8dc},
031            {"crimson", 0xdc143c},
032            {"cyan", 0x00ffff},
033            {"darkblue", 0x00008b},
034            {"darkcyan", 0x008b8b},
035            {"darkgoldenrod", 0xb8860b},
036            {"darkgray", 0xa9a9a9},
037            {"darkgreen", 0x006400},
038            {"darkgrey", 0xa9a9a9},
039            {"darkkhaki", 0xbdb76b},
040            {"darkmagenta", 0x8b008b},
041            {"darkolivegreen", 0x556b2f},
042            {"darkorange", 0xff8c00},
043            {"darkorchid", 0x9932cc},
044            {"darkred", 0x8b0000},
045            {"darksalmon", 0xe9967a},
046            {"darkseagreen", 0x8fbc8f},
047            {"darkslateblue", 0x483d8b},
048            {"darkslategray", 0x2f4f4f},
049            {"darkslategrey", 0x2f4f4f},
050            {"darkturquoise", 0x00ced1},
051            {"darkviolet", 0x9400d3},
052            {"deeppink", 0xff1493},
053            {"deepskyblue", 0x00bfff},
054            {"dimgray", 0x696969},
055            {"dimgrey", 0x696969},
056            {"dodgerblue", 0x1e90ff},
057            {"firebrick", 0xb22222},
058            {"floralwhite", 0xfffaf0},
059            {"forestgreen", 0x228b22},
060            {"fuchsia", 0xff00ff},
061            {"gainsboro", 0xdcdcdc},
062            {"ghostwhite", 0xf8f8ff},
063            {"gold", 0xffd700},
064            {"goldenrod", 0xdaa520},
065            {"gray", 0x808080},
066            {"green", 0x008000},
067            {"greenyellow", 0xadff2f},
068            {"grey", 0x808080},
069            {"honeydew", 0xf0fff0},
070            {"hotpink", 0xff69b4},
071            {"indianred", 0xcd5c5c},
072            {"indigo", 0x4b0082},
073            {"ivory", 0xfffff0},
074            {"khaki", 0xf0e68c},
075            {"lavender", 0xe6e6fa},
076            {"lavenderblush", 0xfff0f5},
077            {"lawngreen", 0x7cfc00},
078            {"lemonchiffon", 0xfffacd},
079            {"lightblue", 0xadd8e6},
080            {"lightcoral", 0xf08080},
081            {"lightcyan", 0xe0ffff},
082            {"lightgoldenrodyellow", 0xfafad2},
083            {"lightgray", 0xd3d3d3},
084            {"lightgreen", 0x90ee90},
085            {"lightgrey", 0xd3d3d3},
086            {"lightpink", 0xffb6c1},
087            {"lightsalmon", 0xffa07a},
088            {"lightseagreen", 0x20b2aa},
089            {"lightskyblue", 0x87cefa},
090            {"lightslategray", 0x778899},
091            {"lightslategrey", 0x778899},
092            {"lightsteelblue", 0xb0c4de},
093            {"lightyellow", 0xffffe0},
094            {"lime", 0x00ff00},
095            {"limegreen", 0x32cd32},
096            {"linen", 0xfaf0e6},
097            {"magenta", 0xff00ff},
098            {"maroon", 0x800000},
099            {"mediumaquamarine", 0x66cdaa},
100            {"mediumblue", 0x0000cd},
101            {"mediumorchid", 0xba55d3},
102            {"mediumpurple", 0x9370db},
103            {"mediumseagreen", 0x3cb371},
104            {"mediumslateblue", 0x7b68ee},
105            {"mediumspringgreen", 0x00fa9a},
106            {"mediumturquoise", 0x48d1cc},
107            {"mediumvioletred", 0xc71585},
108            {"midnightblue", 0x191970},
109            {"mintcream", 0xf5fffa},
110            {"mistyrose", 0xffe4e1},
111            {"moccasin", 0xffe4b5},
112            {"navajowhite", 0xffdead},
113            {"navy", 0x000080},
114            {"oldlace", 0xfdf5e6},
115            {"olive", 0x808000},
116            {"olivedrab", 0x6b8e23},
117            {"orange", 0xffa500},
118            {"orangered", 0xff4500},
119            {"orchid", 0xda70d6},
120            {"palegoldenrod", 0xeee8aa},
121            {"palegreen", 0x98fb98},
122            {"paleturquoise", 0xafeeee},
123            {"palevioletred", 0xdb7093},
124            {"papayawhip", 0xffefd5},
125            {"peachpuff", 0xffdab9},
126            {"peru", 0xcd853f},
127            {"pink", 0xffc0cb},
128            {"plum", 0xdda0dd},
129            {"powderblue", 0xb0e0e6},
130            {"purple", 0x800080},
131            {"red", 0xff0000},
132            {"rosybrown", 0xbc8f8f},
133            {"royalblue", 0x4169e1},
134            {"saddlebrown", 0x8b4513},
135            {"salmon", 0xfa8072},
136            {"sandybrown", 0xf4a460},
137            {"seagreen", 0x2e8b57},
138            {"seashell", 0xfff5ee},
139            {"sienna", 0xa0522d},
140            {"silver", 0xc0c0c0},
141            {"skyblue", 0x87ceeb},
142            {"slateblue", 0x6a5acd},
143            {"slategray", 0x708090},
144            {"slategrey", 0x708090},
145            {"snow", 0xfffafa},
146            {"springgreen", 0x00ff7f},
147            {"steelblue", 0x4682b4},
148            {"tan", 0xd2b48c},
149            {"teal", 0x008080},
150            {"thistle", 0xd8bfd8},
151            {"tomato", 0xff6347},
152            {"turquoise", 0x40e0d0},
153            {"violet", 0xee82ee},
154            {"wheat", 0xf5deb3},
155            {"white", 0xffffff},
156            {"whitesmoke", 0xf5f5f5},
157            {"yellow", 0xffff00},
158            {"yellowgreen", 0x9acd32}
159        };
160        for (Object[] pair : CSSCOLORS_INIT) {
161            CSS_COLORS.put((String) pair[0], new Color((Integer) pair[1]));
162        }
163    }
164
165    /**
166     * Returns the CSS color for the given key
167     * @param key The key to find
168     * @return The color for {@code key}
169     */
170    public static Color get(String key) {
171        return CSS_COLORS.get(key);
172    }
173
174    private CSSColors() {
175        // Hide default constructor for utils classes
176    }
177}