Changeset 3102 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2010-03-10T10:00:20+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r3008 r3102 9 9 import java.util.Collection; 10 10 import java.util.Collections; 11 import java.util.Comparator;12 11 import java.util.HashMap; 13 12 import java.util.HashSet; … … 313 312 314 313 /** 315 * Return a list of all selected objects. Even keys are returned. 316 * @return List of all selected objects. 314 * Replies an unmodifiable collection of primitives currently selected 315 * in this dataset 316 * 317 * @return unmodifiable collection of primitives 317 318 */ 318 319 public Collection<OsmPrimitive> getSelected() { 319 // It would be nice to have this be a copy-on-write list 320 // or an Collections.unmodifiableList(). It would be 321 // much faster for large selections. May users just 322 // call this, and only check the .size(). 323 return new ArrayList<OsmPrimitive>(selectedPrimitives); 320 return Collections.unmodifiableSet(selectedPrimitives); 324 321 } 325 322 … … 610 607 } 611 608 return a; 612 }613 614 // Provide well-defined sorting for collections of OsmPrimitives.615 // FIXME: probably not a good place to put this code.616 public static OsmPrimitive[] sort(Collection<? extends OsmPrimitive> list) {617 OsmPrimitive[] selArr = new OsmPrimitive[list.size()];618 final HashMap<Object, String> h = new HashMap<Object, String>();619 selArr = list.toArray(selArr);620 Arrays.sort(selArr, new Comparator<OsmPrimitive>() {621 public int compare(OsmPrimitive a, OsmPrimitive b) {622 if (a.getClass() == b.getClass()) {623 String as = h.get(a);624 if (as == null) {625 as = a.getName() != null ? a.getName() : Long.toString(a.getId());626 h.put(a, as);627 }628 String bs = h.get(b);629 if (bs == null) {630 bs = b.getName() != null ? b.getName() : Long.toString(b.getId());631 h.put(b, bs);632 }633 int res = as.compareTo(bs);634 if (res != 0)635 return res;636 }637 return a.compareTo(b);638 }639 });640 return selArr;641 609 } 642 610 -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r3032 r3102 398 398 } 399 399 } 400 401 /** 402 * Replies true if at least one child primitive is incomplete 403 * 404 * @return true if at least one child primitive is incomplete 405 */ 406 public boolean hasIncompleteMembers() { 407 for (RelationMember rm: members) { 408 if (rm.getMember().isIncomplete()) return true; 409 } 410 return false; 411 } 412 413 /** 414 * Replies a collection with the incomplete children this relation 415 * refers to 416 * 417 * @return the incomplete children. Empty collection if no children are incomplete. 418 */ 419 public Collection<OsmPrimitive> getIncompleteMembers() { 420 Set<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 421 for (RelationMember rm: members) { 422 if (!rm.getMember().isIncomplete()) { 423 continue; 424 } 425 ret.add(rm.getMember()); 426 } 427 return ret; 428 } 400 429 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintVisitor.java
r2982 r3102 17 17 import java.util.Comparator; 18 18 import java.util.LinkedList; 19 import java.util.List; 19 20 20 21 import org.openstreetmap.josm.Main; … … 674 675 Collection<Way> noAreaWays = new LinkedList<Way>(); 675 676 677 List<Relation> relations = data.searchRelations(bbox); 676 678 /*** RELATIONS ***/ 677 679 for (final Relation osm: data.searchRelations(bbox)) {
Note:
See TracChangeset
for help on using the changeset viewer.