- Timestamp:
- 2009-07-25T18:37:45+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ApiPreconditionChecker.java
r1814 r1843 74 74 private boolean checkMaxNodes(Collection<OsmPrimitive> add, long maxNodes) { 75 75 for (OsmPrimitive osmPrimitive : add) { 76 if (osmPrimitive.keys == null) { 77 continue; 78 } 79 for (Entry<String,String> e : osmPrimitive.keys.entrySet()) { 76 for (Entry<String,String> e : osmPrimitive.entrySet()) { 80 77 if(e.getValue().length() > 255) { 81 78 if (osmPrimitive.deleted) { -
trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r1820 r1843 45 45 46 46 for (String key : m.keySet()) { 47 clist.add(new ChangePropertyCommand(selectionSubset, key, osm. keys.get(key)));47 clist.add(new ChangePropertyCommand(selectionSubset, key, osm.get(key))); 48 48 } 49 49 } … … 83 83 private boolean containsSameKeysWithDifferentValues(Collection<? extends OsmPrimitive> osms) { 84 84 Map<String,String> kvSeen = new HashMap<String,String>(); 85 for (Iterator<? extends OsmPrimitive> it = osms.iterator(); it.hasNext();) { 86 OsmPrimitive osm = it.next(); 87 if (osm.keys == null || osm.keys.isEmpty()) { 88 continue; 89 } 90 for (String key : osm.keys.keySet()) { 91 String value = osm.keys.get(key); 85 for (OsmPrimitive osm:osms) { 86 for (String key : osm.keySet()) { 87 String value = osm.get(key); 92 88 if (! kvSeen.containsKey(key)) { 93 89 kvSeen.put(key, value); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r1820 r1843 24 24 import org.openstreetmap.josm.command.Command; 25 25 import org.openstreetmap.josm.command.SequenceCommand; 26 import org.openstreetmap.josm.data.SelectionChangedListener;27 import org.openstreetmap.josm.data.osm.DataSet;28 26 import org.openstreetmap.josm.data.osm.Node; 29 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 34 32 import org.openstreetmap.josm.data.osm.visitor.Visitor; 35 33 import org.openstreetmap.josm.gui.PrimitiveNameFormatter; 36 import org.openstreetmap.josm.gui.layer.Layer;37 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;38 34 import org.openstreetmap.josm.tools.Shortcut; 39 35 … … 279 275 } 280 276 Relation c = null; 281 String type = ""; 277 String type = r.get("type"); 278 if (type == null) { 279 type = ""; 280 } 282 281 int i = 0; 283 284 if(r.keys != null) {285 type = r.keys.get("type");286 }287 282 288 283 for (RelationMember rm : r.members) { -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r1814 r1843 94 94 95 95 if (regexSearch) { 96 if ( osm.keys == null)96 if (!osm.hasKeys()) 97 97 return false; 98 98 … … 115 115 } 116 116 117 for (Entry<String, String> e : osm. keys.entrySet()) {117 for (Entry<String, String> e : osm.entrySet()) { 118 118 String k = e.getKey(); 119 119 String v = e.getValue(); … … 223 223 public boolean match(OsmPrimitive osm) throws ParseError { 224 224 225 if ( osm.keys == null || osm.keys.isEmpty())225 if (!osm.hasKeys()) 226 226 return mode == Mode.NONE; 227 227 … … 251 251 case ANY_VALUE_REGEXP: 252 252 case EXACT_REGEXP: 253 for (Entry<String, String> entry:osm. keys.entrySet()) {253 for (Entry<String, String> entry:osm.entrySet()) { 254 254 if (keyPattern.matcher(entry.getKey()).matches()) { 255 255 if (mode == Mode.ANY_VALUE_REGEXP … … 260 260 return false; 261 261 case MISSING_KEY_REGEXP: 262 for (String k:osm.key s.keySet()) {262 for (String k:osm.keySet()) { 263 263 if (keyPattern.matcher(k).matches()) 264 264 return false; … … 280 280 public Any(String s) {this.s = s;} 281 281 @Override public boolean match(OsmPrimitive osm) throws ParseError { 282 if ( osm.keys == null)282 if (!osm.hasKeys()) 283 283 return s.equals(""); 284 284 … … 301 301 // is not Java 1.5 302 302 //search = java.text.Normalizer.normalize(search, java.text.Normalizer.Form.NFC); 303 for (Entry<String, String> e : osm. keys.entrySet()) {303 for (Entry<String, String> e : osm.entrySet()) { 304 304 if (regexSearch) { 305 305 String key = e.getKey(); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r1762 r1843 29 29 */ 30 30 abstract public class OsmPrimitive implements Comparable<OsmPrimitive> { 31 32 /**33 * The key/value list for this primitive.34 */35 public Map<String, String> keys;36 31 37 32 /* mappaint data */ … … 219 214 } 220 215 216 /*------------ 217 * Keys handling 218 ------------*/ 219 220 /** 221 * The key/value list for this primitive. 222 */ 223 public Map<String, String> keys; 224 221 225 /** 222 226 * Set the given value to the given key … … 248 252 } 249 253 250 public String getName() { 251 return null; 254 /** 255 * Added in revision 1843 256 * Please do not use in plug-ins until this version becomes JOSM tested 257 */ 258 public final void removeAll() { 259 keys = null; 260 mappaintStyle = null; 252 261 } 253 262 … … 266 275 return Collections.emptyList(); 267 276 return keys.keySet(); 277 } 278 279 /** 280 * Added in revision 1843 281 * Please do not use in plug-ins until this version becomes JOSM tested 282 */ 283 public final boolean hasKeys() { 284 return keys != null && !keys.isEmpty(); 285 } 286 287 288 289 290 291 292 public String getName() { 293 return null; 268 294 } 269 295 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1755 r1843 495 495 return; 496 496 } 497 else if (drawMultipolygon && r.keys != null &&"multipolygon".equals(r.keys.get("type")))497 else if (drawMultipolygon && "multipolygon".equals(r.get("type"))) 498 498 { 499 499 if(drawMultipolygon(r)) 500 500 return; 501 501 } 502 else if (drawRestriction && r.keys != null &&"restriction".equals(r.keys.get("type")))502 else if (drawRestriction && "restriction".equals(r.get("type"))) 503 503 { 504 504 drawRestriction(r); … … 751 751 752 752 if (nodeStyle == null) { 753 r.putError(tr("Style for restriction {0} not found.", r. keys.get("restriction")), true);753 r.putError(tr("Style for restriction {0} not found.", r.get("restriction")), true); 754 754 return; 755 755 } … … 1112 1112 protected String getNodeName(Node n) { 1113 1113 String name = null; 1114 if (n. keys != null) {1114 if (n.hasKeys()) { 1115 1115 for (String rn : regionalNameOrder) { 1116 name = n. keys.get(rn);1116 name = n.get(rn); 1117 1117 if (name != null) break; 1118 1118 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagMergeItem.java
r1655 r1843 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.util.HashMap;7 5 8 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 56 54 if (their == null) throw new IllegalArgumentException(tr("parameter '{0}' must not be null", "their")); 57 55 this.key = key; 58 myTagValue = null; 59 if (my.keys != null && my.keys.containsKey(key)) { 60 myTagValue = my.keys.get(key); 61 } 62 theirTagValue = null; 63 if (their.keys != null && their.keys.containsKey(key)) { 64 theirTagValue = their.keys.get(key); 65 } 56 myTagValue = my.get(key); 57 theirTagValue = their.get(key); 66 58 } 67 59 … … 108 100 throw new IllegalStateException(tr("cannot apply undecided tag merge item")); 109 101 } else if (mergeDecision == MergeDecisionType.KEEP_THEIR) { 110 if (theirTagValue == null && primitive.keys != null) {111 primitive. keys.remove(key);102 if (theirTagValue == null) { 103 primitive.remove(key); 112 104 } else if (theirTagValue != null) { 113 if (primitive.keys == null) { 114 primitive.keys = new HashMap<String, String>(); 115 } 116 primitive.keys.put(key, theirTagValue); 105 primitive.put(key, theirTagValue); 117 106 } 118 107 } else if (mergeDecision == MergeDecisionType.KEEP_MINE) { 119 if (myTagValue == null && primitive.keys != null) {120 primitive. keys.remove(key);108 if (myTagValue == null) { 109 primitive.remove(key); 121 110 } else if (myTagValue != null) { 122 if (primitive.keys == null) { 123 primitive.keys = new HashMap<String, String>(); 124 } 125 primitive.keys.put(key, myTagValue); 111 primitive.put(key, myTagValue); 126 112 } 127 113 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r1815 r1843 240 240 HashMap<String, Vector<OsmPrimitive>> map=new HashMap<String, Vector<OsmPrimitive>>(); 241 241 for (OsmPrimitive osm: sel) { 242 if(osm.keys != null) 242 String val=osm.get(key); 243 if(val != null) 243 244 { 244 String val=osm.keys.get(key); 245 if(val != null) 246 { 247 if (map.containsKey(val)) { 248 map.get(val).add(osm); 249 } else { 250 Vector<OsmPrimitive> v = new Vector<OsmPrimitive>(); 251 v.add(osm); 252 map.put(val, v); 253 } 245 if (map.containsKey(val)) { 246 map.get(val).add(osm); 247 } else { 248 Vector<OsmPrimitive> v = new Vector<OsmPrimitive>(); 249 v.add(osm); 250 map.put(val, v); 254 251 } 255 252 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/TagEditorModel.java
r1814 r1843 9 9 import java.util.Collection; 10 10 import java.util.Comparator; 11 import java.util.HashMap;12 11 import java.util.List; 13 12 import java.util.logging.Logger; … … 15 14 import javax.swing.table.AbstractTableModel; 16 15 17 import org.openstreetmap.josm.Main;18 16 import org.openstreetmap.josm.command.ChangePropertyCommand; 19 17 import org.openstreetmap.josm.command.Command; … … 24 22 /** 25 23 * TagEditorModel is a table model. 26 * 27 * 24 * 25 * 28 26 * @author gubaer 29 27 * … … 104 102 /** 105 103 * adds a tag to the model 106 * 104 * 107 105 * @param tag the tag. Must not be null. 108 * 106 * 109 107 * @exception IllegalArgumentException thrown, if tag is null 110 108 */ … … 129 127 /** 130 128 * adds a tag given by a name/value pair to the tag editor model. 131 * 129 * 132 130 * If there is no tag with name <code>name</name> yet, a new {@link TagModel} is created 133 131 * and append to this model. 134 * 132 * 135 133 * If there is a tag with name <code>name</name>, <code>value</code> is merged to the list 136 134 * of values for this tag. 137 * 135 * 138 136 * @param name the name; converted to "" if null 139 137 * @param value the value; converted to "" if null … … 183 181 /** 184 182 * deletes the names of the tags given by tagIndices 185 * 183 * 186 184 * @param tagIndices a list of tag indices 187 185 */ … … 201 199 /** 202 200 * deletes the values of the tags given by tagIndices 203 * 201 * 204 202 * @param tagIndices the lit of tag indices 205 203 */ … … 219 217 /** 220 218 * deletes the tags given by tagIndices 221 * 219 * 222 220 * @param tagIndices the list of tag indices 223 221 */ … … 261 259 /** 262 260 * initializes the model with the tags of an OSM primitive 263 * 261 * 264 262 * @param primitive the OSM primitive 265 263 */ … … 278 276 /** 279 277 * applies the current state of the tag editor model to a primitive 280 * 278 * 281 279 * @param primitive the primitive 282 * 280 * 283 281 */ 284 282 public void applyToPrimitive(OsmPrimitive primitive) { 285 if (primitive.keys == null) { 286 primitive.keys = new HashMap<String, String>(); 287 } else { 288 primitive.keys.clear(); 289 } 283 primitive.removeAll(); 290 284 for (TagModel tag: tags) { 291 285 // tag still holds an unchanged list of different values for the same key. … … 306 300 /** 307 301 * checks whether the tag model includes a tag with a given key 308 * 302 * 309 303 * @param key the key 310 304 * @return true, if the tag model includes the tag; false, otherwise … … 345 339 346 340 for (OsmPrimitive primitive : primitives) { 347 if (primitive.keys == null) { 348 continue; 349 } 350 for (String oldkey : primitive.keys.keySet()) { 341 for (String oldkey : primitive.keySet()) { 351 342 if (!currentkeys.contains(oldkey)) { 352 343 ChangePropertyCommand deleteCommand = … … 367 358 /** 368 359 * replies the list of keys of the tags managed by this model 369 * 360 * 370 361 * @return the list of keys managed by this model 371 362 */ … … 397 388 * updates the name of a tag and sets the dirty state to true if 398 389 * the new name is different from the old name. 399 * 390 * 400 391 * @param tag the tag 401 392 * @param newName the new name … … 412 403 * updates the value value of a tag and sets the dirty state to true if the 413 404 * new name is different from the old name 414 * 405 * 415 406 * @param tag the tag 416 407 * @param newValue the new value … … 426 417 /** 427 418 * replies true, if this model has been updated 428 * 419 * 429 420 * @return true, if this model has been updated 430 421 */ -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r1823 r1843 18 18 import java.awt.TexturePaint; 19 19 import java.awt.event.ActionEvent; 20 import java.awt.event.KeyEvent;21 20 import java.awt.geom.Area; 22 21 import java.awt.image.BufferedImage; … … 38 37 39 38 import org.openstreetmap.josm.Main; 40 import org.openstreetmap.josm.actions.GpxExportAction;41 39 import org.openstreetmap.josm.actions.RenameLayerAction; 42 import org.openstreetmap.josm.actions.SaveAction;43 import org.openstreetmap.josm.actions.SaveAsAction;44 40 import org.openstreetmap.josm.data.conflict.Conflict; 45 41 import org.openstreetmap.josm.data.conflict.ConflictCollection; … … 67 63 import org.openstreetmap.josm.tools.GBC; 68 64 import org.openstreetmap.josm.tools.ImageProvider; 69 import org.openstreetmap.josm.tools.Shortcut;70 65 71 66 /** … … 82 77 /** 83 78 * Replies a new unique name for a data layer 84 * 79 * 85 80 * @return a new unique name for a data layer 86 81 */ … … 497 492 wpt.setTime(); 498 493 } 499 if (n.keys != null && n.keys.containsKey("name")) { 500 wpt.attr.put("name", n.keys.get("name")); 494 String name = n.get("name"); 495 if (name != null) { 496 wpt.attr.put("name", name); 501 497 } 502 498 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r1747 r1843 4 4 import java.util.Collections; 5 5 import java.util.HashMap; 6 import java.util.Iterator; 6 7 import java.util.LinkedList; 7 8 import java.util.List; 8 9 import java.util.Map; 9 import java.util.Iterator; 10 10 11 import org.openstreetmap.josm.Main; 11 12 import org.openstreetmap.josm.data.osm.Node; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 14 import org.openstreetmap.josm.data.osm.OsmUtils; 14 15 import org.openstreetmap.josm.data.osm.Way; 15 import org.openstreetmap.josm.Main;16 16 17 17 public class ElemStyles … … 185 185 { 186 186 boolean noclosed = o instanceof Way && !((Way)o).isClosed(); 187 Iterator<String> iterator = o.key s.keySet().iterator();187 Iterator<String> iterator = o.keySet().iterator(); 188 188 while(iterator.hasNext()) 189 189 { 190 190 String key = iterator.next(); 191 String val = o. keys.get(key);191 String val = o.get(key); 192 192 AreaElemStyle s = areas.get("n" + key + "=" + val); 193 193 if(s == null || (s.closed && noclosed)) -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r1814 r1843 106 106 returnValue.hadEmpty = true; 107 107 } 108 if(s.keys != null && s.keys.size() > 0) { 109 returnValue.hadKeys = true; 110 } 108 returnValue.hadKeys = returnValue.hadKeys | s.hasKeys(); 111 109 } 112 110 return returnValue; … … 220 218 { 221 219 for (OsmPrimitive s : sel) 222 if(s. keys != null && s.keys.size() > 0) {220 if(s.hasKeys()) { 223 221 def = false; 224 222 } … … 381 379 382 380 // no change if same as before 383 if (value.equals(originalValue) || (originalValue == null && (value == null ||value.length() == 0))) return;384 385 if (delete_if_empty && value != null && value.length() == 0) {381 if (value.equals(originalValue) || (originalValue == null && value.length() == 0)) return; 382 383 if (delete_if_empty && value.length() == 0) { 386 384 value = null; 387 385 } -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r1735 r1843 164 164 165 165 private void addTags(OsmPrimitive osm, String tagname, boolean tagOpen) { 166 if (osm. keys != null) {166 if (osm.hasKeys()) { 167 167 if (tagOpen) { 168 168 out.println(">"); 169 169 } 170 for (Entry<String, String> e : osm. keys.entrySet()) {170 for (Entry<String, String> e : osm.entrySet()) { 171 171 if ((osm instanceof Changeset) || !("created_by".equals(e.getKey()))) 172 172 out.println(" <tag k='"+ XmlWriter.encode(e.getKey()) +
Note:
See TracChangeset
for help on using the changeset viewer.