Changeset 5783 in josm for trunk


Ignore:
Timestamp:
2013-03-19T02:09:12+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #8517 - Sort validator results (based on patch by windu.2b)

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/WaySegment.java

    r4327 r5783  
    55 * A segment consisting of 2 consecutive nodes out of a way.
    66 */
    7 public final class WaySegment {
     7public final class WaySegment implements Comparable<WaySegment> {
    88    /**
    99     * The way.
     
    5050        return way.hashCode() ^ lowerIndex;
    5151    }
     52
     53    @Override
     54    public int compareTo(WaySegment o) {
     55        return equals(o) ? 0 : toWay().compareTo(o.toWay());
     56    }
    5257}
  • trunk/src/org/openstreetmap/josm/data/validation/TestError.java

    r5671 r5783  
    1414import org.openstreetmap.josm.data.osm.Way;
    1515import org.openstreetmap.josm.data.osm.WaySegment;
     16import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor;
    1617
    1718/**
     
    1920 * @author frsantos
    2021 */
    21 public class TestError {
     22public class TestError implements Comparable<TestError> {
    2223    /** is this error on the ignore list */
    2324    private Boolean ignored = false;
     
    277278        return highlighted;
    278279    }
     280
     281    @Override
     282    public int compareTo(TestError o) {
     283        if (equals(o)) return 0;
     284       
     285        MultipleNameVisitor v1 = new MultipleNameVisitor();
     286        MultipleNameVisitor v2 = new MultipleNameVisitor();
     287
     288        v1.visit(getPrimitives());
     289        v2.visit(o.getPrimitives());
     290        return v1.toString().compareToIgnoreCase(v2.toString());
     291    }
    279292}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java

    r5667 r5783  
    77import java.util.Collection;
    88import java.util.HashSet;
    9 import java.util.LinkedHashSet;
    109import java.util.LinkedList;
    1110import java.util.List;
    1211import java.util.Map;
     12import java.util.Set;
    1313
    1414import org.openstreetmap.josm.command.ChangeCommand;
     
    192192    public void endTest() {
    193193        super.endTest();
    194         for(LinkedHashSet<OsmPrimitive> duplicated : relations.values()) {
     194        for (Set<OsmPrimitive> duplicated : relations.values()) {
    195195            if (duplicated.size() > 1) {
    196196                TestError testError = new TestError(this, Severity.ERROR, tr("Duplicated relations"), DUPLICATE_RELATION, duplicated);
     
    199199        }
    200200        relations = null;
    201         for(LinkedHashSet<OsmPrimitive> duplicated : relations_nokeys.values()) {
     201        for (Set<OsmPrimitive> duplicated : relations_nokeys.values()) {
    202202            if (duplicated.size() > 1) {
    203203                TestError testError = new TestError(this, Severity.WARNING, tr("Relations with same members"), SAME_RELATION, duplicated);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r4869 r5783  
    77import java.util.Collection;
    88import java.util.HashMap;
    9 import java.util.LinkedHashSet;
    109import java.util.List;
    1110import java.util.Map;
     11import java.util.Set;
    1212
    1313import org.openstreetmap.josm.data.osm.Node;
     
    5656    @Override
    5757    public void endTest() {
    58         Map<List<Way>, LinkedHashSet<WaySegment>> ways_seen = new HashMap<List<Way>, LinkedHashSet<WaySegment>>(500);
     58        Map<List<Way>, Set<WaySegment>> ways_seen = new HashMap<List<Way>, Set<WaySegment>>(500);
    5959
    60         for (LinkedHashSet<WaySegment> duplicated : nodePairs.values()) {
     60        for (Set<WaySegment> duplicated : nodePairs.values()) {
    6161            int ways = duplicated.size();
    6262
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r5672 r5783  
    99import java.util.HashMap;
    1010import java.util.HashSet;
    11 import java.util.LinkedHashSet;
    1211import java.util.List;
    1312import java.util.Map;
     
    206205            }
    207206
    208             for (Entry<String, LinkedHashSet<TestError>> msgErrors : severityErrors.entrySet()) {
     207            for (Entry<String, Set<TestError>> msgErrors : severityErrors.entrySet()) {
    209208                // Message node
    210209                Set<TestError> errs = msgErrors.getValue();
     
    236235                }
    237236
    238                 for (Entry<String, LinkedHashSet<TestError>> msgErrors : errorlist.entrySet()) {
     237                for (Entry<String, Set<TestError>> msgErrors : errorlist.entrySet()) {
    239238                    // Message node
    240239                    Set<TestError> errs = msgErrors.getValue();
  • trunk/src/org/openstreetmap/josm/tools/MultiMap.java

    r4685 r5783  
    55import java.util.Collection;
    66import java.util.HashMap;
    7 import java.util.LinkedHashSet;
    87import java.util.List;
    98import java.util.Map;
    109import java.util.Map.Entry;
    1110import java.util.Set;
     11import java.util.TreeSet;
    1212
    1313/**
     
    2020public class MultiMap<A, B> {
    2121
    22     private final Map<A, LinkedHashSet<B>> map;
     22    private final Map<A, Set<B>> map;
    2323
    2424    public MultiMap() {
    25         map = new HashMap<A, LinkedHashSet<B>>();
     25        map = new HashMap<A, Set<B>>();
    2626    }
    2727
    2828    public MultiMap(int capacity) {
    29         map = new HashMap<A, LinkedHashSet<B>>(capacity);
     29        map = new HashMap<A, Set<B>>(capacity);
    3030    }
    3131
     
    3636     */
    3737    public void put(A key, B value) {
    38         LinkedHashSet<B> vals = map.get(key);
     38        Set<B> vals = map.get(key);
    3939        if (vals == null) {
    40             vals = new LinkedHashSet<B>();
     40            vals = new TreeSet<B>();
    4141            map.put(key, vals);
    4242        }
     
    5353        if (map.containsKey(key))
    5454            return;
    55         map.put(key, new LinkedHashSet<B>());
     55        map.put(key, new TreeSet<B>());
    5656    }
    5757
     
    6262     */
    6363    public void putAll(A key, Collection<B> values) {
    64         LinkedHashSet<B> vals = map.get(key);
     64        Set<B> vals = map.get(key);
    6565        if (vals == null) {
    66             vals = new LinkedHashSet<B>(values);
     66            vals = new TreeSet<B>(values);
    6767            map.put(key, vals);
    6868        }
     
    9191     * Like get, but returns an empty Set if nothing has been mapped to the key.
    9292     */
    93     public LinkedHashSet<B> getValues(A key) {
     93    public Set<B> getValues(A key) {
    9494        if (!map.containsKey(key))
    95             return new LinkedHashSet<B>();
     95            return new TreeSet<B>();
    9696        return map.get(key);
    9797    }
     
    121121    }
    122122
    123     public Set<Entry<A, LinkedHashSet<B>>> entrySet() {
     123    public Set<Entry<A, Set<B>>> entrySet() {
    124124        return map.entrySet();
    125125    }
     
    135135     * Returns a collection of all value sets.
    136136     */
    137     public Collection<LinkedHashSet<B>> values() {
     137    public Collection<Set<B>> values() {
    138138        return map.values();
    139139    }
     
    155155     * Removes all mappings for a certain key.
    156156     */
    157     public LinkedHashSet<B> remove(A key) {
     157    public Set<B> remove(A key) {
    158158        return map.remove(key);
    159159    }
    160160
     161    @Override
    161162    public String toString() {
    162163        List<String> entries = new ArrayList<String>(map.size());
Note: See TracChangeset for help on using the changeset viewer.