Changeset 13810 in josm
- Timestamp:
- 2018-05-21T20:42:27+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java
r13673 r13810 10 10 11 11 import org.openstreetmap.josm.data.osm.BBox; 12 import org.openstreetmap.josm.data.osm.DataSet;13 12 import org.openstreetmap.josm.data.osm.INode; 14 import org.openstreetmap.josm.data.osm. Node;15 import org.openstreetmap.josm.data.osm. Way;13 import org.openstreetmap.josm.data.osm.IWay; 14 import org.openstreetmap.josm.data.osm.OsmData; 16 15 import org.openstreetmap.josm.data.osm.WaySegment; 17 16 import org.openstreetmap.josm.gui.MapViewState; … … 127 126 * @param data The data set being rendered. 128 127 * @param bbox The bounding box being displayed. 129 */ 130 public void drawVirtualNodes(DataSet data, BBox bbox) { 128 * @since 13810 (signature) 129 */ 130 public void drawVirtualNodes(OsmData<?, ?, ?, ?> data, BBox bbox) { 131 131 if (virtualNodeSize == 0 || data == null || bbox == null || data.isLocked()) 132 132 return; 133 133 // print normal virtual nodes 134 134 GeneralPath path = new GeneralPath(); 135 for ( Wayosm : data.searchWays(bbox)) {135 for (IWay<?> osm : data.searchWays(bbox)) { 136 136 if (osm.isUsable() && !osm.isDisabledAndHidden() && !osm.isDisabled()) { 137 137 visitVirtual(path, osm); … … 222 222 * @param w The ways to draw node for. 223 223 * @since 10827 224 */ 225 public void visitVirtual(Path2D path, Way w) { 226 Iterator<Node> it = w.getNodes().iterator(); 224 * @since 13810 (signature) 225 */ 226 public void visitVirtual(Path2D path, IWay<?> w) { 227 Iterator<? extends INode> it = w.getNodes().iterator(); 227 228 MapViewPoint lastP = null; 228 229 while (it.hasNext()) { 229 Node n = it.next(); 230 INode n = it.next(); 230 231 if (n.isLatLonKnown()) { 231 232 MapViewPoint p = mapState.getPointFor(n); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java
r12964 r13810 8 8 import java.util.concurrent.RecursiveTask; 9 9 10 import org.openstreetmap.josm.data.osm.Node; 11 import org.openstreetmap.josm.data.osm. OsmPrimitive;12 import org.openstreetmap.josm.data.osm.Relation; 13 import org.openstreetmap.josm.data.osm.Way; 14 import org.openstreetmap.josm.data.osm.visitor. OsmPrimitiveVisitor;10 import org.openstreetmap.josm.data.osm.INode; 11 import org.openstreetmap.josm.data.osm.IPrimitive; 12 import org.openstreetmap.josm.data.osm.IRelation; 13 import org.openstreetmap.josm.data.osm.IWay; 14 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 15 15 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord; 16 16 import org.openstreetmap.josm.gui.NavigatableComponent; … … 32 32 * @since 11914 (extracted from StyledMapRenderer) 33 33 */ 34 public class ComputeStyleListWorker extends RecursiveTask<List<StyleRecord>> implements OsmPrimitiveVisitor {35 private final transient List<? extends OsmPrimitive> input;34 public class ComputeStyleListWorker extends RecursiveTask<List<StyleRecord>> implements PrimitiveVisitor { 35 private final transient List<? extends IPrimitive> input; 36 36 private final transient List<StyleRecord> output; 37 37 … … 52 52 * @param output the list of styles to which styles will be added 53 53 * @param directExecutionTaskSize the threshold deciding whether to subdivide the tasks 54 * @since 13810 (signature) 54 55 */ 55 56 ComputeStyleListWorker(double circum, NavigatableComponent nc, 56 final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize) {57 final List<? extends IPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize) { 57 58 this(circum, nc, input, output, directExecutionTaskSize, MapPaintStyles.getStyles()); 58 59 } … … 67 68 * @param styles the {@link ElemStyles} instance used to generate primitive {@link StyleElement}s. 68 69 * @since 12964 70 * @since 13810 (signature) 69 71 */ 70 72 ComputeStyleListWorker(double circum, NavigatableComponent nc, 71 final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize,73 final List<? extends IPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize, 72 74 ElemStyles styles) { 73 75 this.circum = circum; … … 108 110 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 109 111 try { 110 for (final OsmPrimitive osm : input) {112 for (final IPrimitive osm : input) { 111 113 acceptDrawable(osm); 112 114 } … … 119 121 } 120 122 121 private void acceptDrawable(final OsmPrimitive osm) {123 private void acceptDrawable(final IPrimitive osm) { 122 124 try { 123 125 if (osm.isDrawable()) { … … 130 132 131 133 @Override 132 public void visit(Node n) { 134 public void visit(INode n) { 133 135 add(n, StyledMapRenderer.computeFlags(n, false)); 134 136 } 135 137 136 138 @Override 137 public void visit( Wayw) {139 public void visit(IWay<?> w) { 138 140 add(w, StyledMapRenderer.computeFlags(w, true)); 139 141 } 140 142 141 143 @Override 142 public void visit( Relationr) {144 public void visit(IRelation<?> r) { 143 145 add(r, StyledMapRenderer.computeFlags(r, true)); 144 146 } … … 148 150 * @param osm node 149 151 * @param flags flags 152 * @since 13810 (signature) 150 153 */ 151 public void add(Node osm, int flags) { 154 public void add(INode osm, int flags) { 152 155 StyleElementList sl = styles.get(osm, circum, nc); 153 156 for (StyleElement s : sl) { … … 160 163 * @param osm way 161 164 * @param flags flags 165 * @since 13810 (signature) 162 166 */ 163 public void add( Wayosm, int flags) {167 public void add(IWay<?> osm, int flags) { 164 168 StyleElementList sl = styles.get(osm, circum, nc); 165 169 for (StyleElement s : sl) { … … 174 178 * @param osm relation 175 179 * @param flags flags 180 * @since 13810 (signature) 176 181 */ 177 public void add( Relationosm, int flags) {182 public void add(IRelation<?> osm, int flags) { 178 183 StyleElementList sl = styles.get(osm, circum, nc); 179 184 for (StyleElement s : sl) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/Rendering.java
r10600 r13810 3 3 4 4 import org.openstreetmap.josm.data.Bounds; 5 import org.openstreetmap.josm.data.osm. DataSet;5 import org.openstreetmap.josm.data.osm.OsmData; 6 6 7 7 /** 8 * <p>An object which can render data provided by a {@link DataSet}.</p>8 * <p>An object which can render data provided by a {@link OsmData}.</p> 9 9 * @since 4087 (creation) 10 10 * @since 10600 (functional interface) … … 19 19 * @param bbox the bounding box for the data to be rendered. Only objects within or intersecting 20 20 * with {@code bbox} are rendered 21 * @since 13810 (signature) 21 22 */ 22 void render( DataSetdata, boolean renderVirtualNodes, Bounds bbox);23 void render(OsmData<?, ?, ?, ?> data, boolean renderVirtualNodes, Bounds bbox); 23 24 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r13676 r13810 46 46 import org.openstreetmap.josm.data.coor.EastNorth; 47 47 import org.openstreetmap.josm.data.osm.BBox; 48 import org.openstreetmap.josm.data.osm.DataSet;49 48 import org.openstreetmap.josm.data.osm.INode; 50 49 import org.openstreetmap.josm.data.osm.IPrimitive; 50 import org.openstreetmap.josm.data.osm.IRelation; 51 import org.openstreetmap.josm.data.osm.IWay; 51 52 import org.openstreetmap.josm.data.osm.Node; 53 import org.openstreetmap.josm.data.osm.OsmData; 52 54 import org.openstreetmap.josm.data.osm.OsmPrimitive; 53 55 import org.openstreetmap.josm.data.osm.OsmUtils; … … 113 115 public static class StyleRecord implements Comparable<StyleRecord> { 114 116 private final StyleElement style; 115 private final OsmPrimitive osm;117 private final IPrimitive osm; 116 118 private final int flags; 117 119 private final long order; 118 120 119 StyleRecord(StyleElement style, OsmPrimitive osm, int flags) {121 StyleRecord(StyleElement style, IPrimitive osm, int flags) { 120 122 this.style = style; 121 123 this.osm = osm; … … 1587 1589 1588 1590 @Override 1589 public void render(final DataSetdata, boolean renderVirtualNodes, Bounds bounds) {1591 public void render(final OsmData<?, ?, ?, ?> data, boolean renderVirtualNodes, Bounds bounds) { 1590 1592 RenderBenchmarkCollector benchmark = benchmarkFactory.get(); 1591 1593 BBox bbox = bounds.toBBox(); … … 1607 1609 } 1608 1610 1609 private void paintWithLock(final DataSetdata, boolean renderVirtualNodes, RenderBenchmarkCollector benchmark,1611 private void paintWithLock(final OsmData<?, ?, ?, ?> data, boolean renderVirtualNodes, RenderBenchmarkCollector benchmark, 1610 1612 BBox bbox) { 1611 1613 try { … … 1614 1616 benchmark.renderStart(circum); 1615 1617 1616 List<Node> nodes = data.searchNodes(bbox); 1617 List< Way> ways = data.searchWays(bbox);1618 List< Relation> relations = data.searchRelations(bbox);1618 List<? extends INode> nodes = data.searchNodes(bbox); 1619 List<? extends IWay<?>> ways = data.searchWays(bbox); 1620 List<? extends IRelation<?>> relations = data.searchRelations(bbox); 1619 1621 1620 1622 final List<StyleRecord> allStyleElems = new ArrayList<>(nodes.size()+ways.size()+relations.size()); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
r13673 r13810 18 18 import org.openstreetmap.josm.data.Bounds; 19 19 import org.openstreetmap.josm.data.osm.BBox; 20 import org.openstreetmap.josm.data.osm.DataSet;21 20 import org.openstreetmap.josm.data.osm.INode; 22 import org.openstreetmap.josm.data.osm. Node;23 import org.openstreetmap.josm.data.osm. OsmPrimitive;24 import org.openstreetmap.josm.data.osm. Relation;25 import org.openstreetmap.josm.data.osm. RelationMember;26 import org.openstreetmap.josm.data.osm. Way;21 import org.openstreetmap.josm.data.osm.IPrimitive; 22 import org.openstreetmap.josm.data.osm.IRelation; 23 import org.openstreetmap.josm.data.osm.IRelationMember; 24 import org.openstreetmap.josm.data.osm.IWay; 25 import org.openstreetmap.josm.data.osm.OsmData; 27 26 import org.openstreetmap.josm.data.osm.WaySegment; 28 import org.openstreetmap.josm.data.osm.visitor. OsmPrimitiveVisitor;27 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 29 28 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; 30 29 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; … … 39 38 * @since 23 40 39 */ 41 public class WireframeMapRenderer extends AbstractMapRenderer implements OsmPrimitiveVisitor {40 public class WireframeMapRenderer extends AbstractMapRenderer implements PrimitiveVisitor { 42 41 43 42 /** Color Preference for ways not matching any other group */ … … 84 83 /** Path store to draw subsequent segments of same color as one <code>Path</code>. */ 85 84 protected MapPath2D currentPath = new MapPath2D(); 86 /**87 * <code>DataSet</code> passed to the @{link render} function to overcome the argument88 * limitations of @{link Visitor} interface. Only valid until end of rendering call.89 */90 private DataSet ds;91 85 92 86 /** Helper variable for {@link #drawSegment} */ 93 87 private static final ArrowPaintHelper ARROW_PAINT_HELPER = new ArrowPaintHelper(Utils.toRadians(20), 10); 94 88 95 /** Helper variable for {@link #visit(Relation)} */ 89 /** Helper variable for {@link #visit(IRelation)} */ 96 90 private final Stroke relatedWayStroke = new BasicStroke( 97 91 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); … … 153 147 154 148 @Override 155 public void render( DataSetdata, boolean virtual, Bounds bounds) {149 public void render(OsmData<?, ?, ?, ?> data, boolean virtual, Bounds bounds) { 156 150 BBox bbox = bounds.toBBox(); 157 this.ds = data;158 151 Rectangle clip = g.getClipBounds(); 159 152 clip.grow(50, 50); … … 161 154 getSettings(virtual); 162 155 163 for (final Relationrel : data.searchRelations(bbox)) {164 if (rel.isDrawable() && ! ds.isSelected(rel) && !rel.isDisabledAndHidden()) {156 for (final IRelation<?> rel : data.searchRelations(bbox)) { 157 if (rel.isDrawable() && !rel.isSelected() && !rel.isDisabledAndHidden()) { 165 158 rel.accept(this); 166 159 } … … 168 161 169 162 // draw tagged ways first, then untagged ways, then highlighted ways 170 List< Way> highlightedWays = new ArrayList<>();171 List< Way> untaggedWays = new ArrayList<>();172 173 for (final Wayway : data.searchWays(bbox)) {174 if (way.isDrawable() && ! ds.isSelected(way) && !way.isDisabledAndHidden()) {163 List<IWay<?>> highlightedWays = new ArrayList<>(); 164 List<IWay<?>> untaggedWays = new ArrayList<>(); 165 166 for (final IWay<?> way : data.searchWays(bbox)) { 167 if (way.isDrawable() && !way.isSelected() && !way.isDisabledAndHidden()) { 175 168 if (way.isHighlighted()) { 176 169 highlightedWays.add(way); … … 185 178 186 179 // Display highlighted ways after the other ones (fix #8276) 187 List< Way> specialWays = new ArrayList<>(untaggedWays);180 List<IWay<?>> specialWays = new ArrayList<>(untaggedWays); 188 181 specialWays.addAll(highlightedWays); 189 for (final Wayway : specialWays) {182 for (final IWay<?> way : specialWays) { 190 183 way.accept(this); 191 184 } … … 193 186 displaySegments(); 194 187 195 for (final OsmPrimitive osm : data.getSelected()) {188 for (final IPrimitive osm : data.getSelected()) { 196 189 if (osm.isDrawable()) { 197 190 osm.accept(this); … … 200 193 displaySegments(); 201 194 202 for (final OsmPrimitive osm: data.searchNodes(bbox)) {203 if (osm.isDrawable() && ! ds.isSelected(osm) && !osm.isDisabledAndHidden()) {195 for (final INode osm: data.searchNodes(bbox)) { 196 if (osm.isDrawable() && !osm.isSelected() && !osm.isDisabledAndHidden()) { 204 197 osm.accept(this); 205 198 } … … 237 230 */ 238 231 @Override 239 public void visit(Node n) { 232 public void visit(INode n) { 240 233 if (n.isIncomplete()) return; 241 234 … … 265 258 } 266 259 267 final int size = max( ds.isSelected(n) ? selectedNodeSize : 0,260 final int size = max(n.isSelected() ? selectedNodeSize : 0, 268 261 isNodeTagged(n) ? taggedNodeSize : 0, 269 262 n.isConnectionNode() ? connectionNodeSize : 0, 270 263 unselectedNodeSize); 271 264 272 final boolean fill = ( ds.isSelected(n) && fillSelectedNode) ||265 final boolean fill = (n.isSelected() && fillSelectedNode) || 273 266 (isNodeTagged(n) && fillTaggedNode) || 274 267 (n.isConnectionNode() && fillConnectionNode) || … … 279 272 } 280 273 281 private static boolean isNodeTagged(Node n) { 274 private static boolean isNodeTagged(INode n) { 282 275 return n.isTagged() || n.isAnnotated(); 283 276 } … … 288 281 */ 289 282 @Override 290 public void visit( Wayw) {283 public void visit(IWay<?> w) { 291 284 if (w.isIncomplete() || w.getNodesCount() < 2) 292 285 return; … … 295 288 (even if the tag is negated as in oneway=false) or the way is selected */ 296 289 297 boolean showThisDirectionArrow = ds.isSelected(w) || showDirectionArrow;290 boolean showThisDirectionArrow = w.isSelected() || showDirectionArrow; 298 291 /* head only takes over control if the option is true, 299 292 the direction should be shown at all and not only because it's selected */ 300 boolean showOnlyHeadArrowOnly = showThisDirectionArrow && showHeadArrowOnly && ! ds.isSelected(w);293 boolean showOnlyHeadArrowOnly = showThisDirectionArrow && showHeadArrowOnly && !w.isSelected(); 301 294 Color wayColor; 302 295 … … 315 308 } 316 309 317 Iterator<Node> it = w.getNodes().iterator(); 310 Iterator<? extends INode> it = w.getNodes().iterator(); 318 311 if (it.hasNext()) { 319 312 MapViewPoint lastP = mapState.getPointFor(it.next()); … … 340 333 */ 341 334 @Override 342 public void visit( Relationr) {335 public void visit(IRelation<?> r) { 343 336 if (r.isIncomplete()) return; 344 337 … … 355 348 g.setColor(col); 356 349 357 for (RelationMember m : r.getMembers()) { 350 for (IRelationMember<?> m : r.getMembers()) { 358 351 if (m.getMember().isIncomplete() || !m.getMember().isDrawable()) { 359 352 continue; … … 361 354 362 355 if (m.isNode()) { 363 MapViewPoint p = mapState.getPointFor( m.getNode());356 MapViewPoint p = mapState.getPointFor((INode) m.getMember()); 364 357 if (p.isInView()) { 365 358 g.draw(new Ellipse2D.Double(p.getInViewX()-4, p.getInViewY()-4, 9, 9)); … … 370 363 371 364 boolean first = true; 372 for (Node n : m.getWay().getNodes()) {365 for (INode n : ((IWay<?>) m.getMember()).getNodes()) { 373 366 if (!n.isDrawable()) { 374 367 continue; -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r13633 r13810 582 582 final String description2 = group == null ? null : description; 583 583 final List<OsmPrimitive> primitives; 584 if (env.child != null) {585 primitives = Arrays.asList(p, env.child); 584 if (env.child instanceof OsmPrimitive) { 585 primitives = Arrays.asList(p, (OsmPrimitive) env.child); 586 586 } else { 587 587 primitives = Collections.singletonList(p); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r13636 r13810 12 12 import java.util.Optional; 13 13 14 import org.openstreetmap.josm.data.osm.IPrimitive; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 import org.openstreetmap.josm.data.osm.OsmPrimitive;16 16 import org.openstreetmap.josm.data.osm.Relation; 17 17 import org.openstreetmap.josm.data.osm.Way; … … 45 45 * There are several steps to derive the list of elements for display: 46 46 * <ol> 47 * <li>{@link #generateStyles( OsmPrimitive, double, boolean)} applies the47 * <li>{@link #generateStyles(IPrimitive, double, boolean)} applies the 48 48 * {@link StyleSource}s one after another to get a key-value map of MapCSS 49 49 * properties. Then a preliminary set of StyleElements is derived from the 50 50 * properties map.</li> 51 * <li>{@link #getImpl( OsmPrimitive, double, NavigatableComponent)} handles the51 * <li>{@link #getImpl(IPrimitive, double, NavigatableComponent)} handles the 52 52 * different forms of multipolygon tagging.</li> 53 * <li>{@link #getStyleCacheWithRange( OsmPrimitive, double, NavigatableComponent)}53 * <li>{@link #getStyleCacheWithRange(IPrimitive, double, NavigatableComponent)} 54 54 * adds a default StyleElement for primitives that would be invisible otherwise. 55 55 * (For example untagged nodes and ways.)</li> … … 131 131 * @param nc display component 132 132 * @return list of styles 133 */ 134 public StyleElementList get(OsmPrimitive osm, double scale, NavigatableComponent nc) { 133 * @since 13810 (signature) 134 */ 135 public StyleElementList get(IPrimitive osm, double scale, NavigatableComponent nc) { 135 136 return getStyleCacheWithRange(osm, scale, nc).a; 136 137 } … … 145 146 * @param nc navigatable component 146 147 * @return pair containing style list and range 147 */ 148 public Pair<StyleElementList, Range> getStyleCacheWithRange(OsmPrimitive osm, double scale, NavigatableComponent nc) { 148 * @since 13810 (signature) 149 */ 150 public Pair<StyleElementList, Range> getStyleCacheWithRange(IPrimitive osm, double scale, NavigatableComponent nc) { 149 151 if (!osm.isCachedStyleUpToDate() || scale <= 0) { 150 152 osm.setCachedStyle(StyleCache.EMPTY_STYLECACHE); … … 232 234 * @return pair containing style list and range 233 235 */ 234 private Pair<StyleElementList, Range> getImpl( OsmPrimitive osm, double scale, NavigatableComponent nc) {236 private Pair<StyleElementList, Range> getImpl(IPrimitive osm, double scale, NavigatableComponent nc) { 235 237 if (osm instanceof Node) 236 238 return generateStyles(osm, scale, false); … … 242 244 243 245 // FIXME: Maybe in the future outer way styles apply to outers ignoring the multipolygon? 244 for ( OsmPrimitive referrer : osm.getReferrers()) {246 for (IPrimitive referrer : osm.getReferrers()) { 245 247 Relation r = (Relation) referrer; 246 248 if (!drawMultipolygon || !r.isMultipolygon() || !r.isUsable()) { … … 310 312 if (!isDefaultLines()) return p; 311 313 312 for ( OsmPrimitive referrer : osm.getReferrers()) {314 for (IPrimitive referrer : osm.getReferrers()) { 313 315 Relation ref = (Relation) referrer; 314 316 if (!drawMultipolygon || !ref.isMultipolygon() || !ref.isUsable()) { … … 362 364 * outer ways of a multipolygon. 363 365 * @return the generated styles and the valid range as a pair 364 */ 365 public Pair<StyleElementList, Range> generateStyles(OsmPrimitive osm, double scale, boolean pretendWayIsClosed) { 366 * @since 13810 (signature) 367 */ 368 public Pair<StyleElementList, Range> generateStyles(IPrimitive osm, double scale, boolean pretendWayIsClosed) { 366 369 367 370 List<StyleElement> sl = new ArrayList<>(); … … 522 525 * outer ways of a multipolygon. 523 526 * @return first AreaElement found or {@code null}. 524 */ 525 public static AreaElement getAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) { 527 * @since 13810 (signature) 528 */ 529 public static AreaElement getAreaElemStyle(IPrimitive p, boolean pretendWayIsClosed) { 526 530 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 527 531 try { … … 545 549 * outer ways of a multipolygon. 546 550 * @return {@code true} if primitive has an AreaElement 547 */ 548 public static boolean hasAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) { 551 * @since 13810 (signature) 552 */ 553 public static boolean hasAreaElemStyle(IPrimitive p, boolean pretendWayIsClosed) { 549 554 return getAreaElemStyle(p, pretendWayIsClosed) != null; 550 555 } … … 558 563 * @return {@code true} if primitive has area elements, but no line elements 559 564 * @since 12700 560 */ 561 public static boolean hasOnlyAreaElements(OsmPrimitive p) { 565 * @since 13810 (signature) 566 */ 567 public static boolean hasOnlyAreaElements(IPrimitive p) { 562 568 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 563 569 try { -
trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java
r12378 r13810 2 2 package org.openstreetmap.josm.gui.mappaint; 3 3 4 import org.openstreetmap.josm.data.osm. OsmPrimitive;4 import org.openstreetmap.josm.data.osm.IPrimitive; 5 5 import org.openstreetmap.josm.data.osm.Relation; 6 6 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context; … … 18 18 * The primitive that is currently evaluated 19 19 */ 20 public OsmPrimitive osm;20 public IPrimitive osm; 21 21 22 22 /** … … 43 43 * is evaluated in a {@link LinkSelector} (within a child selector) 44 44 */ 45 public OsmPrimitive parent;45 public IPrimitive parent; 46 46 47 47 /** 48 48 * The same for parent selector. Only one of the 2 fields (parent or child) is not null in any environment. 49 49 */ 50 public OsmPrimitive child;50 public IPrimitive child; 51 51 52 52 /** … … 71 71 * @param osm OSM primitive 72 72 * @since 8415 73 */ 74 public Environment(OsmPrimitive osm) { 73 * @since 13810 (signature) 74 */ 75 public Environment(IPrimitive osm) { 75 76 this.osm = osm; 76 77 } … … 82 83 * @param layer layer 83 84 * @param source style source 84 */ 85 public Environment(OsmPrimitive osm, MultiCascade mc, String layer, StyleSource source) { 85 * @since 13810 (signature) 86 */ 87 public Environment(IPrimitive osm, MultiCascade mc, String layer, StyleSource source) { 86 88 this.osm = osm; 87 89 this.mc = mc; … … 114 116 * @return A clone of this environment, with the specified primitive 115 117 * @see #osm 116 */ 117 public Environment withPrimitive(OsmPrimitive osm) { 118 * @since 13810 (signature) 119 */ 120 public Environment withPrimitive(IPrimitive osm) { 118 121 Environment e = new Environment(this); 119 122 e.osm = osm; … … 126 129 * @return A clone of this environment, with the specified parent 127 130 * @see #parent 128 */ 129 public Environment withParent(OsmPrimitive parent) { 131 * @since 13810 (signature) 132 */ 133 public Environment withParent(IPrimitive parent) { 130 134 Environment e = new Environment(this); 131 135 e.parent = parent; … … 142 146 * @see #index 143 147 * @since 6175 144 */ 145 public Environment withParentAndIndexAndLinkContext(OsmPrimitive parent, int index, int count) { 148 * @since 13810 (signature) 149 */ 150 public Environment withParentAndIndexAndLinkContext(IPrimitive parent, int index, int count) { 146 151 Environment e = new Environment(this); 147 152 e.parent = parent; … … 157 162 * @return A clone of this environment, with the specified child 158 163 * @see #child 159 */ 160 public Environment withChild(OsmPrimitive child) { 164 * @since 13810 (signature) 165 */ 166 public Environment withChild(IPrimitive child) { 161 167 Environment e = new Environment(this); 162 168 e.child = child; … … 173 179 * @see #index 174 180 * @since 6175 175 */ 176 public Environment withChildAndIndexAndLinkContext(OsmPrimitive child, int index, int count) { 181 * @since 13810 (signature) 182 */ 183 public Environment withChildAndIndexAndLinkContext(IPrimitive child, int index, int count) { 177 184 Environment e = new Environment(this); 178 185 e.child = child; -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java
r13647 r13810 20 20 import javax.swing.ImageIcon; 21 21 22 import org.openstreetmap.josm.data.osm. OsmPrimitive;22 import org.openstreetmap.josm.data.osm.IPrimitive; 23 23 import org.openstreetmap.josm.data.preferences.sources.SourceEntry; 24 24 import org.openstreetmap.josm.data.preferences.sources.SourceType; … … 94 94 * we pretend it is. This is useful for generating area styles from the (segmented) 95 95 * outer ways of a multipolygon. 96 */ 97 public abstract void apply(MultiCascade mc, OsmPrimitive osm, double scale, boolean pretendWayIsClosed); 96 * @since 13810 (signature) 97 */ 98 public abstract void apply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed); 98 99 99 100 /** -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java
r13046 r13810 15 15 import java.util.regex.PatternSyntaxException; 16 16 17 import org.openstreetmap.josm.data.osm.IPrimitive; 17 18 import org.openstreetmap.josm.data.osm.Node; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 681 682 * @param e MapCSS environment 682 683 * @return {@code true} if the object has an area style 683 * @see ElemStyles#hasAreaElemStyle( OsmPrimitive, boolean)684 * @see ElemStyles#hasAreaElemStyle(IPrimitive, boolean) 684 685 */ 685 686 static boolean areaStyle(Environment e) { // NO_UCD (unused code) … … 749 750 */ 750 751 static boolean inDownloadedArea(Environment e) { // NO_UCD (unused code) 751 return IN_DOWNLOADED_AREA.test(e.osm); 752 return e.osm instanceof OsmPrimitive && IN_DOWNLOADED_AREA.test((OsmPrimitive) e.osm); 752 753 } 753 754 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r13640 r13810 460 460 if (env.osm != null) { 461 461 // we don't have a matched parent, so just search all referrers 462 for ( OsmPrimitive parent : env.osm.getReferrers()) {462 for (IPrimitive parent : env.osm.getReferrers()) { 463 463 String value = parent.get(key); 464 464 if (value != null) { … … 485 485 final Collection<String> tags = new TreeSet<>(AlphanumComparator.getInstance()); 486 486 // we don't have a matched parent, so just search all referrers 487 for ( OsmPrimitive parent : env.osm.getReferrers()) {487 for (IPrimitive parent : env.osm.getReferrers()) { 488 488 String value = parent.get(key); 489 489 if (value != null) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r13800 r13810 30 30 31 31 import org.openstreetmap.josm.data.Version; 32 import org.openstreetmap.josm.data.osm.IPrimitive; 32 33 import org.openstreetmap.josm.data.osm.KeyValueVisitor; 33 34 import org.openstreetmap.josm.data.osm.Node; … … 357 358 * @param osm the primitive to match 358 359 * @return An iterator over possible rules in the right order. 359 */ 360 public Iterator<MapCSSRule> getRuleCandidates(OsmPrimitive osm) { 360 * @since 13810 (signature) 361 */ 362 public Iterator<MapCSSRule> getRuleCandidates(IPrimitive osm) { 361 363 final BitSet ruleCandidates = new BitSet(rules.size()); 362 364 ruleCandidates.or(remaining); … … 638 640 639 641 @Override 640 public void apply(MultiCascade mc, OsmPrimitive osm, double scale, boolean pretendWayIsClosed) {642 public void apply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed) { 641 643 MapCSSRuleIndex matchingRuleIndex; 642 644 if (osm instanceof Node) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r12986 r13810 14 14 import java.util.regex.PatternSyntaxException; 15 15 16 import org.openstreetmap.josm.data.osm.INode; 17 import org.openstreetmap.josm.data.osm.IPrimitive; 18 import org.openstreetmap.josm.data.osm.IRelation; 19 import org.openstreetmap.josm.data.osm.IRelationMember; 20 import org.openstreetmap.josm.data.osm.IWay; 16 21 import org.openstreetmap.josm.data.osm.Node; 17 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 19 24 import org.openstreetmap.josm.data.osm.OsmUtils; 20 25 import org.openstreetmap.josm.data.osm.Relation; 21 import org.openstreetmap.josm.data.osm.RelationMember;22 26 import org.openstreetmap.josm.data.osm.Way; 23 import org.openstreetmap.josm.data.osm.visitor. OsmPrimitiveVisitor;27 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 24 28 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 25 29 import org.openstreetmap.josm.gui.mappaint.Environment; … … 145 149 * 146 150 */ 147 private class MatchingReferrerFinder implements OsmPrimitiveVisitor {151 private class MatchingReferrerFinder implements PrimitiveVisitor { 148 152 private final Environment e; 149 153 … … 157 161 158 162 @Override 159 public void visit(Node n) { 163 public void visit(INode n) { 160 164 // node should never be a referrer 161 165 throw new AssertionError(); 162 166 } 163 167 164 private <T extends OsmPrimitive> void doVisit(T parent, IntSupplier counter, IntFunction<OsmPrimitive> getter) {168 private <T extends IPrimitive> void doVisit(T parent, IntSupplier counter, IntFunction<IPrimitive> getter) { 165 169 // If e.parent is already set to the first matching referrer. 166 170 // We skip any following referrer injected into the visitor. … … 187 191 188 192 @Override 189 public void visit( Wayw) {193 public void visit(IWay<?> w) { 190 194 doVisit(w, w::getNodesCount, w::getNode); 191 195 } 192 196 193 197 @Override 194 public void visit( Relationr) {198 public void visit(IRelation<?> r) { 195 199 doVisit(r, r::getMembersCount, i -> r.getMember(i).getMember()); 196 200 } 197 201 } 198 202 199 private abstract static class AbstractFinder implements OsmPrimitiveVisitor {203 private abstract static class AbstractFinder implements PrimitiveVisitor { 200 204 protected final Environment e; 201 205 … … 205 209 206 210 @Override 207 public void visit(Node n) { 208 } 209 210 @Override 211 public void visit( Wayw) {212 } 213 214 @Override 215 public void visit( Relationr) {216 } 217 218 public void visit(Collection<? extends OsmPrimitive> primitives) {219 for ( OsmPrimitive p : primitives) {211 public void visit(INode n) { 212 } 213 214 @Override 215 public void visit(IWay<?> w) { 216 } 217 218 @Override 219 public void visit(IRelation<?> r) { 220 } 221 222 public void visit(Collection<? extends IPrimitive> primitives) { 223 for (IPrimitive p : primitives) { 220 224 if (e.child != null) { 221 225 // abort if first match has been found … … 227 231 } 228 232 229 public boolean isPrimitiveUsable( OsmPrimitive p) {233 public boolean isPrimitiveUsable(IPrimitive p) { 230 234 return !e.osm.equals(p) && p.isUsable(); 231 235 } … … 235 239 236 240 @Override 237 public void visit( Wayw) {241 public void visit(IWay<?> w) { 238 242 w.visitReferrers(innerVisitor); 239 243 } … … 243 247 } 244 248 245 private final OsmPrimitiveVisitor innerVisitor = new AbstractFinder(e) {249 private final PrimitiveVisitor innerVisitor = new AbstractFinder(e) { 246 250 @Override 247 public void visit( Relationr) {248 if (left.matches(e.withPrimitive(r))) { 249 final List<Node> openEnds = MultipolygonCache.getInstance().get(r).getOpenEnds(); 251 public void visit(IRelation<?> r) { 252 if (r instanceof Relation && left.matches(e.withPrimitive(r))) { 253 final List<Node> openEnds = MultipolygonCache.getInstance().get((Relation) r).getOpenEnds(); 250 254 final int openEndIndex = openEnds.indexOf(e.osm); 251 255 if (openEndIndex >= 0) { … … 265 269 private CrossingFinder(Environment e) { 266 270 super(e); 267 CheckParameterUtil.ensureThat(e.osm instanceof Way, "Only ways are supported"); 271 CheckParameterUtil.ensureThat(e.osm instanceof IWay, "Only ways are supported"); 268 272 layer = OsmUtils.getLayer(e.osm); 269 273 } 270 274 271 275 @Override 272 public void visit( Wayw) {276 public void visit(IWay<?> w) { 273 277 if (e.child == null && Objects.equals(layer, OsmUtils.getLayer(w)) 274 278 && left.matches(new Environment(w).withParent(e.osm)) 275 && e.osm instanceof Way && Geometry.PolygonIntersection.CROSSING.equals( 279 && e.osm instanceof IWay && Geometry.PolygonIntersection.CROSSING.equals( 276 280 Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) { 277 281 e.child = w; … … 283 287 protected ContainsFinder(Environment e) { 284 288 super(e); 285 CheckParameterUtil.ensureThat(!(e.osm instanceof Node), "Nodes not supported"); 286 } 287 288 @Override 289 public void visit(Node n) { 289 CheckParameterUtil.ensureThat(!(e.osm instanceof INode), "Nodes not supported"); 290 } 291 292 @Override 293 public void visit(INode n) { 290 294 if (e.child == null && left.matches(new Environment(n).withParent(e.osm)) 291 && ((e.osm instanceof Way && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes())) 295 && ((e.osm instanceof IWay && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes())) 292 296 || (e.osm instanceof Relation && ( 293 297 (Relation) e.osm).isMultipolygon() && Geometry.isNodeInsideMultiPolygon(n, (Relation) e.osm, null)))) { … … 297 301 298 302 @Override 299 public void visit( Wayw) {303 public void visit(IWay<?> w) { 300 304 if (e.child == null && left.matches(new Environment(w).withParent(e.osm)) 301 && ((e.osm instanceof Way && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals( 305 && ((e.osm instanceof IWay && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals( 302 306 Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) 303 307 || (e.osm instanceof Relation && ( … … 317 321 if (ChildOrParentSelectorType.ELEMENT_OF.equals(type)) { 318 322 319 if (e.osm instanceof Node || e.osm.getDataSet() == null) { 323 if (e.osm instanceof INode || e.osm.getDataSet() == null) { 320 324 // nodes cannot contain elements 321 325 return false; … … 326 330 // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon, 327 331 // use the multipolygon for further analysis 328 if (!(e.osm instanceof Way) 332 if (!(e.osm instanceof IWay) 329 333 || (right instanceof OptimizedGeneralSelector 330 334 && !((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION))) { … … 338 342 containsFinder = new ContainsFinder(new Environment(multipolygon)) { 339 343 @Override 340 public boolean isPrimitiveUsable( OsmPrimitive p) {344 public boolean isPrimitiveUsable(IPrimitive p) { 341 345 return super.isPrimitiveUsable(p) && !members.contains(p); 342 346 } … … 362 366 return e.child != null; 363 367 364 } else if (ChildOrParentSelectorType.CROSSING.equals(type) && e.osm instanceof Way) { 368 } else if (ChildOrParentSelectorType.CROSSING.equals(type) && e.osm instanceof IWay) { 365 369 e.parent = e.osm; 366 370 final CrossingFinder crossingFinder = new CrossingFinder(e); … … 371 375 return e.child != null; 372 376 } else if (ChildOrParentSelectorType.SIBLING.equals(type)) { 373 if (e.osm instanceof Node) { 374 for (Way w : Utils.filteredCollection(e.osm.getReferrers(true), Way.class)) { 375 final int i = w.getNodes().indexOf(e.osm); 376 if (i - 1 >= 0) { 377 final Node n = w.getNode(i - 1); 378 final Environment e2 = e.withPrimitive(n).withParent(w).withChild(e.osm); 379 if (left.matches(e2) && link.matches(e2.withLinkContext())) { 380 e.child = n; 381 e.index = i; 382 e.count = w.getNodesCount(); 383 e.parent = w; 384 return true; 377 if (e.osm instanceof INode) { 378 for (IPrimitive ref : e.osm.getReferrers(true)) { 379 if (ref instanceof IWay) { 380 IWay<?> w = (IWay<?>) ref; 381 final int i = w.getNodes().indexOf(e.osm); 382 if (i - 1 >= 0) { 383 final INode n = w.getNode(i - 1); 384 final Environment e2 = e.withPrimitive(n).withParent(w).withChild(e.osm); 385 if (left.matches(e2) && link.matches(e2.withLinkContext())) { 386 e.child = n; 387 e.index = i; 388 e.count = w.getNodesCount(); 389 e.parent = w; 390 return true; 391 } 385 392 } 386 393 } … … 390 397 && link.conds != null && !link.conds.isEmpty() 391 398 && link.conds.get(0) instanceof OpenEndPseudoClassCondition) { 392 if (e.osm instanceof Node) { 399 if (e.osm instanceof INode) { 393 400 e.osm.visitReferrers(new MultipolygonOpenEndFinder(e)); 394 401 return e.parent != null; … … 400 407 return true; 401 408 } else if (ChildOrParentSelectorType.PARENT.equals(type)) { 402 if (e.osm instanceof Way) { 403 List<Node> wayNodes = (( Way) e.osm).getNodes();409 if (e.osm instanceof IWay) { 410 List<? extends INode> wayNodes = ((IWay<?>) e.osm).getNodes(); 404 411 for (int i = 0; i < wayNodes.size(); i++) { 405 Node n = wayNodes.get(i); 412 INode n = wayNodes.get(i); 406 413 if (left.matches(e.withPrimitive(n)) 407 414 && link.matches(e.withChildAndIndexAndLinkContext(n, i, wayNodes.size()))) { … … 412 419 } 413 420 } 414 } else if (e.osm instanceof Relation) { 415 List<RelationMember> members = (( Relation) e.osm).getMembers();421 } else if (e.osm instanceof IRelation) { 422 List<? extends IRelationMember<?>> members = ((IRelation<?>) e.osm).getMembers(); 416 423 for (int i = 0; i < members.size(); i++) { 417 OsmPrimitive member = members.get(i).getMember();424 IPrimitive member = members.get(i).getMember(); 418 425 if (left.matches(e.withPrimitive(member)) 419 426 && link.matches(e.withChildAndIndexAndLinkContext(member, i, members.size()))) { … … 624 631 } 625 632 626 public boolean matchesBase( OsmPrimitive p) {633 public boolean matchesBase(IPrimitive p) { 627 634 if (!matchesBase(p.getType())) { 628 635 return false; 629 636 } else { 630 if (p instanceof Relation) { 637 if (p instanceof IRelation) { 631 638 if ("area".equals(base)) { 632 return (( Relation) p).isMultipolygon();639 return ((IRelation<?>) p).isMultipolygon(); 633 640 } else if ("canvas".equals(base)) { 634 641 return p.get("#canvas") != null;
Note:
See TracChangeset
for help on using the changeset viewer.