Changeset 17141 in josm
- Timestamp:
- 2020-10-10T11:48:49+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r14134 r17141 12 12 13 13 import org.openstreetmap.josm.actions.mapmode.DrawAction; 14 import org.openstreetmap.josm.command.Change Command;14 import org.openstreetmap.josm.command.ChangeNodesCommand; 15 15 import org.openstreetmap.josm.command.SelectCommand; 16 16 import org.openstreetmap.josm.command.SequenceCommand; … … 109 109 } 110 110 if (newPoint != null) { 111 Way newFollower = new Way(follower);111 List<Node> modNodes = follower.getNodes(); 112 112 if (reversed) { 113 newFollower.addNode(0, newPoint);113 modNodes.add(0, newPoint); 114 114 } else { 115 newFollower.addNode(newPoint);115 modNodes.add(newPoint); 116 116 } 117 boolean isClosed = modNodes.size() >= 3 && modNodes.get(modNodes.size()-1) == modNodes.get(0); 117 118 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Follow line"), 118 new Change Command(ds, follower, newFollower),119 new SelectCommand(ds, newFollower.isClosed()// see #10028 - unselect last node when closing a way119 new ChangeNodesCommand(ds, follower, modNodes), 120 new SelectCommand(ds, isClosed // see #10028 - unselect last node when closing a way 120 121 ? Arrays.<OsmPrimitive>asList(follower) 121 122 : Arrays.<OsmPrimitive>asList(follower, newPoint) -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r16365 r17141 27 27 import org.openstreetmap.josm.command.AddCommand; 28 28 import org.openstreetmap.josm.command.ChangeCommand; 29 import org.openstreetmap.josm.command.ChangeNodesCommand; 29 30 import org.openstreetmap.josm.command.Command; 30 31 import org.openstreetmap.josm.command.DeleteCommand; … … 793 794 discardedWays.remove(oldest); 794 795 discardedWays.add(way); 795 Way copy = new Way(oldest); 796 copy.setNodes(way.getNodes()); 797 cmds.add(new ChangeCommand(oldest, copy)); 796 cmds.add(new ChangeNodesCommand(oldest, way.getNodes())); 798 797 return oldest; 799 798 } … … 875 874 } 876 875 877 Way newWay = new Way(way); 878 newWay.setNodes(newNodes); 879 cmds.add(new ChangeCommand(way, newWay)); 876 cmds.add(new ChangeNodesCommand(way, newNodes)); 880 877 ++totalWaysModified; 881 878 } -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r16202 r17141 23 23 import javax.swing.JOptionPane; 24 24 25 import org.openstreetmap.josm.command.Change Command;25 import org.openstreetmap.josm.command.ChangeNodesCommand; 26 26 import org.openstreetmap.josm.command.Command; 27 27 import org.openstreetmap.josm.command.MoveCommand; … … 192 192 wayNodes.addAll(segmentIndex + 1, nodesToAdd); 193 193 } 194 Way wnew = new Way(w); 195 wnew.setNodes(wayNodes); 196 cmds.add(new ChangeCommand(ds, w, wnew)); 194 cmds.add(new ChangeNodesCommand(ds, w, wayNodes)); 197 195 } 198 196 -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r16438 r17141 31 31 import org.openstreetmap.josm.actions.MergeNodesAction; 32 32 import org.openstreetmap.josm.command.AddCommand; 33 import org.openstreetmap.josm.command.Change Command;33 import org.openstreetmap.josm.command.ChangeNodesCommand; 34 34 import org.openstreetmap.josm.command.Command; 35 35 import org.openstreetmap.josm.command.MoveCommand; … … 586 586 EastNorth b = ws.getSecondNode().getEastNorth(); 587 587 n.setEastNorth(Geometry.closestPointToSegment(a, b, n.getEastNorth())); 588 Way wnew = new Way(ws.way);589 wnew.addNode(ws.lowerIndex+1, n);588 List<Node> modnodes = ws.way.getNodes(); 589 modnodes.add(ws.lowerIndex+1, n); 590 590 DataSet ds = ws.way.getDataSet(); 591 591 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Add a new node to an existing way"), 592 new AddCommand(ds, n), new Change Command(ds, ws.way, wnew)));592 new AddCommand(ds, n), new ChangeNodesCommand(ds, ws.way, modnodes))); 593 593 } 594 594 } … … 634 634 // create extrusion 635 635 Collection<Command> cmds = new LinkedList<>(); 636 Way wnew = new Way(selectedSegment.way);636 List<Node> modNodes = selectedSegment.way.getNodes(); 637 637 boolean wayWasModified = false; 638 boolean wayWasSingleSegment = wnew.getNodesCount() == 2;638 boolean wayWasSingleSegment = modNodes.size() == 2; 639 639 int insertionPoint = selectedSegment.lowerIndex + 1; 640 640 … … 656 656 Node n1Old = selectedSegment.getFirstNode(); 657 657 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 658 wnew.addNode(insertionPoint, n1New);659 wnew.removeNode(n1Old);658 modNodes.add(insertionPoint, n1New); 659 modNodes.remove(n1Old); 660 660 wayWasModified = true; 661 661 cmds.add(new AddCommand(ds, n1New)); … … 664 664 //introduce new node 665 665 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 666 wnew.addNode(insertionPoint, n1New);666 modNodes.add(insertionPoint, n1New); 667 667 wayWasModified = true; 668 668 insertionPoint++; … … 686 686 Node n2Old = selectedSegment.getSecondNode(); 687 687 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 688 wnew.addNode(insertionPoint, n2New);689 wnew.removeNode(n2Old);688 modNodes.add(insertionPoint, n2New); 689 modNodes.remove(n2Old); 690 690 wayWasModified = true; 691 691 cmds.add(new AddCommand(ds, n2New)); … … 694 694 //introduce new node 695 695 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 696 wnew.addNode(insertionPoint, n2New);696 modNodes.add(insertionPoint, n2New); 697 697 wayWasModified = true; 698 698 cmds.add(new AddCommand(ds, n2New)); … … 702 702 //the way was a single segment, close the way 703 703 if (wayWasSingleSegment) { 704 wnew.addNode(selectedSegment.getFirstNode());704 modNodes.add(modNodes.get(0)); 705 705 wayWasModified = true; 706 706 } 707 707 if (wayWasModified) { 708 708 // we only need to change the way if its node list was really modified 709 cmds.add(new Change Command(selectedSegment.way, wnew));709 cmds.add(new ChangeNodesCommand(selectedSegment.way, modNodes)); 710 710 } 711 711 Command c = new SequenceCommand(tr("Extrude Way"), cmds); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r17110 r17141 24 24 25 25 import org.openstreetmap.josm.command.AddCommand; 26 import org.openstreetmap.josm.command.Change Command;26 import org.openstreetmap.josm.command.ChangeNodesCommand; 27 27 import org.openstreetmap.josm.command.Command; 28 28 import org.openstreetmap.josm.command.DeleteCommand; … … 461 461 for (WaySegment virtualSegment : virtualSegments) { 462 462 Way w = virtualSegment.way; 463 Way wnew = new Way(w);464 wnew.addNode(virtualSegment.lowerIndex + 1, virtualNode);465 virtualCmds.add(new Change Command(w, wnew));463 List<Node> modNodes = w.getNodes(); 464 modNodes.add(virtualSegment.lowerIndex + 1, virtualNode); 465 virtualCmds.add(new ChangeNodesCommand(w, modNodes)); 466 466 } 467 467 … … 481 481 if (referrersCount != 1 || referrerWayCount != 1) { 482 482 // detach node from way 483 final Way newWay = new Way(targetWay); 484 final List<Node> nodes = newWay.getNodes(); 483 final List<Node> nodes = targetWay.getNodes(); 485 484 nodes.remove(candidateNode); 486 newWay.setNodes(nodes);487 485 if (nodes.size() < 2) { 488 486 final Command deleteCmd = DeleteCommand.delete(Collections.singleton(targetWay), true); … … 490 488 UndoRedoHandler.getInstance().add(deleteCmd); 491 489 } 492 newWay.setNodes(null);493 490 } else { 494 UndoRedoHandler.getInstance().add(new Change Command(targetWay, newWay));491 UndoRedoHandler.getInstance().add(new ChangeNodesCommand(targetWay, nodes)); 495 492 } 496 493 } else if (candidateNode.isTagged()) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicatedWayNodes.java
r11129 r17141 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.ArrayList; 6 7 import java.util.Collections; 7 8 import java.util.Iterator; 9 import java.util.List; 8 10 9 import org.openstreetmap.josm.command.Change Command;11 import org.openstreetmap.josm.command.ChangeNodesCommand; 10 12 import org.openstreetmap.josm.command.Command; 11 13 import org.openstreetmap.josm.data.osm.Node; … … 59 61 if (it.hasNext()) { 60 62 Way w = (Way) it.next(); 61 Way wnew = new Way(w);62 wnew.setNodes(null);63 63 Node lastN = null; 64 List<Node> modNodes = new ArrayList<>(); 64 65 for (Node n : w.getNodes()) { 65 if (lastN == null) { 66 wnew.addNode(n); 67 } else if (n == lastN) { 68 // Skip this node 69 } else { 70 wnew.addNode(n); 66 if (n != lastN) { 67 modNodes.add(n); 71 68 } 72 69 lastN = n; 73 70 } 74 if ( wnew.getNodesCount() < 2)71 if (modNodes.size() < 2) 75 72 // Empty way, delete 76 73 return deletePrimitivesIfNeeded(Collections.singleton(w)); 77 74 else 78 return new Change Command(w, wnew);75 return new ChangeNodesCommand(w, modNodes); 79 76 } 80 77 return null; -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r16436 r17141 22 22 23 23 import org.openstreetmap.josm.command.AddCommand; 24 import org.openstreetmap.josm.command.Change Command;24 import org.openstreetmap.josm.command.ChangeNodesCommand; 25 25 import org.openstreetmap.josm.command.Command; 26 26 import org.openstreetmap.josm.data.coor.EastNorth; … … 231 231 232 232 for (int pos = 0; pos < ways.size(); pos++) { 233 if (!changedWays[pos]) { 234 continue; 235 } 236 237 Way way = ways.get(pos); 238 Way newWay = new Way(way); 239 newWay.setNodes(newNodes[pos]); 240 241 cmds.add(new ChangeCommand(dataset, way, newWay)); 233 if (changedWays[pos]) { 234 cmds.add(new ChangeNodesCommand(dataset, ways.get(pos), newNodes[pos])); 235 } 242 236 } 243 237
Note:
See TracChangeset
for help on using the changeset viewer.