Ignore:
Timestamp:
2014-01-19T20:30:57+01:00 (10 years ago)
Author:
simon04
Message:

fix #9191 - MapCSS: Add option to include colour preferences of external styles

The syntax is the same as for the XML styles: name#123456

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ColorHelper.java

    r6655 r6740  
    2121        if (html.length() > 0 && html.charAt(0) == '#')
    2222            html = html.substring(1);
     23        if (html.length() == 3) {
     24            return html2color(new String(
     25                    new char[]{html.charAt(0), html.charAt(0), html.charAt(1), html.charAt(1), html.charAt(2), html.charAt(2)}));
     26        }
    2327        if (html.length() != 6 && html.length() != 8)
    2428            return null;
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6717 r6740  
    630630
    631631    /**
    632      * Convert Hex String to Color.
    633      * @param s Must be of the form "#34a300" or "#3f2", otherwise throws Exception.
    634      * Upper/lower case does not matter.
    635      * @return The corresponding color.
    636      */
    637     static public Color hexToColor(String s) {
    638         String clr = s.substring(1);
    639         if (clr.length() == 3) {
    640             clr = new String(new char[] {
    641                 clr.charAt(0), clr.charAt(0), clr.charAt(1), clr.charAt(1), clr.charAt(2), clr.charAt(2)
    642             });
    643         }
    644         if (clr.length() != 6)
    645             throw new IllegalArgumentException();
    646         return new Color(Integer.parseInt(clr, 16));
    647     }
    648 
    649     /**
    650632     * Opens a HTTP connection to the given URL and sets the User-Agent property to JOSM's one.
    651633     * @param httpURL The HTTP url to open (must use http:// or https://)
Note: See TracChangeset for help on using the changeset viewer.