Changeset 5083 in josm for trunk/src/org
- Timestamp:
- 2012-03-14T23:07:10+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r5059 r5083 34 34 import org.openstreetmap.josm.data.osm.history.HistoryWay; 35 35 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 36 import org.openstreetmap.josm.tools.AlphanumComparator; 36 37 import org.openstreetmap.josm.tools.I18n; 37 38 import org.openstreetmap.josm.tools.TaggingPresetNameTemplateList; … … 349 350 350 351 private final Comparator<Relation> relationComparator = new Comparator<Relation>() { 352 private final AlphanumComparator ALPHANUM_COMPARATOR = new AlphanumComparator(); 351 353 @Override 352 354 public int compare(Relation r1, Relation r2) { … … 370 372 String type2 = getRelationTypeName(r2); 371 373 372 int comp = type1.compareTo(type2);374 int comp = ALPHANUM_COMPARATOR.compare(type1, type2); 373 375 if (comp != 0) 374 376 return comp; … … 377 379 String name2 = getRelationName(r2); 378 380 379 if (name1 == null && name2 == null) 380 return (r1.getUniqueId() > r2.getUniqueId())?1:-1; 381 else if (name1 == null) 382 return -1; 383 else if (name2 == null) 384 return 1; 385 else if (!name1.isEmpty() && !name2.isEmpty() && Character.isDigit(name1.charAt(0)) && Character.isDigit(name2.charAt(0))) { 386 //Compare numerically 387 String ln1 = getLeadingNumber(name1); 388 String ln2 = getLeadingNumber(name2); 389 390 comp = Long.valueOf(ln1).compareTo(Long.valueOf(ln2)); 391 if (comp != 0) 392 return comp; 393 394 // put 1 before 0001 395 comp = ln1.compareTo(ln2); 396 if (comp != 0) 397 return comp; 398 399 comp = name1.substring(ln1.length()).compareTo(name2.substring(ln2.length())); 400 if (comp != 0) 401 return comp; 402 } else { 403 comp = name1.compareToIgnoreCase(name2); 404 if (comp != 0) 405 return comp; 406 } 407 } 408 381 return ALPHANUM_COMPARATOR.compare(name1, name2); 382 } 409 383 410 384 if (r1.getMembersCount() != r2.getMembersCount())
Note:
See TracChangeset
for help on using the changeset viewer.