- Timestamp:
- 2020-06-10T08:04:42+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r15719 r16590 21 21 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 22 22 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 23 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 23 24 import org.openstreetmap.josm.gui.MainApplication; 24 25 import org.openstreetmap.josm.gui.NavigatableComponent; … … 40 41 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; 41 42 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; 43 import org.openstreetmap.josm.tools.ColorHelper; 42 44 import org.openstreetmap.josm.tools.Pair; 43 45 … … 604 606 * each primitive can be slow during rendering. 605 607 * 608 * If the default value can be {@linkplain Cascade#convertTo converted} to a {@link Color}, 609 * the {@link NamedColorProperty} is retrieved as string. 610 * 611 * @param source style source 606 612 * @param key preference key 607 613 * @param def default value … … 609 615 * @see org.openstreetmap.josm.data.Preferences#get(String, String) 610 616 */ 611 public String getPreferenceCached(St ring key, String def) {617 public String getPreferenceCached(StyleSource source, String key, String def) { 612 618 String res; 613 619 if (preferenceCache.containsKey(key)) { 614 620 res = preferenceCache.get(key); 615 621 } else { 616 res = Config.getPref().get(key, null); 622 Color realDef = Cascade.convertTo(def, Color.class); 623 if (realDef != null) { 624 String prefName = source != null ? source.getFileNamePart() : "unknown"; 625 NamedColorProperty property = new NamedColorProperty(NamedColorProperty.COLOR_CATEGORY_MAPPAINT, prefName, key, realDef); 626 res = ColorHelper.color2html(property.get()); 627 } else { 628 res = Config.getPref().get(key, null); 629 } 617 630 preferenceCache.put(key, res); 618 631 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
r16553 r16590 28 28 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; 29 29 import org.openstreetmap.josm.data.osm.search.SearchParseError; 30 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 30 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.mappaint.Cascade; … … 768 769 * Obtains the JOSM'key {@link org.openstreetmap.josm.data.Preferences} string for key {@code key}, 769 770 * and defaults to {@code def} if that is null. 771 * 772 * If the default value can be {@linkplain Cascade#convertTo converted} to a {@link Color}, 773 * the {@link NamedColorProperty} is retrieved as string. 774 * 770 775 * @param env the environment 771 776 * @param key Key in JOSM preference … … 774 779 */ 775 780 public static String JOSM_pref(Environment env, String key, String def) { // NO_UCD (unused code) 776 return MapPaintStyles.getStyles().getPreferenceCached( key, def);781 return MapPaintStyles.getStyles().getPreferenceCached(env != null ? env.source : null, key, def); 777 782 } 778 783
Note:
See TracChangeset
for help on using the changeset viewer.