Changeset 755 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2008-08-07T10:03:52+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r753 r755 88 88 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 89 89 SearchCompiler.Match matcher = SearchCompiler.compile(search, caseSensitive); 90 for (OsmPrimitive osm : Main.ds.allNonDeleted PhysicalPrimitives()) {90 for (OsmPrimitive osm : Main.ds.allNonDeletedCompletePrimitives()) { 91 91 if (mode == SearchMode.replace) { 92 92 if (matcher.match(osm)) -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r630 r755 58 58 if (data.size() == 1) { 59 59 data.iterator().next().visit(v); 60 return new DefaultMutableTreeNode(new JLabel(tr("Delete ")+" "+tr(v.className)+" "+v.name, v.icon, JLabel.HORIZONTAL));60 return new DefaultMutableTreeNode(new JLabel(tr("Delete {1} {0}", v.name, tr(v.className)), v.icon, JLabel.HORIZONTAL)); 61 61 } 62 62 63 63 String cname = null; 64 String cnamem = null; 64 65 for (OsmPrimitive osm : data) { 65 66 osm.visit(v); 66 67 if (cname == null) 68 { 67 69 cname = v.className; 70 cnamem = v.classNamePlural; 71 } 68 72 else if (!cname.equals(v.className)) 73 { 69 74 cname = "object"; 75 cnamem = trn("object", "objects", 2); 76 } 70 77 } 71 78 DefaultMutableTreeNode root = new DefaultMutableTreeNode(new JLabel( 72 tr("Delete ")+" "+data.size()+" "+trn(cname, cname+"s", data.size()), ImageProvider.get("data", cname), JLabel.HORIZONTAL));79 tr("Delete {0} {1}", data.size(), trn(cname, cnamem, data.size())), ImageProvider.get("data", cname), JLabel.HORIZONTAL)); 73 80 for (OsmPrimitive osm : data) { 74 81 osm.visit(v); -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r753 r755 8 8 import java.util.Collection; 9 9 import java.util.Collections; 10 import java.util.Comparator; 10 11 import java.util.HashSet; 12 import java.util.HashMap; 11 13 import java.util.LinkedList; 12 14 import java.util.List; … … 78 80 for (OsmPrimitive osm : allPrimitives()) 79 81 if (!osm.deleted) 82 o.add(osm); 83 return o; 84 } 85 86 public Collection<OsmPrimitive> allNonDeletedCompletePrimitives() { 87 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 88 for (OsmPrimitive osm : allPrimitives()) 89 if (!osm.deleted && !osm.incomplete) 80 90 o.add(osm); 81 91 return o; … … 230 240 231 241 } 242 243 // Search für Relation wieder erlauben. 244 public static OsmPrimitive[] sort(Collection<? extends OsmPrimitive> list) { 245 OsmPrimitive[] selArr = new OsmPrimitive[list.size()]; 246 final HashMap<Object, String> h = new HashMap<Object, String>(); 247 selArr = list.toArray(selArr); 248 Arrays.sort(selArr, new Comparator<OsmPrimitive>() { 249 public int compare(OsmPrimitive a, OsmPrimitive b) 250 { 251 if(a.getClass() == b.getClass()) 252 { 253 String as = h.get(a); 254 if(as == null) 255 { 256 as = a.getName(); 257 h.put(a, as); 258 } 259 String bs = h.get(b); 260 if(bs == null) 261 { 262 bs = b.getName(); 263 h.put(b, bs); 264 } 265 int res = as.compareTo(bs); 266 if(res != 0) 267 return res; 268 } 269 return a.compareTo(b); 270 } 271 }); 272 return selArr; 273 } 232 274 } -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r643 r755 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 import java.text.DecimalFormat; 8 import java.text.NumberFormat; 3 9 4 10 import org.openstreetmap.josm.Main; … … 67 73 public int compareTo(OsmPrimitive o) { 68 74 return o instanceof Node ? Long.valueOf(id).compareTo(o.id) : 1; 69 } 75 } 76 77 public String getName() { 78 String name; 79 if (incomplete) { 80 name = tr("incomplete"); 81 } else { 82 NumberFormat latLonFormat = new DecimalFormat("###0.0000000"); 83 84 name = get("name"); 85 if (name == null) 86 name = id == 0 ? "" : ""+id; 87 name += " ("+latLonFormat.format(coor.lat())+", "+latLonFormat.format(coor.lon())+")"; 88 } 89 return name; 90 } 70 91 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r655 r755 217 217 checkTagged(); 218 218 checkDirectionTagged(); 219 } 220 221 public String getName() { 222 return null; 219 223 } 220 224 -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r627 r755 1 1 package org.openstreetmap.josm.data.osm; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.trn; 2 5 3 6 import java.util.ArrayList; … … 66 69 public int compareTo(OsmPrimitive o) { 67 70 return o instanceof Relation ? Long.valueOf(id).compareTo(o.id) : -1; 68 } 69 71 } 72 73 public String getName() { 74 String name; 75 if (incomplete) { 76 name = tr("incomplete"); 77 } else { 78 name = get("type"); 79 // FIXME add names of members 80 if (name == null) 81 name = tr("relation"); 82 83 name += " ("; 84 String nameTag = get("name"); 85 if (nameTag == null) nameTag = get("ref"); 86 if (nameTag != null) name += "\"" + nameTag + "\", "; 87 int mbno = members.size(); 88 name += trn("{0} member", "{0} members", mbno, mbno) + ")"; 89 } 90 return name; 91 } 92 70 93 public boolean isIncomplete() { 71 94 for (RelationMember m : members) -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r627 r755 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 import java.util.HashSet; 3 8 4 9 import java.util.ArrayList; … … 87 92 88 93 public int compareTo(OsmPrimitive o) { 89 return o instanceof Way ? Long.valueOf(id).compareTo(o.id) : -1; 90 } 94 if(o instanceof Relation) 95 return 1; 96 return o instanceof Way ? Long.valueOf(id).compareTo(o.id) : -1; 97 } 98 99 public String getName() { 100 String name; 101 if (incomplete) { 102 name = tr("incomplete"); 103 } else { 104 name = get("name"); 105 if (name == null) name = get("ref"); 106 if (name == null) { 107 name = 108 (get("highway") != null) ? tr("highway") : 109 (get("railway") != null) ? tr("railway") : 110 (get("waterway") != null) ? tr("waterway") : 111 (get("landuse") != null) ? tr("landuse") : ""; 112 } 113 114 int nodesNo = new HashSet<Node>(nodes).size(); 115 name += trn(" ({0} node)", " ({0} nodes)", nodesNo, nodesNo); 116 } 117 return name; 118 } 91 119 92 120 @Deprecated -
trunk/src/org/openstreetmap/josm/data/osm/visitor/NameVisitor.java
r627 r755 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 7 import java.text.DecimalFormat;8 import java.text.NumberFormat;9 import java.util.HashSet;10 6 11 7 import javax.swing.Icon; … … 30 26 */ 31 27 public String className; 28 public String classNamePlural; 32 29 /** 33 30 * The name of this item. … … 39 36 public Icon icon; 40 37 41 /**42 * For formatting lat/lon43 */44 public static NumberFormat latLonFormat = new DecimalFormat("###0.0000000");45 46 38 /** 47 39 * If the node has a name-key or id-key, this is displayed. If not, (lat,lon) … … 49 41 */ 50 42 public void visit(Node n) { 51 if (n.incomplete) { 52 name = tr("incomplete"); 53 } else { 54 name = n.get("name"); 55 if (name == null) { 56 name = n.id == 0 ? "" : ""+n.id; 57 } 58 name += " ("+latLonFormat.format(n.coor.lat())+", "+latLonFormat.format(n.coor.lon())+")"; 59 } 43 name = n.getName(); 60 44 addId(n); 61 45 icon = ImageProvider.get("data", "node"); 62 trn("node", "nodes", 0); // no marktrn available63 46 className = "node"; 47 classNamePlural = trn("node", "nodes", 2); 64 48 } 65 49 … … 69 53 */ 70 54 public void visit(Way w) { 71 if (w.incomplete) { 72 name = tr("incomplete"); 73 } else { 74 name = w.get("name"); 75 if (name == null) name = w.get("ref"); 76 if (name == null) { 77 name = 78 (w.get("highway") != null) ? "highway" : 79 (w.get("railway") != null) ? "railway" : 80 (w.get("waterway") != null) ? "waterway" : ""; 81 } 82 83 int nodesNo = new HashSet<Node>(w.nodes).size(); 84 name += trn(" ({0} node)", " ({0} nodes)", nodesNo, nodesNo); 85 } 55 name = w.getName(); 86 56 addId(w); 87 57 icon = ImageProvider.get("data", "way"); 88 trn("way", "ways", 0); // no marktrn available89 58 className = "way"; 59 classNamePlural = trn("way", "ways", 2); 90 60 } 91 61 … … 93 63 */ 94 64 public void visit(Relation e) { 95 if (e.incomplete) { 96 name = tr("incomplete"); 97 } else { 98 name = e.get("type"); 99 // FIXME add names of members 100 if (name == null) 101 name = "relation"; 102 103 name += " ("; 104 String nameTag = e.get("name"); 105 if (nameTag == null) nameTag = e.get("ref"); 106 if (nameTag != null) name += "\"" + nameTag + "\", "; 107 int mbno = e.members.size(); 108 name += trn("{0} member", "{0} members", mbno, mbno) + ")"; 109 } 65 name = e.getName(); 110 66 addId(e); 111 67 icon = ImageProvider.get("data", "relation"); 112 trn("relation", "relations", 0); // no marktrn available113 68 className = "relation"; 69 classNamePlural = trn("relation", "relations", 2); 114 70 } 115 71 … … 121 77 private void addId(OsmPrimitive osm) { 122 78 if (Main.pref.getBoolean("osm-primitives.showid")) 123 name += " (id: "+osm.id+")";79 name += tr(" (id: {0}))", osm.id); 124 80 } 125 81 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r744 r755 21 21 import org.openstreetmap.josm.Main; 22 22 import org.openstreetmap.josm.command.DeleteCommand; 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 24 import org.openstreetmap.josm.data.osm.Relation; 24 25 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; … … 112 113 list.setSize(Main.ds.relations.size()); 113 114 int i = 0; 114 for ( Relation e : Main.ds.relations) {115 for (OsmPrimitive e : Main.ds.sort(Main.ds.relations)) { 115 116 if (!e.deleted && !e.incomplete) 116 117 list.setElementAt(e, i++); -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r751 r755 96 96 */ 97 97 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 98 if (list == null )98 if (list == null || !isVisible()) 99 99 return; // selection changed may be received in base class constructor before init 100 if (!isVisible()) 101 return; 102 OsmPrimitive[] selArr = new OsmPrimitive[newSelection.size()]; 103 selArr = newSelection.toArray(selArr); 104 Arrays.sort(selArr); 100 OsmPrimitive selArr[] = Main.ds.sort(newSelection); 105 101 list.setSize(selArr.length); 106 102 int i = 0;
Note:
See TracChangeset
for help on using the changeset viewer.