- Timestamp:
- 2020-04-17T15:01:21+02:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r16308 r16319 25 25 import org.openstreetmap.josm.data.preferences.CachingProperty; 26 26 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 27 import org.openstreetmap.josm.gui.mappaint.mapcss.CSSColors; 27 28 import org.openstreetmap.josm.tools.ColorHelper; 28 29 import org.openstreetmap.josm.tools.I18n; … … 125 126 final String color = str.matches("#[0-9A-Fa-f]{3,8}") 126 127 ? str 127 : ColorHelper.color2html(ColorHelper.html2color(str)); 128 str = "<html><body><span color='" + color + "'>\u25A0</span> " + str + "</body></html>"; 128 : ColorHelper.color2html(CSSColors.get(str)); 129 if (color != null) { 130 str = "<html><body><span color='" + color + "'>\u25A0</span> " + str + "</body></html>"; 131 } 129 132 } 130 133 ((JLabel) c).putClientProperty("html.disable", enableHTML ? null : Boolean.TRUE); // Fix #8730 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java
r16315 r16319 15 15 import org.openstreetmap.josm.data.tagging.ac.AutoCompletionPriority; 16 16 import org.openstreetmap.josm.gui.MainApplication; 17 import org.openstreetmap.josm.gui.mappaint.mapcss.CSSColors; 17 18 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 18 19 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; … … 135 136 136 137 protected Color getColor() { 137 return ColorHelper.html2color(String.valueOf(getSelectedItem())); 138 String colorString = String.valueOf(getSelectedItem()); 139 return colorString.startsWith("#") 140 ? ColorHelper.html2color(colorString) 141 : CSSColors.get(colorString); 138 142 } 139 143 -
trunk/src/org/openstreetmap/josm/tools/ColorHelper.java
r16293 r16319 3 3 4 4 import java.awt.Color; 5 6 import org.openstreetmap.josm.gui.mappaint.mapcss.CSSColors;7 5 8 6 /** … … 16 14 17 15 /** 18 * Returns the {@code Color} for the given HTML code , also evaluates CSS color names using {@link CSSColors}.16 * Returns the {@code Color} for the given HTML code. 19 17 * @param html the color code 20 18 * @return the color … … 30 28 } 31 29 if (html.length() != 6 && html.length() != 8) 32 return CSSColors.get(html);30 return null; 33 31 try { 34 32 return new Color( … … 38 36 html.length() == 8 ? Integer.parseInt(html.substring(6, 8), 16) : 255); 39 37 } catch (NumberFormatException e) { 40 return CSSColors.get(html);38 return null; 41 39 } 42 40 } -
trunk/test/unit/org/openstreetmap/josm/tools/ColorHelperTest.java
r16293 r16319 26 26 assertEquals(Color.CYAN, ColorHelper.html2color("#00ffff")); 27 27 assertEquals(Color.CYAN, ColorHelper.html2color("#00FFFF")); 28 assertEquals(Color.CYAN, ColorHelper.html2color("cyan"));29 assertEquals(new Color(0xa52a2a), ColorHelper.html2color("brown"));30 assertEquals(new Color(0x6495ed), ColorHelper.html2color("cornflowerblue"));31 28 assertEquals(new Color(0x12345678, true), ColorHelper.html2color("#34567812")); 32 29 }
Note:
See TracChangeset
for help on using the changeset viewer.