Ticket #8517: sortValidatorDialog.patch
File sortValidatorDialog.patch, 10.3 KB (added by , 10 years ago) |
---|
-
src/org/openstreetmap/josm/data/osm/WaySegment.java
4 4 /** 5 5 * A segment consisting of 2 consecutive nodes out of a way. 6 6 */ 7 public final class WaySegment {7 public final class WaySegment implements Comparable<WaySegment> { 8 8 /** 9 9 * The way. 10 10 */ … … 49 49 @Override public int hashCode() { 50 50 return way.hashCode() ^ lowerIndex; 51 51 } 52 53 @Override 54 public int compareTo(WaySegment o) { 55 return this.toWay().compareTo(o.toWay()); 56 } 52 57 } -
src/org/openstreetmap/josm/data/validation/TestError.java
13 13 import org.openstreetmap.josm.data.osm.Relation; 14 14 import org.openstreetmap.josm.data.osm.Way; 15 15 import org.openstreetmap.josm.data.osm.WaySegment; 16 import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor; 16 17 17 18 /** 18 19 * Validation error 19 20 * @author frsantos 20 21 */ 21 public class TestError {22 public class TestError implements Comparable<TestError> { 22 23 /** is this error on the ignore list */ 23 24 private Boolean ignored = false; 24 25 /** Severity */ … … 276 277 public Collection<?> getHighlighted() { 277 278 return highlighted; 278 279 } 280 281 @Override 282 public int compareTo(TestError o) { 283 MultipleNameVisitor v1 = new MultipleNameVisitor(); 284 MultipleNameVisitor v2 = new MultipleNameVisitor(); 285 286 v1.visit(getPrimitives()); 287 v2.visit(o.getPrimitives()); 288 return v1.toString().compareToIgnoreCase(v2.toString()); 289 } 290 279 291 } -
src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
6 6 import java.util.ArrayList; 7 7 import java.util.Collection; 8 8 import java.util.HashSet; 9 import java.util.LinkedHashSet;10 9 import java.util.LinkedList; 11 10 import java.util.List; 12 11 import java.util.Map; 12 import java.util.TreeSet; 13 13 14 14 import org.openstreetmap.josm.command.ChangeCommand; 15 15 import org.openstreetmap.josm.command.Command; … … 191 191 @Override 192 192 public void endTest() { 193 193 super.endTest(); 194 for( LinkedHashSet<OsmPrimitive> duplicated : relations.values()) {194 for(TreeSet<OsmPrimitive> duplicated : relations.values()) { 195 195 if (duplicated.size() > 1) { 196 196 TestError testError = new TestError(this, Severity.ERROR, tr("Duplicated relations"), DUPLICATE_RELATION, duplicated); 197 197 errors.add( testError ); 198 198 } 199 199 } 200 200 relations = null; 201 for( LinkedHashSet<OsmPrimitive> duplicated : relations_nokeys.values()) {201 for(TreeSet<OsmPrimitive> duplicated : relations_nokeys.values()) { 202 202 if (duplicated.size() > 1) { 203 203 TestError testError = new TestError(this, Severity.WARNING, tr("Relations with same members"), SAME_RELATION, duplicated); 204 204 errors.add( testError ); … … 213 213 return; 214 214 List<RelationMember> rMembers = r.getMembers(); 215 215 Map<String, String> rkeys = r.getKeys(); 216 for (String key : ignoreKeys) 216 for (String key : ignoreKeys) { 217 217 rkeys.remove(key); 218 } 218 219 RelationPair rKey = new RelationPair(rMembers, rkeys); 219 220 relations.put(rKey, r); 220 221 relations_nokeys.put(rMembers, r); … … 289 290 @Override 290 291 public boolean isFixable(TestError testError) { 291 292 if (!(testError.getTester() instanceof DuplicateRelation) 292 || testError.getCode() == SAME_RELATION) return false;293 || testError.getCode() == SAME_RELATION) return false; 293 294 294 295 // We fix it only if there is no more than one relation that is relation member. 295 296 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); -
src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
6 6 import java.util.ArrayList; 7 7 import java.util.Collection; 8 8 import java.util.HashMap; 9 import java.util.LinkedHashSet;10 9 import java.util.List; 11 10 import java.util.Map; 11 import java.util.TreeSet; 12 12 13 13 import org.openstreetmap.josm.data.osm.Node; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 55 55 56 56 @Override 57 57 public void endTest() { 58 Map<List<Way>, LinkedHashSet<WaySegment>> ways_seen = new HashMap<List<Way>, LinkedHashSet<WaySegment>>(500);58 Map<List<Way>, TreeSet<WaySegment>> ways_seen = new HashMap<List<Way>, TreeSet<WaySegment>>(500); 59 59 60 for ( LinkedHashSet<WaySegment> duplicated : nodePairs.values()) {60 for (TreeSet<WaySegment> duplicated : nodePairs.values()) { 61 61 int ways = duplicated.size(); 62 62 63 63 if (ways > 1) { -
src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
8 8 import java.util.Enumeration; 9 9 import java.util.HashMap; 10 10 import java.util.HashSet; 11 import java.util.LinkedHashSet;12 11 import java.util.List; 13 12 import java.util.Map; 14 13 import java.util.Map.Entry; 15 14 import java.util.Set; 15 import java.util.TreeSet; 16 16 17 17 import javax.swing.JTree; 18 18 import javax.swing.ToolTipManager; … … 205 206 expandedPaths.add(new TreePath(new Object[] { rootNode, severityNode })); 206 207 } 207 208 208 for (Entry<String, LinkedHashSet<TestError>> msgErrors : severityErrors.entrySet()) {209 for (Entry<String, TreeSet<TestError>> msgErrors : severityErrors.entrySet()) { 209 210 // Message node 210 211 Set<TestError> errs = msgErrors.getValue(); 211 212 String msg = msgErrors.getKey() + " (" + errs.size() + ")"; … … 235 236 } 236 237 } 237 238 238 for (Entry<String, LinkedHashSet<TestError>> msgErrors : errorlist.entrySet()) {239 for (Entry<String, TreeSet<TestError>> msgErrors : errorlist.entrySet()) { 239 240 // Message node 240 241 Set<TestError> errs = msgErrors.getValue(); 241 242 String msg; -
src/org/openstreetmap/josm/tools/MultiMap.java
4 4 import java.util.ArrayList; 5 5 import java.util.Collection; 6 6 import java.util.HashMap; 7 import java.util.LinkedHashSet;8 7 import java.util.List; 9 8 import java.util.Map; 10 9 import java.util.Map.Entry; 11 10 import java.util.Set; 11 import java.util.TreeSet; 12 12 13 13 /** 14 14 * MultiMap - maps keys to multiple values … … 19 19 */ 20 20 public class MultiMap<A, B> { 21 21 22 private final Map<A, LinkedHashSet<B>> map;22 private final Map<A, TreeSet<B>> map; 23 23 24 24 public MultiMap() { 25 map = new HashMap<A, LinkedHashSet<B>>();25 map = new HashMap<A, TreeSet<B>>(); 26 26 } 27 27 28 28 public MultiMap(int capacity) { 29 map = new HashMap<A, LinkedHashSet<B>>(capacity);29 map = new HashMap<A, TreeSet<B>>(capacity); 30 30 } 31 31 32 32 /** … … 35 35 * Can be called multiple times with the same key, but different value. 36 36 */ 37 37 public void put(A key, B value) { 38 LinkedHashSet<B> vals = map.get(key);38 TreeSet<B> vals = map.get(key); 39 39 if (vals == null) { 40 vals = new LinkedHashSet<B>();40 vals = new TreeSet<B>(); 41 41 map.put(key, vals); 42 42 } 43 43 vals.add(value); … … 52 52 public void putVoid(A key) { 53 53 if (map.containsKey(key)) 54 54 return; 55 map.put(key, new LinkedHashSet<B>());55 map.put(key, new TreeSet<B>()); 56 56 } 57 57 58 58 /** … … 61 61 * Adds to the mappings that are already there. 62 62 */ 63 63 public void putAll(A key, Collection<B> values) { 64 LinkedHashSet<B> vals = map.get(key);64 TreeSet<B> vals = map.get(key); 65 65 if (vals == null) { 66 vals = new LinkedHashSet<B>(values);66 vals = new TreeSet<B>(values); 67 67 map.put(key, vals); 68 68 } 69 69 vals.addAll(values); … … 90 90 /** 91 91 * Like get, but returns an empty Set if nothing has been mapped to the key. 92 92 */ 93 public LinkedHashSet<B> getValues(A key) {93 public TreeSet<B> getValues(A key) { 94 94 if (!map.containsKey(key)) 95 return new LinkedHashSet<B>();95 return new TreeSet<B>(); 96 96 return map.get(key); 97 97 } 98 98 … … 120 120 map.clear(); 121 121 } 122 122 123 public Set<Entry<A, LinkedHashSet<B>>> entrySet() {123 public Set<Entry<A, TreeSet<B>>> entrySet() { 124 124 return map.entrySet(); 125 125 } 126 126 … … 134 134 /** 135 135 * Returns a collection of all value sets. 136 136 */ 137 public Collection< LinkedHashSet<B>> values() {137 public Collection<TreeSet<B>> values() { 138 138 return map.values(); 139 139 } 140 140 … … 145 145 */ 146 146 public boolean remove(A key, B value) { 147 147 Set<B> values = get(key); 148 if (values != null) {148 if (values != null) 149 149 return values.remove(value); 150 }151 150 return false; 152 151 } 153 152 154 153 /** 155 154 * Removes all mappings for a certain key. 156 155 */ 157 public LinkedHashSet<B> remove(A key) {156 public TreeSet<B> remove(A key) { 158 157 return map.remove(key); 159 158 } 160 159 160 @Override 161 161 public String toString() { 162 162 List<String> entries = new ArrayList<String>(map.size()); 163 163 for (A key : map.keySet()) {