- Timestamp:
- 2011-12-01T00:53:26+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r4388 r4623 38 38 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 39 39 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData; 40 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 40 41 import org.openstreetmap.josm.gui.NavigatableComponent; 41 42 import org.openstreetmap.josm.gui.mappaint.BoxTextElemStyle; … … 860 861 861 862 public void drawArea(Relation r, Color color, BufferedImage fillImage, float fillImageAlpha, TextElement text) { 862 Multipolygon multipolygon = new Multipolygon(nc); 863 multipolygon.load(r); 863 Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, r); 864 864 if(!r.isDisabled() && !multipolygon.getOuterWays().isEmpty()) { 865 865 for (PolyData pd : multipolygon.getCombinedPolygons()) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r4191 r4623 134 134 */ 135 135 private static MultipolygonRoleMatcher roleMatcher; 136 private static MultipolygonRoleMatcher getMultipol oygonRoleMatcher() {136 private static MultipolygonRoleMatcher getMultipolygonRoleMatcher() { 137 137 if (roleMatcher == null) { 138 138 roleMatcher = new MultipolygonRoleMatcher(); … … 237 237 } 238 238 239 private final NavigatableComponent nc;240 241 239 private final List<Way> innerWays = new ArrayList<Way>(); 242 240 private final List<Way> outerWays = new ArrayList<Way>(); … … 245 243 private final List<PolyData> combinedPolygons = new ArrayList<PolyData>(); 246 244 247 public Multipolygon(NavigatableComponent nc ) {248 this.nc = nc;249 } 250 251 p ublic void load(Relation r) {252 MultipolygonRoleMatcher matcher = getMultipol oygonRoleMatcher();245 public Multipolygon(NavigatableComponent nc, Relation r) { 246 load(r, nc); 247 } 248 249 private void load(Relation r, NavigatableComponent nc) { 250 MultipolygonRoleMatcher matcher = getMultipolygonRoleMatcher(); 253 251 254 252 // Fill inner and outer list with valid ways … … 273 271 } 274 272 275 createPolygons( innerWays, innerPolygons);276 createPolygons( outerWays, outerPolygons);273 createPolygons(nc, innerWays, innerPolygons); 274 createPolygons(nc, outerWays, outerPolygons); 277 275 if (!outerPolygons.isEmpty()) { 278 276 addInnerToOuters(); … … 280 278 } 281 279 282 private void createPolygons( List<Way> ways, List<PolyData> result) {280 private void createPolygons(NavigatableComponent nc, List<Way> ways, List<PolyData> result) { 283 281 List<Way> waysToJoin = new ArrayList<Way>(); 284 282 for (Way way: ways) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r4447 r4623 134 134 checkMembersAndRoles(r); 135 135 136 Multipolygon polygon = new Multipolygon(Main.map.mapView); 137 polygon.load(r); 136 Multipolygon polygon = new Multipolygon(Main.map.mapView, r); 138 137 139 138 boolean hasOuterWay = false; -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r4621 r4623 45 45 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 46 46 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 47 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 47 48 import org.openstreetmap.josm.gui.layer.GpxLayer; 48 49 import org.openstreetmap.josm.gui.layer.Layer; … … 51 52 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 52 53 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; 53 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;54 54 import org.openstreetmap.josm.tools.AudioPlayer; 55 55 import org.openstreetmap.josm.tools.BugReportExceptionHandler; … … 238 238 } 239 239 }); 240 241 // Add Multipolygon cache to layer and zoom listeners 242 addLayerChangeListener(MultipolygonCache.getInstance()); 243 addZoomChangeListener(MultipolygonCache.getInstance()); 240 244 } 241 245 … … 843 847 Main.pref.removePreferenceChangeListener(this); 844 848 DataSet.removeSelectionListener(repaintSelectionChangedListener); 845 M apPaintStyles.getStyles().clearMultipolygonsCache(this);849 MultipolygonCache.getInstance().clear(this); 846 850 } 847 851 -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r4534 r4623 63 63 import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory; 64 64 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 65 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 65 66 import org.openstreetmap.josm.data.projection.Projection; 66 67 import org.openstreetmap.josm.data.validation.TestError; … … 207 208 conflicts = new ConflictCollection(); 208 209 data.addDataSetListener(new DataSetListenerAdapter(this)); 210 data.addDataSetListener(MultipolygonCache.getInstance()); 209 211 DataSet.addSelectionListener(this); 210 212 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r4621 r4623 6 6 import java.util.Collection; 7 7 import java.util.Collections; 8 import java.util.HashMap;9 8 import java.util.Iterator; 10 9 import java.util.List; 11 import java.util.Map;12 10 import java.util.Map.Entry; 13 11 … … 17 15 import org.openstreetmap.josm.data.osm.Way; 18 16 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 17 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 19 18 import org.openstreetmap.josm.gui.NavigatableComponent; 20 19 import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList; … … 31 30 private int defaultNodesIdx, defaultLinesIdx; 32 31 33 private final Map<NavigatableComponent, Map<Relation, Multipolygon>> multipolygonsCache;34 35 32 public ElemStyles() 36 33 { 37 34 styleSources = new ArrayList<StyleSource>(); 38 multipolygonsCache = new HashMap<NavigatableComponent, Map<Relation,Multipolygon>>();39 35 } 40 36 … … 121 117 } 122 118 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 137 119 /** 138 120 * Create the list of styles and its valid scale range for one primitive. … … 179 161 continue; 180 162 } 181 Multipolygon multipolygon = getCachedMultipolygon(nc, r);163 Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, r); 182 164 183 165 if (multipolygon.getOuterWays().contains(osm)) { … … 244 226 continue; 245 227 } 246 final Multipolygon multipolygon = getCachedMultipolygon(nc, ref);228 final Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, ref); 247 229 248 230 if (multipolygon.getInnerWays().contains(osm)) { … … 277 259 if (!Utils.exists(p.a, AreaElemStyle.class)) { 278 260 // look at outer ways to find area style 279 Multipolygon multipolygon = new Multipolygon(nc); 280 multipolygon.load((Relation) osm); 261 Multipolygon multipolygon = MultipolygonCache.getInstance().get(nc, (Relation) osm); 281 262 for (Way w : multipolygon.getOuterWays()) { 282 263 Pair<StyleList, Range> wayStyles = generateStyles(w, scale, null, false); … … 429 410 styleSources.addAll(sources); 430 411 } 431 432 public void clearMultipolygonsCache(NavigatableComponent nc) {433 multipolygonsCache.remove(nc);434 }435 412 }
Note:
See TracChangeset
for help on using the changeset viewer.