For named colors, returns the name, or 'defaultName' if not a named color. If 'defaultName' is non-null and starts with an uppercase character, the returned name is capitalized (first character uppercase). Use colorToString or colorToString2 to get a String representation (hexadecimal) also for
(Color c, String defaultName)
| 82 | * Use colorToString or colorToString2 to get a String representation (hexadecimal) |
| 83 | * also for unnamed colors.*/ |
| 84 | public static String getColorName(Color c, String defaultName) { |
| 85 | if (c==null) return defaultName; |
| 86 | boolean useCapitalizedName = defaultName!=null && defaultName.length()>0 && Character.isUpperCase(defaultName.charAt(0)); |
| 87 | return getColorName(c, defaultName, useCapitalizedName); |
| 88 | } |
| 89 | |
| 90 | /** For named colors, returns the name, or 'defaultName' if not a named color. |
| 91 | * 'color' must not be null. */ |
no test coverage detected