Returns the 6-digit hex string such as "aa55ff" for opaque colors or or 8-digit like "80aa55ff" for other colors (the first two hex digits are alpha). 'color' must not be null.
(Color color)
| 231 | * or 8-digit like "80aa55ff" for other colors (the first two hex digits are alpha). |
| 232 | * 'color' must not be null. */ |
| 233 | private static String getHexString(Color color) { |
| 234 | int rgb = color.getRGB(); |
| 235 | boolean isOpaque = (rgb & 0xff000000) == 0xff000000; |
| 236 | if (isOpaque) |
| 237 | rgb &= 0x00ffffff; //don't show alpha for opaque colors |
| 238 | String format = isOpaque? "%06x" : "%08x"; |
| 239 | return String.format(format, rgb); |
| 240 | } |
| 241 | |
| 242 | /** Returns an opaque color with the specified red, green, and blue values. |
| 243 | * Values is outside the 0-255 range are replaced by the nearest |
no test coverage detected