Changeset 6613 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
- Timestamp:
- 2014-01-03T17:47:52+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r6611 r6613 39 39 40 40 public static enum ChildOrParentSelectorType { 41 CHILD, PARENT, ELEMENT_OF 41 CHILD, PARENT, ELEMENT_OF, CROSSING 42 42 } 43 43 … … 150 150 } 151 151 152 private class ContainsFinder extends AbstractVisitor {153 pr ivatefinal Environment e;154 155 pr ivate ContainsFinder(Environment e) {152 private abstract class AbstractFinder extends AbstractVisitor { 153 protected final Environment e; 154 155 protected AbstractFinder(Environment e) { 156 156 this.e = e; 157 CheckParameterUtil.ensureThat(!(e.osm instanceof Node), "Nodes not supported");158 157 } 159 158 160 159 @Override 161 160 public void visit(Node n) { 162 if (e.child == null && left.matches(e.withPrimitive(n))) {163 if (e.osm instanceof Way && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes())164 || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isNodeInsideMultiPolygon(n, (Relation) e.osm, null)) {165 e.child = n;166 }167 }168 161 } 169 162 170 163 @Override 171 164 public void visit(Way w) { 172 if (e.child == null && left.matches(e.withPrimitive(w))) {173 if (e.osm instanceof Way && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals(Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))174 || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isPolygonInsideMultiPolygon(w.getNodes(), (Relation) e.osm, null)) {175 e.child = w;176 }177 }178 165 } 179 166 … … 194 181 } 195 182 183 private class CrossingFinder extends AbstractFinder { 184 private CrossingFinder(Environment e) { 185 super(e); 186 CheckParameterUtil.ensureThat(e.osm instanceof Way, "Only ways are supported"); 187 } 188 189 @Override 190 public void visit(Way w) { 191 if (e.child == null && left.matches(e.withPrimitive(w))) { 192 if (e.osm instanceof Way && Geometry.PolygonIntersection.CROSSING.equals(Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes()))) { 193 e.child = w; 194 } 195 } 196 } 197 } 198 199 private class ContainsFinder extends AbstractFinder { 200 private ContainsFinder(Environment e) { 201 super(e); 202 CheckParameterUtil.ensureThat(!(e.osm instanceof Node), "Nodes not supported"); 203 } 204 205 @Override 206 public void visit(Node n) { 207 if (e.child == null && left.matches(e.withPrimitive(n))) { 208 if (e.osm instanceof Way && Geometry.nodeInsidePolygon(n, ((Way) e.osm).getNodes()) 209 || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isNodeInsideMultiPolygon(n, (Relation) e.osm, null)) { 210 e.child = n; 211 } 212 } 213 } 214 215 @Override 216 public void visit(Way w) { 217 if (e.child == null && left.matches(e.withPrimitive(w))) { 218 if (e.osm instanceof Way && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals(Geometry.polygonIntersection(w.getNodes(), ((Way) e.osm).getNodes())) 219 || e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() && Geometry.isPolygonInsideMultiPolygon(w.getNodes(), (Relation) e.osm, null)) { 220 e.child = w; 221 } 222 } 223 } 224 } 225 196 226 @Override 197 227 public boolean matches(Environment e) { … … 223 253 return e.child != null; 224 254 255 } else if (ChildOrParentSelectorType.CROSSING.equals(type) && e.osm instanceof Way) { 256 final CrossingFinder crossingFinder = new CrossingFinder(e); 257 if (((GeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) { 258 crossingFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox())); 259 } 260 return e.child != null; 225 261 } else if (ChildOrParentSelectorType.CHILD.equals(type)) { 226 262 MatchingReferrerFinder collector = new MatchingReferrerFinder(e);
Note:
See TracChangeset
for help on using the changeset viewer.