Ignore:
Timestamp:
2012-11-12T21:38:11+01:00 (13 years ago)
Author:
bastiK
Message:

fixed #8187 - eval(#colour) doesn't result in #colour value suitable for color

File:
1 edited

Legend:

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

    r5221 r5577  
    546546        };
    547547    }
     548
     549    /**
     550     * Convert Hex String to Color.
     551     * @param s Must be of the form "#34a300" or "#3f2", otherwise throws Exception.
     552     * Upper/lower case does not matter.
     553     * @return The corresponding color.
     554     */
     555    static public Color hexToColor(String s) {
     556        String clr = s.substring(1);
     557        if (clr.length() == 3) {
     558            clr = new String(new char[] {
     559                clr.charAt(0), clr.charAt(0), clr.charAt(1), clr.charAt(1), clr.charAt(2), clr.charAt(2)
     560            });
     561        }
     562        if (clr.length() != 6)
     563            throw new IllegalArgumentException();
     564        return new Color(Integer.parseInt(clr, 16));
     565    }
     566
    548567}
Note: See TracChangeset for help on using the changeset viewer.