Changeset 1898 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-08-03T21:18:50+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r1862 r1898 12 12 13 13 import javax.swing.JOptionPane; 14 import javax.swing.text.html.Option;15 14 16 15 import org.openstreetmap.josm.Main; … … 96 95 // Otherwise, two segments could be turned into same direction and intersection would fail. 97 96 // Or changes of shape would be too serious. 98 for (int i1=0; i1 < way. nodes.size()-1; i1++) {99 int i2 = (i1+1) % (way. nodes.size()-1);100 int i3 = (i1+2) % (way. nodes.size()-1);101 double angle1 =Math.abs(way. nodes.get(i1).getEastNorth().heading(way.nodes.get(i2).getEastNorth()));102 double angle2 = Math.abs(way. nodes.get(i2).getEastNorth().heading(way.nodes.get(i3).getEastNorth()));97 for (int i1=0; i1 < way.getNodesCount()-1; i1++) { 98 int i2 = (i1+1) % (way.getNodesCount()-1); 99 int i3 = (i1+2) % (way.getNodesCount()-1); 100 double angle1 =Math.abs(way.getNode(i1).getEastNorth().heading(way.getNode(i2).getEastNorth())); 101 double angle2 = Math.abs(way.getNode(i2).getEastNorth().heading(way.getNode(i3).getEastNorth())); 103 102 double delta = Math.abs(angle2 - angle1); 104 103 while(delta > Math.PI) { … … 162 161 163 162 Way way = (Way)osm; 164 int nodes = way. nodes.size();163 int nodes = way.getNodesCount(); 165 164 int sides = nodes - 1; 166 165 // Copy necessary data into a more suitable data structure 167 166 EastNorth en[] = new EastNorth[sides]; 168 167 for (int i=0; i < sides; i++) { 169 en[i] = new EastNorth(way. nodes.get(i).getEastNorth().east(), way.nodes.get(i).getEastNorth().north());168 en[i] = new EastNorth(way.getNode(i).getEastNorth().east(), way.getNode(i).getEastNorth().north()); 170 169 } 171 170 … … 178 177 double weights[] = new double[sides]; 179 178 for (int i=0; i < sides; i++) { 180 headings[i] = normalize_angle(way. nodes.get(i).getEastNorth().heading(way.nodes.get(i+1).getEastNorth()));181 weights[i] = way. nodes.get(i).getEastNorth().distance(way.nodes.get(i+1).getEastNorth());179 headings[i] = normalize_angle(way.getNode(i).getEastNorth().heading(way.getNode(i+1).getEastNorth())); 180 weights[i] = way.getNode(i).getEastNorth().distance(way.getNode(i+1).getEastNorth()); 182 181 } 183 182 … … 270 269 B.north() + q * (A.north() - B.north())); 271 270 272 Node n = way. nodes.get(i2);271 Node n = way.getNode(i2); 273 272 274 273 LatLon ill = Main.proj.eastNorth2latlon(intersection); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r1862 r1898 285 285 } 286 286 newWays.add(wayToAdd); 287 wayToAdd. nodes.addAll(chunkIt.next());287 wayToAdd.setNodes(chunkIt.next()); 288 288 commandList.add(new AddCommand(wayToAdd)); 289 289 //Main.debug("wayToAdd: " + wayToAdd); -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r1883 r1898 72 72 * the current dataset 73 73 * @exception IllegalStateException thrown if there is no current dataset 74 * 74 * 75 75 */ 76 76 public void updatePrimitive(long id) throws IllegalStateException{ … … 171 171 } else if (primitive instanceof Way) { 172 172 Way way = (Way)primitive; 173 for (Node node: way. nodes) {173 for (Node node: way.getNodes()) { 174 174 if (node.id > 0) { 175 175 reader.append(node); -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r1858 r1898 391 391 for (int i : is) { 392 392 segSet.add( 393 Pair.sort(new Pair<Node,Node>(w. nodes.get(i), w.nodes.get(i+1))));393 Pair.sort(new Pair<Node,Node>(w.getNode(i), w.getNode(i+1)))); 394 394 } 395 395 for (int i : is) { … … 478 478 if(way != null) { 479 479 int nodeCount=0; 480 for (Node p : way. nodes)480 for (Node p : way.getNodes()) 481 481 if(p.equals(n0)) { 482 482 nodeCount++; … … 503 503 504 504 // Connected to a node that's already in the way 505 if(way. nodes.contains(n)) {505 if(way.getNodes().contains(n)) { 506 506 wayIsFinished = true; 507 507 selection.clear(); … … 509 509 510 510 // Add new node to way 511 if (way. nodes.get(way.nodes.size() - 1) == n0) {511 if (way.getNode(way.getNodesCount() - 1) == n0) { 512 512 way.addNode(n); 513 513 } else { … … 571 571 */ 572 572 private boolean isSelfContainedWay(Way selectedWay, Node currentNode, Node targetNode) { 573 if(selectedWay != null && selectedWay.nodes != null) {574 int posn0 = selectedWay. nodes.indexOf(currentNode);573 if(selectedWay != null) { 574 int posn0 = selectedWay.getNodes().indexOf(currentNode); 575 575 if( posn0 != -1 && // n0 is part of way 576 (posn0 >= 1 && targetNode.equals(selectedWay.nodes.get(posn0-1))) || // previous node577 (posn0 < selectedWay. nodes.size()-1) && targetNode.equals(selectedWay.nodes.get(posn0+1))) { // next node576 (posn0 >= 1 && targetNode.equals(selectedWay.getNode(posn0-1))) || // previous node 577 (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) { // next node 578 578 getCurrentDataSet().setSelected(targetNode); 579 579 DataSet.fireSelectionChanged(getCurrentDataSet().getSelected()); … … 714 714 if (selectedWay.isFirstLastNode(lastUsedNode)) { 715 715 currentBaseNode = lastUsedNode; 716 if (lastUsedNode == selectedWay. nodes.get(selectedWay.nodes.size()-1) && selectedWay.nodes.size() > 1) {717 previousNode = selectedWay. nodes.get(selectedWay.nodes.size()-2);716 if (lastUsedNode == selectedWay.getNode(selectedWay.getNodesCount()-1) && selectedWay.getNodesCount() > 1) { 717 previousNode = selectedWay.getNode(selectedWay.getNodesCount()-2); 718 718 } 719 719 } … … 721 721 currentBaseNode = selectedNode; 722 722 } else { 723 if (selectedNode == selectedWay. nodes.get(0) || selectedNode == selectedWay.nodes.get(selectedWay.nodes.size()-1)) {723 if (selectedNode == selectedWay.getNode(0) || selectedNode == selectedWay.getNode(selectedWay.getNodesCount()-1)) { 724 724 currentBaseNode = selectedNode; 725 725 } … … 763 763 Way way = null; 764 764 for (Way w : getCurrentDataSet().ways) { 765 if (w.deleted || w.incomplete || w. nodes.size() < 1) {765 if (w.deleted || w.incomplete || w.getNodesCount() < 1) { 766 766 continue; 767 767 } 768 Node firstNode = w. nodes.get(0);769 Node lastNode = w. nodes.get(w.nodes.size() - 1);768 Node firstNode = w.getNode(0); 769 Node lastNode = w.getNode(w.getNodesCount() - 1); 770 770 if ((firstNode == n || lastNode == n) && (firstNode != lastNode)) { 771 771 if (way != null) … … 966 966 if (getCurrentDataSet() != null && getCurrentDataSet().getSelectedWays().size() > 0 && !wayIsFinished && !alt) { 967 967 Way w = (Way) getCurrentDataSet().getSelectedWays().iterator().next(); 968 for (Node m : w. nodes) {968 for (Node m : w.getNodes()) { 969 969 if (m.equals(mouseOnExistingNode) || mouseOnExistingWays.contains(w)) { 970 970 rv += " " + tr("Finish drawing."); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r1814 r1898 28 28 import org.openstreetmap.josm.gui.MapFrame; 29 29 import org.openstreetmap.josm.gui.MapView; 30 import org.openstreetmap.josm.gui.layer.Layer; 30 31 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 31 import org.openstreetmap.josm.gui.layer.Layer;32 32 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 33 33 import org.openstreetmap.josm.tools.ImageProvider; … … 152 152 public void paint(Graphics g, MapView mv) { 153 153 if (selectedSegment != null) { 154 Node n1 = selectedSegment.way. nodes.get(selectedSegment.lowerIndex);155 Node n2 = selectedSegment.way. nodes.get(selectedSegment.lowerIndex + 1);154 Node n1 = selectedSegment.way.getNode(selectedSegment.lowerIndex); 155 Node n2 = selectedSegment.way.getNode(selectedSegment.lowerIndex + 1); 156 156 157 157 EastNorth en1 = n1.getEastNorth(); … … 233 233 if (selectedSegment == null) return; 234 234 if (mousePos.distance(initialMousePos) > 10) { 235 Node n1 = selectedSegment.way. nodes.get(selectedSegment.lowerIndex);236 Node n2 = selectedSegment.way. nodes.get(selectedSegment.lowerIndex+1);235 Node n1 = selectedSegment.way.getNode(selectedSegment.lowerIndex); 236 Node n2 = selectedSegment.way.getNode(selectedSegment.lowerIndex+1); 237 237 EastNorth en3 = n2.getEastNorth().add(xoff, yoff); 238 238 Node n3 = new Node(Main.proj.eastNorth2latlon(en3)); … … 242 242 wnew.addNode(selectedSegment.lowerIndex+1, n3); 243 243 wnew.addNode(selectedSegment.lowerIndex+1, n4); 244 if (wnew. nodes.size() == 4) {244 if (wnew.getNodesCount() == 4) { 245 245 wnew.addNode(n1); 246 246 } -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r1856 r1898 67 67 * Constructor for a single data item. Use the collection constructor to delete multiple 68 68 * objects. 69 * 69 * 70 70 * @param layer the layer context for deleting this primitive 71 71 * @param data the primitive to delete … … 79 79 * Constructor for a collection of data to be deleted in the context of 80 80 * a specific layer 81 * 81 * 82 82 * @param layer the layer context for deleting these primitives 83 83 * @param data the primitives to delete … … 137 137 /** 138 138 * Delete the primitives and everything they reference. 139 * 139 * 140 140 * If a node is deleted, the node and all ways and relations the node is part of are deleted as 141 141 * well. 142 * 142 * 143 143 * If a way is deleted, all relations the way is member of are also deleted. 144 * 144 * 145 145 * If a way is deleted, only the way and no nodes are deleted. 146 * 146 * 147 147 * @param selection The list of all object to be deleted. 148 148 * @return command A command to perform the deletions, or null of there is nothing to delete. … … 204 204 continue; 205 205 } 206 for (Node n : ((Way) osm). nodes) {206 for (Node n : ((Way) osm).getNodes()) { 207 207 if (n.isTagged()) { 208 208 continue; … … 221 221 /** 222 222 * Try to delete all given primitives. 223 * 223 * 224 224 * If a node is used by a way, it's removed from that way. If a node or a way is used by a 225 225 * relation, inform the user and do not delete. 226 * 226 * 227 227 * If this would cause ways with less than 2 nodes to be created, delete these ways instead. If 228 228 * they are part of a relation, inform the user and do not delete. 229 * 229 * 230 230 * @param layer the {@see OsmDataLayer} in whose context a primitive the primitives are deleted 231 231 * @param selection The objects to delete. … … 279 279 Way wnew = new Way(w); 280 280 wnew.removeNodes(primitivesToDelete); 281 if (wnew. nodes.size() < 2) {281 if (wnew.getNodesCount() < 2) { 282 282 primitivesToDelete.add(w); 283 283 … … 347 347 } 348 348 Way wnew = new Way(w); 349 ArrayList<Node> nodesToStrip = new ArrayList<Node>();349 List<Node> nodesToKeep = new ArrayList<Node>(); 350 350 // lookup new nodes which have been added to the set of deleted 351 351 // nodes ... 352 for (Node n : wnew. nodes) {353 if (n.id == 0 &&primitivesToDelete.contains(n)) {354 nodesTo Strip.add(n);352 for (Node n : wnew.getNodes()) { 353 if (n.id != 0 || !primitivesToDelete.contains(n)) { 354 nodesToKeep.add(n); 355 355 } 356 356 } 357 357 // .. and remove them from the way 358 358 // 359 wnew. nodes.removeAll(nodesToStrip);360 if ( !nodesToStrip.isEmpty()) {359 wnew.setNodes(nodesToKeep); 360 if (nodesToKeep.size() < w.getNodesCount()) { 361 361 cmds.add(new ChangeCommand(w, wnew)); 362 362 } … … 373 373 List<Node> n1 = new ArrayList<Node>(), n2 = new ArrayList<Node>(); 374 374 375 n1.addAll(ws.way. nodes.subList(0, ws.lowerIndex + 1));376 n2.addAll(ws.way. nodes.subList(ws.lowerIndex + 1, ws.way.nodes.size()));375 n1.addAll(ws.way.getNodes().subList(0, ws.lowerIndex + 1)); 376 n2.addAll(ws.way.getNodes().subList(ws.lowerIndex + 1, ws.way.getNodesCount())); 377 377 378 378 if (n1.size() < 2 && n2.size() < 2) … … 380 380 381 381 Way wnew = new Way(ws.way); 382 wnew.nodes.clear();383 382 384 383 if (n1.size() < 2) { 385 wnew. nodes.addAll(n2);384 wnew.setNodes(n2); 386 385 return new ChangeCommand(ws.way, wnew); 387 386 } else if (n2.size() < 2) { 388 wnew. nodes.addAll(n1);387 wnew.setNodes(n1); 389 388 return new ChangeCommand(ws.way, wnew); 390 389 } else { 391 390 Collection<Command> cmds = new LinkedList<Command>(); 392 391 393 wnew. nodes.addAll(n1);392 wnew.setNodes(n1); 394 393 cmds.add(new ChangeCommand(ws.way, wnew)); 395 394 … … 398 397 wnew2.keys = new HashMap<String, String>(wnew.keys); 399 398 } 400 wnew2. nodes.addAll(n2);399 wnew2.setNodes(n2); 401 400 cmds.add(new AddCommand(wnew2)); 402 401 … … 408 407 * Check whether user is about to delete data outside of the download area. Request confirmation 409 408 * if he is. 410 * 409 * 411 410 * @param layer the layer in whose context data is deleted 412 411 * @param primitivesToDelete the primitives to delete -
trunk/src/org/openstreetmap/josm/command/PurgePrimitivesCommand.java
r1862 r1898 190 190 // remember it on the "hive" 191 191 // 192 if (w. nodes.size() < 2) {192 if (w.getNodesCount() < 2) { 193 193 System.out.println(tr("Warning: Purging way {0} because number of nodes dropped below 2. Current is {1}", 194 w.id,w. nodes.size()));194 w.id,w.getNodesCount())); 195 195 if (!hive.contains(w)) { 196 196 hive.add(w); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1862 r1898 344 344 int orderNumber = 0; 345 345 lastN = null; 346 for(Node n : w. nodes)346 for(Node n : w.getNodes()) 347 347 { 348 348 if(lastN != null) … … 429 429 { 430 430 w = new Way(w); 431 w.nodes.clear(); 432 w.nodes.addAll(n); 431 w.setNodes(n); 433 432 w.selected = selected; 434 433 } … … 644 643 } else { 645 644 //System.out.println("From way heading towards via"); 646 fromNode = fromWay.getNode(fromWay. nodes.size()-2);645 fromNode = fromWay.getNode(fromWay.getNodesCount()-2); 647 646 } 648 647 … … 936 935 Polygon polygon = new Polygon(); 937 936 938 for (Node n : wInner. nodes)937 for (Node n : wInner.getNodes()) 939 938 { 940 939 Point pInner = nc.getPoint(n); … … 943 942 if(!wInner.isClosed()) 944 943 { 945 Point pInner = nc.getPoint(wInner. nodes.get(0));944 Point pInner = nc.getPoint(wInner.getNode(0)); 946 945 polygon.addPoint(pInner.x,pInner.y); 947 946 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r1891 r1898 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.ArrayList; 6 7 import java.util.HashMap; 8 import java.util.List; 7 9 8 10 import org.openstreetmap.josm.data.osm.DataSet; … … 22 24 * incomplete {@see OsmPrimitive}s in the "hull", if they are not themselves present in the 23 25 * original collection. 24 * 26 * 25 27 */ 26 28 public class MergeSourceBuildingVisitor extends AbstractVisitor { … … 33 35 * the currently selected primitives in the dataset <code>selectionBase</code>, 34 36 * i.e. from {@see DataSet#getSelected()}. 35 * 37 * 36 38 * @param selectionBase the dataset. Must not be null. 37 39 * @exception IllegalArgumentException thrown if selectionBase is null 38 * 40 * 39 41 */ 40 42 public MergeSourceBuildingVisitor(DataSet selectionBase) throws IllegalArgumentException { … … 48 50 /** 49 51 * Remebers a node in the "hull" 50 * 52 * 51 53 * @param n the node 52 54 */ … … 60 62 /** 61 63 * remembers a way in the hull 62 * 64 * 63 65 * @param w the way 64 66 */ … … 67 69 return; 68 70 Way clone = new Way(w); 69 clone.nodes.clear(); 70 for (Node n: w.nodes) { 71 clone.nodes.add((Node)mappedPrimitives.get(n)); 72 } 71 List<Node> newNodes = new ArrayList<Node>(); 72 for (Node n: w.getNodes()) { 73 newNodes.add((Node)mappedPrimitives.get(n)); 74 } 75 clone.setNodes(newNodes); 73 76 mappedPrimitives.put(w, clone); 74 77 } … … 76 79 /** 77 80 * Remembers a relation in the hull 78 * 81 * 79 82 * @param r the relation 80 83 */ … … 160 163 // remember all nodes this way refers to ... 161 164 // 162 for (Node n: w. nodes) {165 for (Node n: w.getNodes()) { 163 166 if (! isAlreadyRemembered(n)) { 164 167 n.visit(this); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r1862 r1898 319 319 } 320 320 321 Iterator<Node> it = w. nodes.iterator();321 Iterator<Node> it = w.getNodes().iterator(); 322 322 if (it.hasNext()) { 323 323 Point lastP = nc.getPoint(it.next()); -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r1823 r1898 319 319 Node lastN = null; 320 320 int i = -2; 321 for (Node n : w. nodes) {321 for (Node n : w.getNodes()) { 322 322 i++; 323 323 if (n.deleted || n.incomplete) { … … 437 437 } 438 438 Node lastN = null; 439 for (Node n : w. nodes) {439 for (Node n : w.getNodes()) { 440 440 if (n.deleted || n.incomplete) { 441 441 continue; -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r1814 r1898 286 286 // ways 287 287 for (Way w : nc.getCurrentDataSet().ways) { 288 if (w.deleted || w. nodes.isEmpty()|| w.incomplete)288 if (w.deleted || w.getNodesCount() == 0 || w.incomplete) 289 289 continue; 290 290 if (alt) { -
trunk/src/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModel.java
r1655 r1898 23 23 * Populates the model with the nodes in the two {@see Way}s <code>my</code> and 24 24 * <code>their</code>. 25 * 25 * 26 26 * @param my my way (i.e. the way in the local dataset) 27 27 * @param their their way (i.e. the way in the server dataset) … … 37 37 getMyEntries().clear(); 38 38 getTheirEntries().clear(); 39 for (Node n : my. nodes) {39 for (Node n : my.getNodes()) { 40 40 getMyEntries().add(n); 41 41 } 42 for (Node n : their. nodes) {42 for (Node n : their.getNodes()) { 43 43 getTheirEntries().add(n); 44 44 } … … 55 55 /** 56 56 * Builds the command to resolve conflicts in the node list of a way 57 * 57 * 58 58 * @param my my way. Must not be null. 59 59 * @param their their way. Must not be null -
trunk/src/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModel.java
r1847 r1898 533 533 534 534 HashMap<Long,OsmPrimitive> candidates = new HashMap<Long,OsmPrimitive>(); 535 for (Node n : way. nodes) {535 for (Node n : way.getNodes()) { 536 536 if (n.id > 0 && ! candidates.values().contains(n)) { 537 537 candidates.put(n.id, n); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r1814 r1898 55 55 * This dialog displays the {@see ConflictCollection} of the active {@see OsmDataLayer} in a toggle 56 56 * dialog on the right of the main frame. 57 * 57 * 58 58 */ 59 59 public final class ConflictDialog extends ToggleDialog implements LayerChangeListener, IConflictListener, SelectionChangedListener{ … … 128 128 /** 129 129 * Launches a conflict resolution dialog for the first selected conflict 130 * 130 * 131 131 */ 132 132 private final void resolve() { … … 180 180 public void visit(Way w) { 181 181 Node lastN = null; 182 for (Node n : w. nodes) {182 for (Node n : w.getNodes()) { 183 183 if (lastN == null) { 184 184 lastN = n; … … 206 206 /** 207 207 * replies the conflict collection currently held by this dialog; may be null 208 * 208 * 209 209 * @return the conflict collection currently held by this dialog; may be null 210 210 */ -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r1894 r1898 65 65 import org.openstreetmap.josm.tools.ImageProvider; 66 66 67 import sun.security.action.GetLongAction;68 69 67 /** 70 68 * A layer holding data from a specific dataset. … … 321 319 * Cleanup the layer after save to disk. Just marks the layer as unmodified. 322 320 * Leaves the undo/redo stack unchanged. 323 * 321 * 324 322 */ 325 323 public void cleanupAfterSaveToDisk() { … … 470 468 471 469 ArrayList<WayPoint> trkseg = null; 472 for (Node n : w. nodes) {470 for (Node n : w.getNodes()) { 473 471 if (n.incomplete || n.deleted) { 474 472 trkseg = null; -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r1881 r1898 183 183 if (way == null) return this; 184 184 if (way.id == 0) return this; 185 for (Node node: way. nodes) {185 for (Node node: way.getNodes()) { 186 186 if (node.id > 0) { 187 187 remember(node.id, OsmPrimitiveType.NODE); -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r1843 r1898 117 117 } else { 118 118 out.println(">"); 119 for (Node n : w. nodes) {119 for (Node n : w.getNodes()) { 120 120 out.println(" <nd ref='"+getUsedId(n)+"' />"); 121 121 }
Note:
See TracChangeset
for help on using the changeset viewer.