- Timestamp:
- 2020-08-03T22:32:16+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/preferences/NamedColorProperty.java
r15496 r16843 17 17 * @since 12987 18 18 */ 19 public class NamedColorProperty extends Abstract Property<Color> {19 public class NamedColorProperty extends AbstractToStringProperty<Color> { 20 20 21 21 public static final String NAMED_COLOR_PREFIX = "clr."; … … 62 62 private List<String> getDefaultValuePref() { 63 63 return defaultValue == null ? null : getValuePref(defaultValue, category, source, name); 64 } 65 66 @Override 67 protected void storeDefaultValue() { 68 // This is required due to the super() initializer calling this method. 69 if (category != null) { 70 super.storeDefaultValue(); 71 } 64 72 } 65 73 … … 137 145 return getChildColor(category, source, name); 138 146 } 147 148 @Override 149 protected Color fromString(String string) { 150 return ColorHelper.html2color(string); 151 } 152 153 @Override 154 protected String toString(Color color) { 155 return ColorHelper.color2html(color); 156 } 139 157 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSetting.java
r15731 r16843 2 2 package org.openstreetmap.josm.gui.mappaint; 3 3 4 import java.awt.Color; 4 5 import java.util.Objects; 5 6 import java.util.Optional; … … 176 177 } 177 178 } 179 180 /** 181 * A style setting for color values. 182 * @since 16842 183 */ 184 class ColorStyleSetting extends PropertyStyleSetting<Color> { 185 ColorStyleSetting(StyleSource parentStyle, String label, AbstractToStringProperty<Color> property) { 186 super(parentStyle, label, Color.class, property); 187 } 188 189 @Override 190 public StyleSettingGui getStyleSettingGui() { 191 return new ColorStyleSettingGui(this); 192 } 193 } 178 194 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSettingFactory.java
r15731 r16843 2 2 package org.openstreetmap.josm.gui.mappaint; 3 3 4 import java.awt.Color; 4 5 import java.util.function.BiFunction; 5 6 6 7 import org.openstreetmap.josm.data.preferences.BooleanProperty; 7 8 import org.openstreetmap.josm.data.preferences.DoubleProperty; 9 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 8 10 import org.openstreetmap.josm.data.preferences.StringProperty; 9 11 import org.openstreetmap.josm.tools.Logging; … … 46 48 return new StyleSetting.PropertyStyleSetting<>(parentStyle, label, String.class, property); 47 49 }); 50 case "color": 51 return forLabelAndDefault(c, Color.class, (label, defaultValue) -> { 52 final NamedColorProperty property = new NamedColorProperty(NamedColorProperty.COLOR_CATEGORY_MAPPAINT, 53 parentStyle.getFileNamePart(), label, defaultValue); 54 return new StyleSetting.ColorStyleSetting(parentStyle, label, property); 55 }); 48 56 default: 49 57 Logging.warn("Unknown setting type {0} for style {1}", type, parentStyle.url);
Note:
See TracChangeset
for help on using the changeset viewer.