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