Changeset 6740 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-01-19T20:30:57+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ColorHelper.java
r6655 r6740 21 21 if (html.length() > 0 && html.charAt(0) == '#') 22 22 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 } 23 27 if (html.length() != 6 && html.length() != 8) 24 28 return null; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6717 r6740 630 630 631 631 /** 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 /**650 632 * Opens a HTTP connection to the given URL and sets the User-Agent property to JOSM's one. 651 633 * @param httpURL The HTTP url to open (must use http:// or https://)
Note: See TracChangeset
for help on using the changeset viewer.