Index: trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java	(revision 5576)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java	(revision 5577)
@@ -9,6 +9,8 @@
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 import org.openstreetmap.josm.gui.mappaint.mapcss.CSSColors;
+import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;
 import org.openstreetmap.josm.tools.Utils;
 
@@ -22,4 +24,6 @@
     protected Map<String, Object> prop = new HashMap<String, Object>();
 
+    private final static Pattern HEX_COLOR_PATTERN = Pattern.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})");
+
     public <T> T get(String key, T def, Class<T> klass) {
         return get(key, def, klass, false);
@@ -28,4 +32,5 @@
     /**
      * Get value for the given key
+     * @param <T> the expected type
      * @param key the key
      * @param def default value, can be null
@@ -165,4 +170,12 @@
         if (o instanceof Keyword)
             return CSSColors.get(((Keyword) o).val);
+        if (o instanceof String) {
+            Color c = CSSColors.get((String) o);
+            if (c != null)
+                return c;
+            if (HEX_COLOR_PATTERN.matcher((String) o).matches()) {
+                return Utils.hexToColor((String) o);
+            }
+        }
         return null;
     }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj	(revision 5576)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj	(revision 5577)
@@ -26,4 +26,5 @@
 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.LinkSelector;
 import org.openstreetmap.josm.tools.Pair;
+import org.openstreetmap.josm.tools.Utils;
 
 public class MapCSSParser {
@@ -553,14 +554,5 @@
         f=ufloat() { return f; }
     |
-        t=<HEXCOLOR>
-            {
-                String clr = t.image.substring(1);
-                if (clr.length() == 3) {
-                    clr = new String(new char[] {clr.charAt(0),clr.charAt(0),clr.charAt(1),clr.charAt(1),clr.charAt(2),clr.charAt(2)});
-                }
-                if (clr.length() != 6)
-                    throw new AssertionError();
-                return new Color(Integer.parseInt(clr, 16));
-            }
+        t=<HEXCOLOR> { return Utils.hexToColor(t.image); }
 }
 
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 5576)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 5577)
@@ -546,3 +546,22 @@
         };
     }
+
+    /**
+     * Convert Hex String to Color.
+     * @param s Must be of the form "#34a300" or "#3f2", otherwise throws Exception.
+     * Upper/lower case does not matter.
+     * @return The corresponding color.
+     */
+    static public Color hexToColor(String s) {
+        String clr = s.substring(1);
+        if (clr.length() == 3) {
+            clr = new String(new char[] {
+                clr.charAt(0), clr.charAt(0), clr.charAt(1), clr.charAt(1), clr.charAt(2), clr.charAt(2)
+            });
+        }
+        if (clr.length() != 6)
+            throw new IllegalArgumentException();
+        return new Color(Integer.parseInt(clr, 16));
+    }
+
 }
