Changeset 7395 in josm for trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
- Timestamp:
- 2014-08-14T15:33:52+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r7073 r7395 122 122 private final Object selectionLock = new Object(); 123 123 124 /** 125 * Constructs a new {@code DataSet}. 126 */ 124 127 public DataSet() { 125 128 /* … … 130 133 } 131 134 135 /** 136 * Returns the lock used for reading. 137 * @return the lock used for reading 138 */ 132 139 public Lock getReadLock() { 133 140 return lock.readLock(); … … 165 172 166 173 /** 167 * Maintain a list of used tags for autocompletion174 * Maintains a list of used tags for autocompletion. 168 175 */ 169 176 private AutoCompletionManager autocomplete; 170 177 178 /** 179 * Returns the autocompletion manager, which maintains a list of used tags for autocompletion. 180 * @return the autocompletion manager 181 */ 171 182 public AutoCompletionManager getAutoCompletionManager() { 172 183 if (autocomplete == null) { … … 200 211 } 201 212 213 /** 214 * Determines if upload is being discouraged (i.e. this dataset contains private data which should not be uploaded) 215 * @return {@code true} if upload is being discouraged, {@code false} otherwise 216 * @see #setUploadDiscouraged 217 */ 202 218 public final boolean isUploadDiscouraged() { 203 219 return uploadDiscouraged; 204 220 } 205 221 222 /** 223 * Sets the "upload discouraged" flag. 224 * @param uploadDiscouraged {@code true} if this dataset contains private data which should not be uploaded 225 * @see #isUploadDiscouraged 226 */ 206 227 public final void setUploadDiscouraged(boolean uploadDiscouraged) { 207 228 this.uploadDiscouraged = uploadDiscouraged; … … 213 234 private Map<String, String> changeSetTags = new HashMap<>(); 214 235 236 /** 237 * Replies the set of changeset tags to be applied when or if this is ever uploaded. 238 * @return the set of changeset tags 239 * @see #addChangeSetTag 240 */ 215 241 public Map<String, String> getChangeSetTags() { 216 242 return changeSetTags; 217 243 } 218 244 245 /** 246 * Adds a new changeset tag. 247 * @param k Key 248 * @param v Value 249 * @see #getChangeSetTags 250 */ 219 251 public void addChangeSetTag(String k, String v) { 220 252 this.changeSetTags.put(k,v); … … 240 272 } 241 273 274 /** 275 * Searches for nodes in the given bounding box. 276 * @param bbox the bounding box 277 * @return List of nodes in the given bbox. Can be empty but not null 278 */ 242 279 public List<Node> searchNodes(BBox bbox) { 243 280 lock.readLock().lock(); … … 265 302 } 266 303 304 /** 305 * Searches for ways in the given bounding box. 306 * @param bbox the bounding box 307 * @return List of ways in the given bbox. Can be empty but not null 308 */ 267 309 public List<Way> searchWays(BBox bbox) { 268 310 lock.readLock().lock(); … … 288 330 } 289 331 332 /** 333 * Searches for relations in the given bounding box. 334 * @param bbox the bounding box 335 * @return List of relations in the given bbox. Can be empty but not null 336 */ 290 337 public List<Relation> searchRelations(BBox bbox) { 291 338 lock.readLock().lock(); … … 310 357 311 358 /** 312 * @return A collection containing all primitives of the dataset. Data are not ordered 359 * Returns a collection containing all primitives of the dataset. 360 * @return A collection containing all primitives of the dataset. Data is not ordered 313 361 */ 314 362 public Collection<OsmPrimitive> allPrimitives() { … … 317 365 318 366 /** 319 * @return A collection containing all not-deleted primitives (except keys). 367 * Returns a collection containing all not-deleted primitives. 368 * @return A collection containing all not-deleted primitives. 369 * @see OsmPrimitive#isDeleted 320 370 */ 321 371 public Collection<OsmPrimitive> allNonDeletedPrimitives() { … … 323 373 } 324 374 375 /** 376 * Returns a collection containing all not-deleted complete primitives. 377 * @return A collection containing all not-deleted complete primitives. 378 * @see OsmPrimitive#isDeleted 379 * @see OsmPrimitive#isIncomplete 380 */ 325 381 public Collection<OsmPrimitive> allNonDeletedCompletePrimitives() { 326 382 return getPrimitives(OsmPrimitive.nonDeletedCompletePredicate); 327 383 } 328 384 385 /** 386 * Returns a collection containing all not-deleted complete physical primitives. 387 * @return A collection containing all not-deleted complete physical primitives (nodes and ways). 388 * @see OsmPrimitive#isDeleted 389 * @see OsmPrimitive#isIncomplete 390 */ 329 391 public Collection<OsmPrimitive> allNonDeletedPhysicalPrimitives() { 330 392 return getPrimitives(OsmPrimitive.nonDeletedPhysicalPredicate); 331 393 } 332 394 395 /** 396 * Returns a collection containing all modified primitives. 397 * @return A collection containing all modified primitives. 398 * @see OsmPrimitive#isModified 399 */ 333 400 public Collection<OsmPrimitive> allModifiedPrimitives() { 334 401 return getPrimitives(OsmPrimitive.modifiedPredicate); … … 336 403 337 404 /** 338 * Adds a primitive to the dataset 405 * Adds a primitive to the dataset. 339 406 * 340 407 * @param primitive the primitive. … … 414 481 private static final Collection<SelectionChangedListener> selListeners = new CopyOnWriteArrayList<>(); 415 482 483 /** 484 * Adds a new selection listener. 485 * @param listener The selection listener to add 486 */ 416 487 public static void addSelectionListener(SelectionChangedListener listener) { 417 488 ((CopyOnWriteArrayList<SelectionChangedListener>)selListeners).addIfAbsent(listener); 418 489 } 419 490 491 /** 492 * Removes a selection listener. 493 * @param listener The selection listener to remove 494 */ 420 495 public static void removeSelectionListener(SelectionChangedListener listener) { 421 496 selListeners.remove(listener); … … 437 512 private Collection<OsmPrimitive> selectionSnapshot; 438 513 514 /** 515 * Returns selected nodes and ways. 516 * @return selected nodes and ways 517 */ 439 518 public Collection<OsmPrimitive> getSelectedNodesAndWays() { 440 519 return new FilteredCollection<>(getSelected(), new Predicate<OsmPrimitive>() { … … 447 526 448 527 /** 449 * returns an unmodifiable collection of *WaySegments* whose virtual528 * Returns an unmodifiable collection of *WaySegments* whose virtual 450 529 * nodes should be highlighted. WaySegments are used to avoid having 451 530 * to create a VirtualNode class that wouldn't have much purpose otherwise. … … 458 537 459 538 /** 460 * returns an unmodifiable collection of WaySegments that should be 461 * highlighted. 539 * Returns an unmodifiable collection of WaySegments that should be highlighted. 462 540 * 463 541 * @return unmodifiable collection of WaySegments … … 495 573 496 574 /** 497 * Return selected nodes. 575 * Returns selected nodes. 576 * @return selected nodes 498 577 */ 499 578 public Collection<Node> getSelectedNodes() { … … 502 581 503 582 /** 504 * Return selected ways. 583 * Returns selected ways. 584 * @return selected ways 505 585 */ 506 586 public Collection<Way> getSelectedWays() { … … 509 589 510 590 /** 511 * Return selected relations. 591 * Returns selected relations. 592 * @return selected relations 512 593 */ 513 594 public Collection<Relation> getSelectedRelations() { … … 516 597 517 598 /** 599 * Determines whether the selection is empty or not 518 600 * @return whether the selection is empty or not 519 601 */ … … 522 604 } 523 605 606 /** 607 * Determines whether the given primitive is selected or not 608 * @param osm the primitive 609 * @return whether {@code osm} is selected or not 610 */ 524 611 public boolean isSelected(OsmPrimitive osm) { 525 612 return selectedPrimitives.contains(osm); 526 613 } 527 614 615 /** 616 * Toggles the selected state of the given collection of primitives. 617 * @param osm The primitives to toggle 618 */ 528 619 public void toggleSelected(Collection<? extends PrimitiveId> osm) { 529 620 boolean changed = false; … … 540 631 } 541 632 } 633 634 /** 635 * Toggles the selected state of the given collection of primitives. 636 * @param osm The primitives to toggle 637 */ 542 638 public void toggleSelected(PrimitiveId... osm) { 543 639 toggleSelected(Arrays.asList(osm)); 544 640 } 641 545 642 private boolean __toggleSelected(PrimitiveId primitiveId) { 546 643 OsmPrimitive primitive = getPrimitiveByIdChecked(primitiveId); … … 617 714 } 618 715 716 /** 717 * Sets the current selection to the primitives in <code>osm</code> 718 * and notifies all {@link SelectionChangedListener}. 719 * 720 * @param osm the primitives to set 721 */ 619 722 public void setSelected(PrimitiveId... osm) { 620 723 if (osm.length == 1 && osm[0] == null) { … … 627 730 628 731 /** 629 * Adds 732 * Adds the primitives in <code>selection</code> to the current selection 630 733 * and notifies all {@link SelectionChangedListener}. 631 734 * … … 636 739 } 637 740 741 /** 742 * Adds the primitives in <code>osm</code> to the current selection 743 * and notifies all {@link SelectionChangedListener}. 744 * 745 * @param osm the primitives to add 746 */ 638 747 public void addSelected(PrimitiveId... osm) { 639 748 addSelected(Arrays.asList(osm)); … … 682 791 683 792 /** 684 * Remove the selection from every value in the collection.793 * Removes the selection from every value in the collection. 685 794 * @param osm The collection of ids to remove the selection from. 686 795 */ … … 688 797 clearSelection(Arrays.asList(osm)); 689 798 } 799 800 /** 801 * Removes the selection from every value in the collection. 802 * @param list The collection of ids to remove the selection from. 803 */ 690 804 public void clearSelection(Collection<? extends PrimitiveId> list) { 691 805 boolean changed = false; … … 705 819 } 706 820 } 821 822 /** 823 * Clears the current selection. 824 */ 707 825 public void clearSelection() { 708 826 if (!selectedPrimitives.isEmpty()) { … … 715 833 } 716 834 717 @Override public DataSet clone() { 835 @Override 836 public DataSet clone() { 718 837 getReadLock().lock(); 719 838 try { … … 776 895 777 896 /** 778 * returns a primitive with a given id from the data set. null, if no such primitive 779 * exists 897 * Returns a primitive with a given id from the data set. null, if no such primitive exists 780 898 * 781 899 * @param id uniqueId of the primitive. Might be < 0 for newly created primitives … … 788 906 } 789 907 908 /** 909 * Returns a primitive with a given id from the data set. null, if no such primitive exists 910 * 911 * @param primitiveId type and uniqueId of the primitive. Might be < 0 for newly created primitives 912 * @return the primitive 913 */ 790 914 public OsmPrimitive getPrimitiveById(PrimitiveId primitiveId) { 791 915 return primitivesMap.get(primitiveId); … … 949 1073 } 950 1074 1075 /** 1076 * Adds a new data set listener. 1077 * @param dsl The data set listener to add 1078 */ 951 1079 public void addDataSetListener(DataSetListener dsl) { 952 1080 listeners.addIfAbsent(dsl); 953 1081 } 954 1082 1083 /** 1084 * Removes a data set listener. 1085 * @param dsl The data set listener to remove 1086 */ 955 1087 public void removeDataSetListener(DataSetListener dsl) { 956 1088 listeners.remove(dsl); … … 1078 1210 } 1079 1211 1212 /** 1213 * Cleanups all deleted primitives (really delete them from the dataset). 1214 */ 1080 1215 public void cleanupDeletedPrimitives() { 1081 1216 beginUpdate(); … … 1169 1304 1170 1305 /** 1171 * Moves all primitives and datasources from DataSet "from" to this DataSet 1306 * Moves all primitives and datasources from DataSet "from" to this DataSet. 1172 1307 * @param from The source DataSet 1173 1308 */ … … 1177 1312 1178 1313 /** 1179 * Moves all primitives and datasources from DataSet "from" to this DataSet 1314 * Moves all primitives and datasources from DataSet "from" to this DataSet. 1180 1315 * @param from The source DataSet 1316 * @param progressMonitor The progress monitor 1181 1317 */ 1182 1318 public void mergeFrom(DataSet from, ProgressMonitor progressMonitor) {
Note:
See TracChangeset
for help on using the changeset viewer.