Changeset 12966 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
- Timestamp:
- 2017-10-09T17:14:50+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r12881 r12966 10 10 import java.util.Map; 11 11 import java.util.Map.Entry; 12 import java.util.Optional; 12 13 13 14 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; … … 17 18 import org.openstreetmap.josm.data.osm.Relation; 18 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 19 21 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 20 22 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; … … 69 71 private final Map<String, String> preferenceCache = new HashMap<>(); 70 72 73 private static volatile Color backgroundColorCache; 74 71 75 /** 72 76 * Constructs a new {@code ElemStyles}. … … 75 79 styleSources = new ArrayList<>(); 76 80 Config.getPref().addPreferenceChangeListener(this); 81 MapPaintStyles.addMapPaintSylesUpdateListener(new MapPaintStyles.MapPaintSylesUpdateListener() { 82 //TODO: Listen to wireframe map mode changes. 83 @Override 84 public void mapPaintStylesUpdated() { 85 backgroundColorCache = null; 86 } 87 88 @Override 89 public void mapPaintStyleEntryUpdated(int idx) { 90 mapPaintStylesUpdated(); 91 } 92 }); 77 93 } 78 94 … … 94 110 public List<StyleSource> getStyleSources() { 95 111 return Collections.<StyleSource>unmodifiableList(styleSources); 112 } 113 114 public Color getBackgroundColor() { 115 if (backgroundColorCache != null) 116 return backgroundColorCache; 117 for (StyleSource s : styleSources) { 118 if (!s.active) { 119 continue; 120 } 121 Color backgroundColorOverride = s.getBackgroundColorOverride(); 122 if (backgroundColorOverride != null) { 123 backgroundColorCache = backgroundColorOverride; 124 } 125 } 126 return Optional.ofNullable(backgroundColorCache).orElseGet(PaintColors.BACKGROUND::get); 96 127 } 97 128
Note:
See TracChangeset
for help on using the changeset viewer.