Changeset 6302 in osm for applications/editors
- Timestamp:
- 2008-01-09T19:05:45+01:00 (17 years ago)
- Location:
- applications/editors/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java
r5583 r6302 2 2 3 3 import java.awt.*; 4 import java.util. ArrayList;4 import java.util.Collections; 5 5 import java.util.List; 6 6 … … 21 21 private String message; 22 22 /** The affected primitives */ 23 private List<OsmPrimitive> primitives; 23 private List<? extends OsmPrimitive> primitives; 24 /** The primitives to be highlighted */ 25 private List<?> highlighted; 24 26 /** The tester that raised this error */ 25 27 private Test tester; 26 28 /** Internal code used by testers to classify errors */ 27 private int internalCode ;29 private int internalCode = -1; 28 30 /** If this error is selected */ 29 31 private boolean selected; 30 32 31 /** 32 * Constructor 33 */ 34 public TestError() 35 { 33 public TestError(Test tester, Severity severity, String message, 34 List<? extends OsmPrimitive> primitives, List<?> highlighted) { 35 this.tester = tester; 36 this.severity = severity; 37 this.message = message; 38 this.primitives = primitives; 39 this.highlighted = highlighted; 36 40 } 37 41 … … 43 47 * @param primitives The affected primitives 44 48 */ 45 public TestError(Test tester, Severity severity, String message, List<OsmPrimitive> primitives) 46 { 47 this.tester = tester; 48 this.severity = severity; 49 this.message = message; 50 this.primitives = primitives; 49 public TestError(Test tester, Severity severity, String message, List<? extends OsmPrimitive> primitives) 50 { 51 this(tester, severity, message, primitives, primitives); 51 52 } 52 53 … … 60 61 public TestError(Test tester, Severity severity, String message, OsmPrimitive primitive) 61 62 { 62 this.tester = tester; 63 this.severity = severity; 64 this.message = message; 65 66 List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 67 primitives.add(primitive); 68 69 this.primitives = primitives; 63 this(tester, severity, message, Collections.singletonList(primitive)); 70 64 } 71 65 … … 106 100 * @return the list of primitives affected by this error 107 101 */ 108 public List< OsmPrimitive> getPrimitives()102 public List<? extends OsmPrimitive> getPrimitives() 109 103 { 110 104 return primitives; … … 199 193 { 200 194 PaintVisitor v = new PaintVisitor(g, mv); 201 for( OsmPrimitive p : primitives) 202 { 203 if( !p.deleted || !p.incomplete ) 204 p.visit(v); 195 for (Object o : highlighted) { 196 if (o instanceof OsmPrimitive) { 197 v.visit((OsmPrimitive) o); 198 } else if (o instanceof WaySegment) { 199 v.visit((WaySegment) o); 200 } 205 201 } 206 202 } … … 227 223 this.mv = mv; 228 224 } 225 226 public void visit(OsmPrimitive p) { 227 if (!p.deleted && !p.incomplete) { 228 p.visit(this); 229 } 230 } 229 231 230 232 /** … … 278 280 } 279 281 280 281 282 282 283 /** … … 308 309 } 309 310 311 public void visit(WaySegment ws) { 312 if (ws.lowerIndex < 0 || ws.lowerIndex >= ws.way.nodes.size()) return; 313 Node a = ws.way.nodes.get(ws.lowerIndex), 314 b = ws.way.nodes.get(ws.lowerIndex + 1); 315 if (isSegmentVisible(a, b)) { 316 drawSegment(a, b, severity.getColor()); 317 } 318 } 319 310 320 public void visit(Relation r) 311 321 { -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java
r5583 r6302 87 87 if( isCoastline1 != isCoastline2 ) continue; 88 88 89 List<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 90 primitives.add(es1.ws.way); 91 primitives.add(es2.ws.way); 92 errors.add( new TestError(this, Severity.WARNING, tr("Crossing ways"), primitives) ); 89 errors.add(new TestError(this, Severity.WARNING, tr("Crossing ways"), 90 Arrays.asList(es1.ws.way, es2.ws.way), 91 Arrays.asList(es1.ws, es2.ws))); 93 92 } 94 93 segments.add(es1); -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java
r5583 r6302 68 68 public Command fixError(TestError testError) 69 69 { 70 Collection< OsmPrimitive> sel = testError.getPrimitives();70 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 71 71 Collection<OsmPrimitive> nodes = new ArrayList<OsmPrimitive>(); 72 72 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicatedWayNodes.java
r6301 r6302 11 11 import org.openstreetmap.josm.command.ChangeCommand; 12 12 import java.util.Collections; 13 import java.util.Arrays; 13 14 14 15 public class DuplicatedWayNodes extends Test { … … 28 29 } 29 30 if (lastN == n) { 30 errors.add(new TestError(this, Severity.ERROR, tr("Duplicated way nodes"), w)); 31 errors.add(new TestError(this, Severity.ERROR, tr("Duplicated way nodes"), 32 Arrays.asList(w), Arrays.asList(n))); 31 33 break; 32 34 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/OverlappingWays.java
r5194 r6302 4 4 5 5 import java.util.List; 6 import java.util.ArrayList; 6 7 7 8 import org.openstreetmap.josm.data.coor.LatLon; 8 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 10 import org.openstreetmap.josm.data.osm.Way; 11 import org.openstreetmap.josm.data.osm.WaySegment; 10 12 import org.openstreetmap.josm.data.osm.Node; 11 13 import org.openstreetmap.josm.tools.Pair; … … 23 25 { 24 26 /** Bag of all way segments */ 25 Bag<Pair<Node,Node>, OsmPrimitive> nodePairs;27 Bag<Pair<Node,Node>, WaySegment> nodePairs; 26 28 27 29 /** … … 40 42 public void startTest() 41 43 { 42 nodePairs = new Bag<Pair<Node,Node>, OsmPrimitive>(1000);44 nodePairs = new Bag<Pair<Node,Node>, WaySegment>(1000); 43 45 } 44 46 … … 46 48 public void endTest() 47 49 { 48 for (List< OsmPrimitive> duplicated : nodePairs.values())50 for (List<WaySegment> duplicated : nodePairs.values()) 49 51 { 50 52 if (duplicated.size() > 1) 51 53 { 52 errors.add( new TestError(this, Severity.OTHER, tr("Overlapping ways"), duplicated) ); 54 List<OsmPrimitive> prims = new ArrayList<OsmPrimitive>(); 55 for (WaySegment ws : duplicated) prims.add(ws.way); 56 errors.add(new TestError(this, Severity.OTHER, 57 tr("Overlapping ways"), prims, duplicated)); 53 58 } 54 59 } … … 60 65 { 61 66 Node lastN = null; 67 int i = -2; 62 68 for (Node n : w.nodes) { 69 i++; 63 70 if (lastN == null) { 64 71 lastN = n; 65 72 continue; 66 73 } 67 if (n.hashCode() > lastN.hashCode()) { 68 nodePairs.add(new Pair<Node,Node>(lastN, n), w); 69 } else { 70 nodePairs.add(new Pair<Node,Node>(n, lastN), w); 71 } 74 nodePairs.add(Pair.sort(new Pair<Node,Node>(lastN, n)), 75 new WaySegment(w, i)); 72 76 lastN = n; 73 77 } -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SelfIntersectingWay.java
r5283 r6302 4 4 5 5 import java.util.HashSet; 6 import java.util.Arrays; 6 7 7 8 import org.openstreetmap.josm.data.osm.Way; … … 28 29 if (nodes.contains(n)) { 29 30 errors.add(new TestError(this, 30 Severity.WARNING, tr("Self-intersecting ways"), w, 0)); 31 Severity.WARNING, tr("Self-intersecting ways"), 32 Arrays.asList(w), Arrays.asList(n))); 31 33 break; 32 34 } else { -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java
r6301 r6302 492 492 493 493 int i = -1; 494 List< OsmPrimitive> primitives = testError.getPrimitives();494 List<? extends OsmPrimitive> primitives = testError.getPrimitives(); 495 495 for(OsmPrimitive p : primitives ) 496 496 { … … 505 505 String value = prop.getValue(); 506 506 if( value == null || value.trim().length() == 0 ) 507 commands.add( new ChangePropertyCommand( primitives.subList(i, i+1), key, null) );507 commands.add( new ChangePropertyCommand(Collections.singleton(primitives.get(i)), key, null) ); 508 508 else 509 509 { 510 510 String replacementKey = spellCheckKeyData.get(key); 511 511 if( replacementKey != null ) 512 commands.add( new ChangePropertyKeyCommand( primitives.subList(i, i+1), key, replacementKey) );512 commands.add( new ChangePropertyKeyCommand(Collections.singleton(primitives.get(i)), key, replacementKey) ); 513 513 } 514 514 }
Note:
See TracChangeset
for help on using the changeset viewer.