Changeset 343 in josm for trunk/src/org/openstreetmap/josm/data/osm/visitor/NameVisitor.java
- Timestamp:
- 2007-10-07T13:20:27+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/NameVisitor.java
r298 r343 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 3 2 package org.openstreetmap.josm.data.osm.visitor; 4 3 … … 13 12 14 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.osm.Relation; 15 15 import org.openstreetmap.josm.data.osm.Node; 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.osm.Segment;18 17 import org.openstreetmap.josm.data.osm.Way; 19 18 import org.openstreetmap.josm.tools.ImageProvider; … … 41 40 42 41 /** 43 * If the segment has a key named "name", its value is displayed.44 * Otherwise, if it has "id", this is used. If none of these available,45 * "(x1,y1) -> (x2,y2)" is displayed with the nodes coordinates.46 */47 public void visit(Segment ls) {48 name = ls.get("name");49 if (name == null) {50 if (ls.incomplete)51 name = ls.id == 0 ? tr("new") : ls.id+" ("+tr("unknown")+")";52 else53 name = (ls.id==0?"":ls.id+" ")+"("+ls.from.coor.lat()+","+ls.from.coor.lon()+") -> ("+ls.to.coor.lat()+","+ls.to.coor.lon()+")";54 }55 addId(ls);56 icon = ImageProvider.get("data", "segment");57 trn("segment", "segments", 0); // no marktrn available58 className = "segment";59 }60 61 /**62 42 * If the node has a name-key or id-key, this is displayed. If not, (lat,lon) 63 43 * is displayed. … … 81 61 if (name == null) name = w.get("ref"); 82 62 if (name == null) { 83 AllNodesVisitor.getAllNodes(w.segments);84 Set<Node> nodes = new HashSet<Node>();85 for (Segment ls : w.segments) {86 if (!ls.incomplete) {87 nodes.add(ls.from);88 nodes.add(ls.to);89 }90 }91 63 String what = (w.get("highway") != null) ? "highway " : (w.get("railway") != null) ? "railway " : (w.get("waterway") != null) ? "waterway " : ""; 92 name = what + trn("{0} node", "{0} nodes", nodes.size(),nodes.size());64 name = what + trn("{0} node", "{0} nodes", w.nodes.size(), w.nodes.size()); 93 65 } 94 if (w.isIncomplete())95 name += " ("+tr("incomplete")+")";96 66 addId(w); 97 67 icon = ImageProvider.get("data", "way"); 98 68 trn("way", "ways", 0); // no marktrn available 99 69 className = "way"; 70 } 71 72 /** 73 */ 74 public void visit(Relation e) { 75 name = e.get("type"); 76 // FIXME add names of members 77 if (name == null) 78 name = "relation"; 79 addId(e); 80 icon = ImageProvider.get("data", "relation"); 81 trn("relation", "relations", 0); // no marktrn available 82 className = "relation"; 100 83 } 101 84
Note:
See TracChangeset
for help on using the changeset viewer.