Changeset 4621 in josm
- Timestamp:
- 2011-11-29T21:25:55+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r4480 r4621 51 51 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 52 52 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; 53 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 53 54 import org.openstreetmap.josm.tools.AudioPlayer; 54 55 import org.openstreetmap.josm.tools.BugReportExceptionHandler; … … 842 843 Main.pref.removePreferenceChangeListener(this); 843 844 DataSet.removeSelectionListener(repaintSelectionChangedListener); 845 MapPaintStyles.getStyles().clearMultipolygonsCache(this); 844 846 } 845 847 -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r4606 r4621 6 6 import java.util.Collection; 7 7 import java.util.Collections; 8 import java.util.HashMap; 8 9 import java.util.Iterator; 9 10 import java.util.List; 11 import java.util.Map; 10 12 import java.util.Map.Entry; 11 13 … … 28 30 private boolean defaultNodes, defaultLines; 29 31 private int defaultNodesIdx, defaultLinesIdx; 32 33 private final Map<NavigatableComponent, Map<Relation, Multipolygon>> multipolygonsCache; 30 34 31 35 public ElemStyles() 32 36 { 33 37 styleSources = new ArrayList<StyleSource>(); 38 multipolygonsCache = new HashMap<NavigatableComponent, Map<Relation,Multipolygon>>(); 34 39 } 35 40 … … 116 121 } 117 122 123 private final Multipolygon getCachedMultipolygon(NavigatableComponent nc, Relation r) { 124 Multipolygon multipolygon = null; 125 Map<Relation, Multipolygon> map = multipolygonsCache.get(nc); 126 if (map == null) { 127 multipolygonsCache.put(nc, map = new HashMap<Relation, Multipolygon>()); 128 } 129 multipolygon = map.get(r); 130 if (multipolygon == null) { 131 map.put(r, multipolygon = new Multipolygon(nc)); 132 multipolygon.load(r); 133 } 134 return multipolygon; 135 } 136 118 137 /** 119 138 * Create the list of styles and its valid scale range for one primitive. … … 160 179 continue; 161 180 } 162 Multipolygon multipolygon = new Multipolygon(nc); 163 multipolygon.load(r); 181 Multipolygon multipolygon = getCachedMultipolygon(nc, r); 164 182 165 183 if (multipolygon.getOuterWays().contains(osm)) { … … 226 244 continue; 227 245 } 228 Multipolygon multipolygon = new Multipolygon(nc); 229 multipolygon.load(ref); 246 final Multipolygon multipolygon = getCachedMultipolygon(nc, ref); 230 247 231 248 if (multipolygon.getInnerWays().contains(osm)) { … … 413 430 } 414 431 432 public void clearMultipolygonsCache(NavigatableComponent nc) { 433 multipolygonsCache.remove(nc); 434 } 415 435 }
Note:
See TracChangeset
for help on using the changeset viewer.