Changeset 15152 in josm
- Timestamp:
- 2019-06-02T15:25:38+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r14397 r15152 18 18 import java.util.Map; 19 19 import java.util.Set; 20 import java.util.stream.Collectors; 20 21 21 22 import javax.swing.JOptionPane; … … 367 368 368 369 // put the nodes of all ways in a set 369 final Set<Node> allNodes = new HashSet<>(); 370 for (WayData w : wayDataList) { 371 allNodes.addAll(w.wayNodes); 372 } 370 final Set<Node> allNodes = wayDataList.stream().flatMap(w -> w.wayNodes.stream()).collect(Collectors.toSet()); 373 371 374 372 // the new x and y value for each node -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r14971 r15152 229 229 if (newNodes.size() == w.getNodesCount()) return null; 230 230 231 Set<Node> delNodes = new HashSet<>(); 232 delNodes.addAll(w.getNodes()); 231 Set<Node> delNodes = new HashSet<>(w.getNodes()); 233 232 delNodes.removeAll(newNodes); 234 233 -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r14706 r15152 17 17 import java.util.Map; 18 18 import java.util.Set; 19 import java.util.stream.Collectors; 19 20 20 21 import javax.swing.JOptionPane; … … 610 611 } 611 612 612 protected void notifyWayPartOfRelation(final Iterable<Way> ways) { 613 final Set<String> affectedRelations = new HashSet<>(); 614 for (Way way : ways) { 615 for (OsmPrimitive ref : way.getReferrers()) { 616 if (ref instanceof Relation && ref.isUsable()) { 617 affectedRelations.add(ref.getDisplayName(DefaultNameFormatter.getInstance())); 618 } 619 } 620 } 613 protected void notifyWayPartOfRelation(final Collection<Way> ways) { 614 final Set<String> affectedRelations = ways.stream() 615 .flatMap(w -> w.getReferrers().stream()) 616 .filter(ref -> ref instanceof Relation && ref.isUsable()) 617 .map(ref -> ref.getDisplayName(DefaultNameFormatter.getInstance())) 618 .collect(Collectors.toSet()); 621 619 if (affectedRelations.isEmpty()) { 622 620 return; 623 621 } 624 622 623 final int size = affectedRelations.size(); 625 624 final String msg1 = trn("Unglueing affected {0} relation: {1}", "Unglueing affected {0} relations: {1}", 626 affectedRelations.size(), affectedRelations.size(), Utils.joinAsHtmlUnorderedList(affectedRelations));625 size, size, Utils.joinAsHtmlUnorderedList(affectedRelations)); 627 626 final String msg2 = trn("Ensure that the relation has not been broken!", "Ensure that the relations have not been broken!", 628 affectedRelations.size());627 size); 629 628 new Notification("<html>" + msg1 + msg2).setIcon(JOptionPane.WARNING_MESSAGE).show(); 630 629 } -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r14397 r15152 12 12 import java.util.Set; 13 13 import java.util.Stack; 14 import java.util.stream.Collectors; 14 15 15 16 import javax.swing.JOptionPane; … … 70 71 71 72 protected Set<OsmPrimitive> getDeletedPrimitives(DataSet ds) { 72 Set<OsmPrimitive> ret = new HashSet<>(); 73 for (OsmPrimitive p: ds.allPrimitives()) { 74 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 75 ret.add(p); 76 } 77 } 78 return ret; 73 return ds.allPrimitives().stream() 74 .filter(p -> p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) 75 .collect(Collectors.toSet()); 79 76 } 80 77 81 78 protected Set<OsmPrimitive> getModifiedPrimitives(Collection<OsmPrimitive> primitives) { 82 Set<OsmPrimitive> ret = new HashSet<>(); 83 for (OsmPrimitive p: primitives) { 84 if (p.isNewOrUndeleted() || (p.isModified() && !p.isIncomplete())) { 85 ret.add(p); 86 } 87 } 88 return ret; 79 return primitives.stream() 80 .filter(p -> p.isNewOrUndeleted() || (p.isModified() && !p.isIncomplete())) 81 .collect(Collectors.toSet()); 89 82 } 90 83 … … 292 285 */ 293 286 protected Set<OsmPrimitive> getPrimitivesToCheckForParents() { 294 Set<OsmPrimitive> ret = new HashSet<>(); 295 for (OsmPrimitive p: toUpload) { 296 if (p.isDeleted() && !p.isNewOrUndeleted()) { 297 ret.add(p); 298 } 299 } 300 return ret; 287 return toUpload.stream().filter(p -> p.isDeleted() && !p.isNewOrUndeleted()).collect(Collectors.toSet()); 301 288 } 302 289 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/ChangesetHeaderDownloadTask.java
r14154 r15152 9 9 import java.util.Collections; 10 10 import java.util.HashSet; 11 import java.util.Objects; 11 12 import java.util.Set; 13 import java.util.stream.Collectors; 12 14 13 15 import org.openstreetmap.josm.data.osm.Changeset; … … 16 18 import org.openstreetmap.josm.gui.MainApplication; 17 19 import org.openstreetmap.josm.io.OsmTransferException; 18 import org.openstreetmap.josm.tools.CheckParameterUtil;19 20 import org.xml.sax.SAXException; 20 21 … … 134 135 * @param changesets the collection of changesets. Assumes an empty collection if null. 135 136 * @return the download task 136 * @throws IllegalArgumentException if parent is null137 * @throws NullPointerException if parent is null 137 138 */ 138 139 public static ChangesetHeaderDownloadTask buildTaskForChangesets(Component parent, Collection<Changeset> changesets) { 139 CheckParameterUtil.ensureParameterNotNull(parent, "parent"); 140 141 Set<Integer> ids = new HashSet<>(); 142 for (Changeset cs: changesets != null ? changesets : Collections.<Changeset>emptyList()) { 143 if (cs == null || cs.isNew()) { 144 continue; 145 } 146 ids.add(cs.getId()); 147 } 148 return new ChangesetHeaderDownloadTask(parent, ids); 140 return new ChangesetHeaderDownloadTask(Objects.requireNonNull(parent, "parent"), 141 changesets == null ? Collections.<Integer>emptySet() : 142 changesets.stream().filter(cs -> cs != null && !cs.isNew()).map(Changeset::getId).collect(Collectors.toSet())); 149 143 } 150 144 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r14153 r15152 9 9 import java.util.Collection; 10 10 import java.util.HashMap; 11 import java.util.HashSet;12 11 import java.util.Map; 13 12 import java.util.Map.Entry; 14 13 import java.util.Set; 14 import java.util.stream.Collectors; 15 15 16 16 import javax.swing.JOptionPane; … … 148 148 Collection<Way> ways = ds.getWays(); 149 149 150 DataSetMerger merger;151 150 if (!ways.isEmpty()) { 152 Set<Node> nodes = new HashSet<>(); 153 for (Way w: ways) { 154 // Ensure each node is only listed once 155 nodes.addAll(w.getNodes()); 156 } 151 // Ensure each node is only listed once 152 Set<Node> nodes = ways.stream().flatMap(w -> w.getNodes().stream()).collect(Collectors.toSet()); 157 153 // Don't retrieve any nodes we've already grabbed 158 154 nodes.removeAll(targetLayer.data.getNodes()); … … 164 160 reader = null; 165 161 } 166 merger = new DataSetMerger(ds, wayNodes); 167 merger.merge(); 162 new DataSetMerger(ds, wayNodes).merge(); 168 163 } 169 164 } 170 merger = new DataSetMerger(parents, ds); 171 merger.merge(); 165 new DataSetMerger(parents, ds).merge(); 172 166 } 173 167 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java
r14153 r15152 11 11 import java.util.ArrayList; 12 12 import java.util.Collection; 13 import java.util.HashSet;14 13 import java.util.LinkedHashSet; 15 14 import java.util.LinkedList; 16 15 import java.util.List; 16 import java.util.Objects; 17 17 import java.util.Set; 18 18 import java.util.concurrent.CancellationException; 19 19 import java.util.concurrent.ExecutionException; 20 20 import java.util.concurrent.Future; 21 import java.util.stream.Collectors; 21 22 22 23 import javax.swing.JOptionPane; … … 126 127 */ 127 128 protected Set<OsmPrimitive> getCompletePrimitives(DataSet ds) { 128 Set<OsmPrimitive> ret = new HashSet<>(); 129 for (OsmPrimitive primitive : ds.allPrimitives()) { 130 if (!primitive.isIncomplete() && !primitive.isNew()) { 131 ret.add(primitive); 132 } 133 } 134 return ret; 129 return ds.allPrimitives().stream().filter(p -> !p.isIncomplete() && !p.isNew()).collect(Collectors.toSet()); 135 130 } 136 131 … … 210 205 */ 211 206 public Set<OsmPrimitive> getDownloadedPrimitives() { 212 Set<OsmPrimitive> ret = new HashSet<>(); 213 for (DownloadTask task : tasks) { 214 if (task instanceof DownloadOsmTask) { 215 DataSet ds = ((DownloadOsmTask) task).getDownloadedData(); 216 if (ds != null) { 217 ret.addAll(ds.allPrimitives()); 218 } 219 } 220 } 221 return ret; 207 return tasks.stream() 208 .filter(t -> t instanceof DownloadOsmTask) 209 .map(t -> ((DownloadOsmTask) t).getDownloadedData()) 210 .filter(Objects::nonNull) 211 .flatMap(ds -> ds.allPrimitives().stream()) 212 .collect(Collectors.toSet()); 222 213 } 223 214 -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r15126 r15152 202 202 return; 203 203 204 Set<OsmPrimitive> newHighlights = new HashSet<>();205 204 DeleteParameters parameters = getDeleteParameters(e, modifiers); 206 205 … … 208 207 // deleting segments is the only action not working on OsmPrimitives 209 208 // so we have to handle them separately. 210 repaintIfRequired( newHighlights, parameters.nearestSegment);209 repaintIfRequired(Collections.emptySet(), parameters.nearestSegment); 211 210 } else { 212 211 // don't call buildDeleteCommands for DeleteMode.segment because it doesn't support 213 212 // silent operation and SplitWayAction will show dialogs. A lot. 214 213 Command delCmd = buildDeleteCommands(e, modifiers, true); 215 if (delCmd != null) { 216 // all other cases delete OsmPrimitives directly, so we can safely do the following 217 for (OsmPrimitive osm : delCmd.getParticipatingPrimitives()) { 218 newHighlights.add(osm); 219 } 220 } 221 repaintIfRequired(newHighlights, null); 214 // all other cases delete OsmPrimitives directly, so we can safely do the following 215 repaintIfRequired(delCmd == null ? Collections.emptySet() : new HashSet<>(delCmd.getParticipatingPrimitives()), null); 222 216 } 223 217 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r13957 r15152 6 6 import java.awt.event.ActionEvent; 7 7 import java.util.Collection; 8 import java.util.HashSet;9 8 import java.util.Set; 9 import java.util.stream.Collectors; 10 10 11 11 import org.openstreetmap.josm.data.osm.IPrimitive; … … 42 42 */ 43 43 public static Set<IPrimitive> buildSetOfIncompleteMembers(Collection<IRelation<?>> rels) { 44 Set<IPrimitive> ret = new HashSet<>(); 45 for (IRelation<?> r : rels) { 46 ret.addAll(SubclassFilteredCollection.filter(r.getIncompleteMembers(), osm -> !osm.isNew())); 47 } 48 return ret; 44 return rels.stream() 45 .flatMap(r -> SubclassFilteredCollection.filter(r.getIncompleteMembers(), osm -> !osm.isNew()).stream()) 46 .collect(Collectors.toSet()); 49 47 } 50 48 -
trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java
r14153 r15152 7 7 import java.awt.event.ActionEvent; 8 8 import java.util.Collection; 9 import java.util. HashSet;9 import java.util.Collections; 10 10 import java.util.Set; 11 import java.util.stream.Collectors; 11 12 12 13 import javax.swing.JOptionPane; … … 46 47 */ 47 48 public static Set<RelationMember> getMembersForCurrentSelection(Relation r) { 48 Set<RelationMember> members = new HashSet<>();49 49 if (MainApplication.isDisplayingMapView()) { 50 50 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 51 51 if (editLayer != null && editLayer.data != null) { 52 52 Collection<OsmPrimitive> selection = editLayer.data.getSelected(); 53 for (RelationMember member: r.getMembers()) { 54 if (selection.contains(member.getMember())) { 55 members.add(member); 56 } 57 } 53 return r.getMembers().stream().filter(m -> selection.contains(m.getMember())).collect(Collectors.toSet()); 58 54 } 59 55 } 60 return members;56 return Collections.emptySet(); 61 57 } 62 58 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java
r13929 r15152 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.Collection;7 import java.util.HashSet;8 6 import java.util.LinkedList; 9 7 import java.util.List; 8 import java.util.stream.Collectors; 10 9 11 10 import org.openstreetmap.josm.data.osm.DataSet; 12 import org.openstreetmap.josm.data.osm.OsmPrimitive;13 11 import org.openstreetmap.josm.data.osm.PrimitiveId; 14 12 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; … … 75 73 if (downloaded != null) { 76 74 GuiHelper.runInEDT(() -> ds.setSelected(downloaded)); 77 Collection<OsmPrimitive> downlPrim = new HashSet<>(); 78 for (PrimitiveId id : downloaded) { 79 downlPrim.add(ds.getPrimitiveById(id)); 80 } 81 AddTagsDialog.addTags(args, sender, downlPrim); 75 AddTagsDialog.addTags(args, sender, downloaded.stream().map(ds::getPrimitiveById).collect(Collectors.toSet())); 82 76 } 83 77 ps.clear();
Note:
See TracChangeset
for help on using the changeset viewer.