Changeset 11779 in josm
- Timestamp:
- 2017-03-25T23:34:39+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r11761 r11779 441 441 */ 442 442 public void drawArea(Relation r, Color color, MapImage fillImage, Float extent, Float extentThreshold, boolean disabled, TextLabel text) { 443 Multipolygon multipolygon = MultipolygonCache.getInstance().get( nc,r);443 Multipolygon multipolygon = MultipolygonCache.getInstance().get(r); 444 444 if (!r.isDisabled() && !multipolygon.getOuterWays().isEmpty()) { 445 445 for (PolyData pd : multipolygon.getCombinedPolygons()) { … … 1129 1129 consumer.accept(getPath((Way) osm)); 1130 1130 } else if (osm instanceof Relation) { 1131 Multipolygon multipolygon = MultipolygonCache.getInstance().get( nc,(Relation) osm);1131 Multipolygon multipolygon = MultipolygonCache.getInstance().get((Relation) osm); 1132 1132 if (!multipolygon.getOuterWays().isEmpty()) { 1133 1133 for (PolyData pd : multipolygon.getCombinedPolygons()) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java
r11117 r11779 28 28 import org.openstreetmap.josm.data.projection.Projection; 29 29 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 30 import org.openstreetmap.josm.gui.NavigatableComponent;31 30 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 32 31 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; … … 43 42 private static final MultipolygonCache INSTANCE = new MultipolygonCache(); 44 43 45 private final Map< NavigatableComponent, Map<DataSet, Map<Relation, Multipolygon>>> cache;44 private final Map<DataSet, Map<Relation, Multipolygon>> cache; 46 45 47 46 private final Collection<PolyData> selectedPolyData; … … 65 64 /** 66 65 * Gets a multipolygon from cache. 67 * @param nc The navigatable component68 66 * @param r The multipolygon relation 69 67 * @return A multipolygon object for the given relation, or {@code null} 70 */ 71 public Multipolygon get(NavigatableComponent nc, Relation r) { 72 return get(nc, r, false); 68 * @since 11779 69 */ 70 public Multipolygon get(Relation r) { 71 return get(r, false); 73 72 } 74 73 75 74 /** 76 75 * Gets a multipolygon from cache. 77 * @param nc The navigatable component78 76 * @param r The multipolygon relation 79 77 * @param forceRefresh if {@code true}, a new object will be created even of present in cache 80 78 * @return A multipolygon object for the given relation, or {@code null} 81 */ 82 public Multipolygon get(NavigatableComponent nc, Relation r, boolean forceRefresh) { 79 * @since 11779 80 */ 81 public Multipolygon get(Relation r, boolean forceRefresh) { 83 82 Multipolygon multipolygon = null; 84 if (nc != null && r != null) { 85 Map<DataSet, Map<Relation, Multipolygon>> map1 = cache.get(nc); 86 if (map1 == null) { 87 map1 = new ConcurrentHashMap<>(); 88 cache.put(nc, map1); 89 } 90 Map<Relation, Multipolygon> map2 = map1.get(r.getDataSet()); 83 if (r != null) { 84 Map<Relation, Multipolygon> map2 = cache.get(r.getDataSet()); 91 85 if (map2 == null) { 92 86 map2 = new ConcurrentHashMap<>(); 93 map1.put(r.getDataSet(), map2);87 cache.put(r.getDataSet(), map2); 94 88 } 95 89 multipolygon = map2.get(r); … … 108 102 109 103 /** 110 * Clears the cache for the given navigatable component.111 * @param nc the navigatable component112 */113 public void clear(NavigatableComponent nc) {114 Map<DataSet, Map<Relation, Multipolygon>> map = cache.remove(nc);115 if (map != null) {116 map.clear();117 }118 }119 120 /**121 104 * Clears the cache for the given dataset. 122 105 * @param ds the data set 123 106 */ 124 107 public void clear(DataSet ds) { 125 for (Map<DataSet, Map<Relation, Multipolygon>> map1 : cache.values()) { 126 Map<Relation, Multipolygon> map2 = map1.remove(ds); 127 if (map2 != null) { 128 map2.clear(); 129 } 108 Map<Relation, Multipolygon> map2 = cache.remove(ds); 109 if (map2 != null) { 110 map2.clear(); 130 111 } 131 112 } … … 140 121 private Collection<Map<Relation, Multipolygon>> getMapsFor(DataSet ds) { 141 122 List<Map<Relation, Multipolygon>> result = new ArrayList<>(); 142 for (Map<DataSet, Map<Relation, Multipolygon>> map : cache.values()) { 143 Map<Relation, Multipolygon> map2 = map.get(ds); 144 if (map2 != null) { 145 result.add(map2); 146 } 123 Map<Relation, Multipolygon> map2 = cache.get(ds); 124 if (map2 != null) { 125 result.add(map2); 147 126 } 148 127 return result; -
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r11608 r11779 9 9 import java.util.List; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.Node; 13 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 29 28 public class PowerLines extends Test { 30 29 30 /** Test identifier */ 31 31 protected static final int POWER_LINES = 2501; 32 32 … … 106 106 nodesLists.add(((Way) station).getNodes()); 107 107 } else if (station instanceof Relation) { 108 Multipolygon polygon = MultipolygonCache.getInstance().get( Main.map.mapView,(Relation) station);108 Multipolygon polygon = MultipolygonCache.getInstance().get((Relation) station); 109 109 if (polygon != null) { 110 110 for (JoinedWay outer : Multipolygon.joinWays(polygon.getOuterWays())) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r11774 r11779 750 750 Main.pref.removePreferenceChangeListener(this); 751 751 DataSet.removeSelectionListener(repaintSelectionChangedListener); 752 MultipolygonCache.getInstance().clear( this);752 MultipolygonCache.getInstance().clear(); 753 753 if (mapMover != null) { 754 754 mapMover.destroy(); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r11730 r11779 88 88 } 89 89 90 /** 91 * Returns the list of style sources. 92 * @return the list of style sources 93 */ 90 94 public List<StyleSource> getStyleSources() { 91 95 return Collections.<StyleSource>unmodifiableList(styleSources); … … 218 222 continue; 219 223 } 220 Multipolygon multipolygon = MultipolygonCache.getInstance().get( nc,r);224 Multipolygon multipolygon = MultipolygonCache.getInstance().get(r); 221 225 222 226 if (multipolygon.getOuterWays().contains(osm)) { … … 286 290 continue; 287 291 } 288 final Multipolygon multipolygon = MultipolygonCache.getInstance().get( nc,ref);292 final Multipolygon multipolygon = MultipolygonCache.getInstance().get(ref); 289 293 290 294 if (multipolygon.getInnerWays().contains(osm)) { … … 320 324 && !Utils.exists(p.a, AreaElement.class) && Main.pref.getBoolean("multipolygon.deprecated.outerstyle", true)) { 321 325 // look at outer ways to find area style 322 Multipolygon multipolygon = MultipolygonCache.getInstance().get( nc,(Relation) osm);326 Multipolygon multipolygon = MultipolygonCache.getInstance().get((Relation) osm); 323 327 for (Way w : multipolygon.getOuterWays()) { 324 328 Pair<StyleElementList, Range> wayStyles = generateStyles(w, scale, false); -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java
r11562 r11779 16 16 import java.util.regex.PatternSyntaxException; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.actions.search.SearchCompiler.InDataSourceArea; 20 19 import org.openstreetmap.josm.data.osm.Node; … … 741 740 return e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && 742 741 !e.osm.isIncomplete() && !((Relation) e.osm).hasIncompleteMembers() && 743 !MultipolygonCache.getInstance().get( Main.map.mapView,(Relation) e.osm).getOpenEnds().isEmpty();742 !MultipolygonCache.getInstance().get((Relation) e.osm).getOpenEnds().isEmpty(); 744 743 } 745 744 … … 768 767 return true; 769 768 if (e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon()) 770 return MultipolygonCache.getInstance().get( Main.map.mapView,(Relation) e.osm).getOpenEnds().isEmpty();769 return MultipolygonCache.getInstance().get((Relation) e.osm).getOpenEnds().isEmpty(); 771 770 return false; 772 771 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r11370 r11779 245 245 public void visit(Relation r) { 246 246 if (left.matches(e.withPrimitive(r))) { 247 final List<Node> openEnds = MultipolygonCache.getInstance().get( Main.map.mapView,r).getOpenEnds();247 final List<Node> openEnds = MultipolygonCache.getInstance().get(r).getOpenEnds(); 248 248 final int openEndIndex = openEnds.indexOf(e.osm); 249 249 if (openEndIndex >= 0) { -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r11664 r11779 533 533 final Multipolygon mp = Main.map == null || Main.map.mapView == null 534 534 ? new Multipolygon(multipolygon) 535 : MultipolygonCache.getInstance().get( Main.map.mapView,multipolygon);535 : MultipolygonCache.getInstance().get(multipolygon); 536 536 Path2D path = new Path2D.Double(); 537 537 path.setWindingRule(Path2D.WIND_EVEN_ODD); … … 673 673 final Multipolygon mp = Main.map == null || Main.map.mapView == null 674 674 ? new Multipolygon(multipolygon) 675 : MultipolygonCache.getInstance().get( Main.map.mapView,multipolygon);675 : MultipolygonCache.getInstance().get(multipolygon); 676 676 for (Multipolygon.PolyData pd : mp.getCombinedPolygons()) { 677 677 area += pd.getAreaAndPerimeter(Projections.getProjectionByCode("EPSG:54008")).getArea();
Note:
See TracChangeset
for help on using the changeset viewer.