Changeset 6655 in josm
- Timestamp:
- 2014-01-08T21:45:22+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ColorHelper.java
r6380 r6655 13 13 } 14 14 15 /** 16 * Returns the {@code Color} for the given HTML code. 17 * @param html the color code 18 * @return the color 19 */ 15 20 public static Color html2color(String html) { 16 21 if (html.length() > 0 && html.charAt(0) == '#') … … 34 39 } 35 40 41 /** 42 * Returns the HTML color code (6 or 8 digit). 43 * @param col The color to convert 44 * @return the HTML color code (6 or 8 digit) 45 */ 36 46 public static String color2html(Color col) { 47 return color2html(col, true); 48 } 49 50 /** 51 * Returns the HTML color code (6 or 8 digit). 52 * @param col The color to convert 53 * @param withAlpha if {@code true} and alpha value < 255, return 8-digit color code, else always 6-digit 54 * @return the HTML color code (6 or 8 digit) 55 * @since 6655 56 */ 57 public static String color2html(Color col, boolean withAlpha) { 37 58 if (col == null) 38 59 return null; 39 return "#"+int2hex(col.getRed())+int2hex(col.getGreen())+int2hex(col.getBlue()); 60 String code = "#"+int2hex(col.getRed())+int2hex(col.getGreen())+int2hex(col.getBlue()); 61 if (withAlpha) { 62 int alpha = col.getAlpha(); 63 if (alpha < 255) { 64 code += int2hex(alpha); 65 } 66 } 67 return code; 40 68 } 41 69 }
Note:
See TracChangeset
for help on using the changeset viewer.