Changeset 3654 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-11-14T18:09:06+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r3469 r3654 676 676 */ 677 677 public void sort() { 678 Collections.sort(this.selection, new OsmPrimitiveComparator()); 678 if (this.selection.size()>Main.pref.getInteger("selection.no_sort_above",100000)) return; 679 if (this.selection.size()>Main.pref.getInteger("selection.fast_sort_above",10000)) { 680 Collections.sort(this.selection, new OsmPrimitiveQuickComparator()); 681 } else { 682 Collections.sort(this.selection, new OsmPrimitiveComparator()); 683 } 679 684 } 680 685 … … 911 916 } 912 917 918 /** Comparator, comparing by type and objects display names */ 913 919 static private class OsmPrimitiveComparator implements Comparator<OsmPrimitive> { 914 920 final private HashMap<OsmPrimitive, String> cache= new HashMap<OsmPrimitive, String>(); … … 940 946 private int compareType(OsmPrimitive a, OsmPrimitive b) { 941 947 // show ways before relations, then nodes 942 //943 if (a.getType().equals(b.getType())) return 0;944 948 if (a.getType().equals(OsmPrimitiveType.WAY)) return -1; 945 949 if (a.getType().equals(OsmPrimitiveType.NODE)) return 1; … … 949 953 return -1; 950 954 } 955 951 956 public int compare(OsmPrimitive a, OsmPrimitive b) { 952 957 if (a.getType().equals(b.getType())) … … 955 960 } 956 961 } 962 963 /** Quicker comparator, comparing just by type and ID's */ 964 static private class OsmPrimitiveQuickComparator implements Comparator<OsmPrimitive> { 965 966 private int compareId(OsmPrimitive a, OsmPrimitive b) { 967 long id_a=a.getUniqueId(); 968 long id_b=b.getUniqueId(); 969 if (id_a<id_b) return -1; 970 if (id_a>id_b) return 1; 971 return 0; 972 } 973 974 private int compareType(OsmPrimitive a, OsmPrimitive b) { 975 // show ways before relations, then nodes 976 if (a.getType().equals(OsmPrimitiveType.WAY)) return -1; 977 if (a.getType().equals(OsmPrimitiveType.NODE)) return 1; 978 // a is a relation 979 if (b.getType().equals(OsmPrimitiveType.WAY)) return 1; 980 // b is a node 981 return -1; 982 } 983 984 public int compare(OsmPrimitive a, OsmPrimitive b) { 985 if (a.getType().equals(b.getType())) 986 return compareId(a, b); 987 return compareType(a, b); 988 } 989 } 990 957 991 }
Note:
See TracChangeset
for help on using the changeset viewer.