Changeset 1670 in josm for trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
- Timestamp:
- 15.06.2009 20:22:46 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r1647 r1670 10 10 import java.util.LinkedList; 11 11 import java.util.List; 12 import java.util.Set; 12 13 13 14 import org.openstreetmap.josm.data.SelectionChangedListener; 15 import static org.openstreetmap.josm.tools.I18n.tr; 14 16 15 17 /** … … 78 80 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 79 81 for (OsmPrimitive osm : allPrimitives()) 80 if (!osm.deleted) 82 if (!osm.deleted) { 81 83 o.add(osm); 84 } 82 85 return o; 83 86 } … … 86 89 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 87 90 for (OsmPrimitive osm : allPrimitives()) 88 if (!osm.deleted && !osm.incomplete) 91 if (!osm.deleted && !osm.incomplete) { 89 92 o.add(osm); 93 } 90 94 return o; 91 95 } … … 94 98 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 95 99 for (OsmPrimitive osm : allPrimitives()) 96 if (!osm.deleted && !osm.incomplete && !(osm instanceof Relation)) 100 if (!osm.deleted && !osm.incomplete && !(osm instanceof Relation)) { 97 101 o.add(osm); 102 } 98 103 return o; 99 104 } … … 150 155 clearSelection(ways); 151 156 clearSelection(relations); 152 for (OsmPrimitive osm : selection) 157 for (OsmPrimitive osm : selection) { 153 158 osm.selected = true; 159 } 154 160 fireSelectionChanged(selection); 155 161 } … … 164 170 clearSelection(relations); 165 171 for (OsmPrimitive o : osm) 166 if (o != null) 172 if (o != null) { 167 173 o.selected = true; 174 } 168 175 fireSelectionChanged(Arrays.asList(osm)); 169 176 } … … 176 183 if (list == null) 177 184 return; 178 for (OsmPrimitive osm : list) 185 for (OsmPrimitive osm : list) { 179 186 osm.selected = false; 187 } 180 188 } 181 189 … … 189 197 return sel; 190 198 for (OsmPrimitive osm : list) 191 if (osm.selected && !osm.deleted) 199 if (osm.selected && !osm.deleted) { 192 200 sel.add(osm); 201 } 193 202 return sel; 194 203 } … … 200 209 */ 201 210 public static void fireSelectionChanged(Collection<? extends OsmPrimitive> sel) { 202 for (SelectionChangedListener l : selListeners) 211 for (SelectionChangedListener l : selListeners) { 203 212 l.selectionChanged(sel); 213 } 204 214 } 205 215 206 216 @Override public DataSet clone() { 207 217 DataSet ds = new DataSet(); 208 for (Node n : nodes) 218 for (Node n : nodes) { 209 219 ds.nodes.add(new Node(n)); 210 for (Way w : ways) 220 } 221 for (Way w : ways) { 211 222 ds.ways.add(new Way(w)); 212 for (Relation e : relations) 223 } 224 for (Relation e : relations) { 213 225 ds.relations.add(new Relation(e)); 214 for (DataSource source : dataSources) 226 } 227 for (DataSource source : dataSources) { 215 228 ds.dataSources.add(new DataSource(source.bounds, source.origin)); 229 } 216 230 ds.version = version; 217 231 return ds; … … 260 274 return selArr; 261 275 } 276 277 /** 278 * returns a primitive with a given id from the data set. null, if no such primitive 279 * exists 280 * 281 * @param id the id, > 0 required 282 * @return the primitive 283 * @exception IllegalArgumentException thrown, if id <= 0 284 */ 285 public OsmPrimitive getPrimitiveById(long id) { 286 if (id <= 0) 287 throw new IllegalArgumentException(tr("parameter {0} > 0 required. Got {1}.", "id", id)); 288 for (OsmPrimitive primitive : nodes) { 289 if (primitive.id == id) return primitive; 290 } 291 for (OsmPrimitive primitive : ways) { 292 if (primitive.id == id) return primitive; 293 } 294 for (OsmPrimitive primitive : relations) { 295 if (primitive.id == id) return primitive; 296 } 297 return null; 298 } 299 300 public Set<Long> getPrimitiveIds() { 301 HashSet<Long> ret = new HashSet<Long>(); 302 for (OsmPrimitive primitive : nodes) { 303 ret.add(primitive.id); 304 } 305 for (OsmPrimitive primitive : ways) { 306 ret.add(primitive.id); 307 } 308 for (OsmPrimitive primitive : relations) { 309 ret.add(primitive.id); 310 } 311 return ret; 312 } 262 313 }
Note: See TracChangeset
for help on using the changeset viewer.
