Changeset 5577 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2012-11-12T21:38:11+01:00 (13 years ago)
- File:
-
- 1 edited
-
trunk/src/org/openstreetmap/josm/tools/Utils.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r5221 r5577 546 546 }; 547 547 } 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 548 567 }
Note:
See TracChangeset
for help on using the changeset viewer.
