Changeset 1596 in josm for trunk/src/org
- Timestamp:
- 2009-05-18T00:07:01+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r1439 r1596 112 112 return false; 113 113 } 114 115 public RelationMember firstMember() { 116 return (members.size() == 0) ? null : members.get(0); 117 } 118 public RelationMember lastMember() { 119 return (members.size() == 0) ? null : members.get(members.size() -1); 120 } 114 121 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationEditor.java
r1554 r1596 37 37 import org.openstreetmap.josm.data.osm.DataSet; 38 38 import org.openstreetmap.josm.data.osm.DataSource; 39 import org.openstreetmap.josm.data.osm.Node; 39 40 import org.openstreetmap.josm.data.osm.OsmPrimitive; 40 41 import org.openstreetmap.josm.data.osm.Relation; 41 42 import org.openstreetmap.josm.data.osm.RelationMember; 43 import org.openstreetmap.josm.data.osm.Way; 42 44 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 43 45 import org.openstreetmap.josm.gui.ExtendedDialog; … … 195 197 // setting up the member table 196 198 197 memberData.setColumnIdentifiers(new String[]{tr("Role"),tr("Occupied By") });199 memberData.setColumnIdentifiers(new String[]{tr("Role"),tr("Occupied By"), tr("linked")}); 198 200 memberTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 199 201 memberTable.getColumnModel().getColumn(1).setCellRenderer(new OsmPrimitivRenderer()); … … 366 368 367 369 memberData.setRowCount(0); 368 for (RelationMember em : clone.members) { 369 memberData.addRow(new Object[]{em.role, em.member}); 370 for (int i=0; i<clone.members.size(); i++) { 371 372 // this whole section is aimed at finding out whether the 373 // relation member is "linked" with the next, i.e. whether 374 // (if both are ways) these ways are connected. It should 375 // really produce a much more beautiful output (with a linkage 376 // symbol somehow places betweeen the two member lines!), and 377 // it should cache results, so... FIXME ;-) 378 379 RelationMember em = clone.members.get(i); 380 boolean linked = false; 381 Node n1 = null; 382 Node n2 = null; 383 RelationMember m = em; 384 while (true) { 385 if (m.member instanceof Way) { 386 n1 = ((Way) m.member).lastNode(); 387 break; 388 } else if (em.member instanceof Relation) { 389 m = ((Relation)m.member).lastMember(); 390 } else { 391 break; 392 } 393 } 394 if (i<clone.members.size()-1) { 395 m = clone.members.get(i+1); 396 while (true) { 397 if (m.member instanceof Way) { 398 n2 = ((Way) (m.member)).firstNode(); 399 break; 400 } else if (em.member instanceof Relation) { 401 m = ((Relation)(m.member)).firstMember(); 402 } else { 403 break; 404 } 405 } 406 } 407 linked = (n1 != null) && n1.equals(n2); 408 409 // end of section to determine linkedness. 410 411 memberData.addRow(new Object[]{em.role, em.member, linked ? tr("yes") : tr("no")}); 370 412 } 371 413 status.setText(tr("Members: {0}", clone.members.size()));
Note:
See TracChangeset
for help on using the changeset viewer.