public final class DataSet extends java.lang.Object implements OsmData<OsmPrimitive,Node,Way,Relation>, ProjectionChangeListener
ds.getReadLock().lock();
try {
// .. do something with dataset
} finally {
ds.getReadLock().unlock();
}
Write lock should be used in case of bulk operations. In addition to ensuring that other threads can't
use dataset in the middle of modifications it also stops sending of dataset events. That's good for performance
reasons - GUI can be updated after all changes are done.
Sample usage:
ds.beginUpdate()
try {
// .. do modifications
} finally {
ds.endUpdate();
}
Note that it is not necessary to call beginUpdate/endUpdate for every dataset modification - dataset will get locked
automatically.
Note that locks cannot be upgraded - if one threads use read lock and and then write lock, dead lock will occur - see #5814 for
sample ticketModifier and Type | Field and Description |
---|---|
private Storage<OsmPrimitive> |
allPrimitives |
private java.awt.geom.Area |
cachedDataSourceArea |
private java.util.List<Bounds> |
cachedDataSourceBounds |
private java.util.List<AbstractDatasetChangedEvent> |
cachedEvents |
private java.util.Map<java.lang.String,java.lang.String> |
changeSetTags
Holding bin for changeset tag information, to be applied when or if this is ever uploaded.
|
private ConflictCollection |
conflicts |
private java.util.Set<OsmPrimitive> |
currentSelectedPrimitives
The current selected primitives.
|
private java.util.Collection<DataSource> |
dataSources
All data sources of this DataSet.
|
private DownloadPolicy |
downloadPolicy |
private java.util.Collection<WaySegment> |
highlightedVirtualNodes |
private java.util.Collection<WaySegment> |
highlightedWaySegments |
private ListenerList<HighlightUpdateListener> |
highlightUpdateListeners |
private java.util.concurrent.atomic.AtomicBoolean |
isReadOnly
Flag used to know if the dataset should not be editable
|
private java.util.concurrent.CopyOnWriteArrayList<DataSetListener> |
listeners |
private java.util.concurrent.locks.ReadWriteLock |
lock |
private short |
mappaintCacheIdx |
private static int |
MAX_EVENTS
Maximum number of events to kept between beginUpdate/endUpdate.
|
private static int |
MAX_SINGLE_EVENTS
Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent)
|
private java.lang.String |
name |
private java.util.Map<PrimitiveId,OsmPrimitive> |
primitivesMap |
private java.util.LinkedList<java.util.Collection<? extends OsmPrimitive>> |
selectionHistory
History of selections - shared by plugins and SelectionListDialog
|
private ListenerList<DataSelectionListener> |
selectionListeners
A list of listeners that listen to selection changes on this layer.
|
private java.lang.Object |
selectionLock
The mutex lock that is used to synchronize selection changes.
|
private static java.util.Collection<SelectionChangedListener> |
selListeners
Deprecated.
to be removed
|
private QuadBucketPrimitiveStore<Node,Way,Relation> |
store |
private int |
updateCount |
private UploadPolicy |
uploadPolicy |
private java.lang.String |
version
The API version that created this data set, if any.
|
Constructor and Description |
---|
DataSet()
Constructs a new
DataSet . |
DataSet(DataSet copyFrom)
Creates a new
DataSet . |
DataSet(OsmPrimitive... osmPrimitives)
Constructs a new
DataSet initially filled with the given primitives. |
Modifier and Type | Method and Description |
---|---|
void |
addChangeSetTag(java.lang.String k,
java.lang.String v)
Adds a new changeset tag.
|
void |
addDataSetListener(DataSetListener dsl)
Adds a new data set listener.
|
boolean |
addDataSource(DataSource source)
Adds a new data source.
|
boolean |
addDataSources(java.util.Collection<DataSource> sources)
Adds new data sources.
|
void |
addHighlightUpdateListener(HighlightUpdateListener listener)
Adds a listener that gets notified whenever way segment / virtual nodes highlights change.
|
void |
addPrimitive(OsmPrimitive primitive)
Adds a primitive to the dataset.
|
void |
addSelected(java.util.Collection<? extends PrimitiveId> selection)
Adds the primitives in
selection to the current selection
and notifies all DataSelectionListener . |
void |
addSelected(PrimitiveId... osm)
Adds the primitives in
osm to the current selection
and notifies all DataSelectionListener . |
private void |
addSelected(java.util.stream.Stream<? extends PrimitiveId> stream) |
void |
addSelectionListener(DataSelectionListener listener)
Add a listener that listens to selection changes in this specific data set.
|
static void |
addSelectionListener(SelectionChangedListener listener)
Deprecated.
|
void |
beginUpdate()
Can be called before bigger changes on dataset.
|
private void |
checkModifiable()
Checks the dataset is modifiable (not read-only).
|
void |
cleanupDeletedPrimitives()
Cleanups all deleted primitives (really delete them from the dataset).
|
void |
clear()
Removes all primitives from the dataset and resets the currently selected primitives
to the empty collection.
|
void |
clearMappaintCache()
Clear the mappaint cache for this DataSet.
|
void |
clearSelection()
Clears the current selection.
|
void |
clearSelection(java.util.Collection<? extends PrimitiveId> list)
Removes the selection from every value in the collection.
|
void |
clearSelection(PrimitiveId... osm)
Removes the selection from every value in the collection.
|
private void |
clearSelection(java.util.stream.Stream<? extends PrimitiveId> stream) |
void |
clearSelectionHistory()
Clears selection history list
|
boolean |
containsNode(Node n)
Determines if the given node can be retrieved in the data set through its bounding box.
|
boolean |
containsRelation(Relation r)
Determines if the given relation can be retrieved in the data set through its bounding box.
|
boolean |
containsWay(Way w)
Determines if the given way can be retrieved in the data set through its bounding box.
|
void |
deleteInvisible()
Marks all "invisible" objects as deleted.
|
private static void |
deleteWay(Way way) |
private boolean |
doSelectionChange(java.util.function.Function<java.util.Set<OsmPrimitive>,DataSelectionListener.SelectionChangeEvent> command)
Do a selection change.
|
void |
endUpdate()
Must be called after a previous call to
beginUpdate() to fire change events. |
(package private) void |
fireChangesetIdChanged(OsmPrimitive primitive,
int oldChangesetId,
int newChangesetId) |
private void |
fireEvent(AbstractDatasetChangedEvent event) |
private void |
fireEventToListeners(AbstractDatasetChangedEvent event) |
(package private) void |
fireFilterChanged() |
(package private) void |
fireHighlightingChanged() |
(package private) void |
fireNodeMoved(Node node,
LatLon newCoor,
EastNorth eastNorth) |
(package private) void |
firePrimitiveFlagsChanged(OsmPrimitive primitive) |
(package private) void |
firePrimitivesAdded(java.util.Collection<? extends OsmPrimitive> added,
boolean wasIncomplete) |
(package private) void |
firePrimitivesRemoved(java.util.Collection<? extends OsmPrimitive> removed,
boolean wasComplete) |
(package private) void |
fireRelationMembersChanged(Relation r) |
private static void |
fireSelectionChange(java.util.Collection<? extends OsmPrimitive> currentSelection)
Deprecated.
to be removed
|
(package private) void |
fireTagsChanged(OsmPrimitive prim,
java.util.Map<java.lang.String,java.lang.String> originalKeys) |
(package private) void |
fireWayNodesChanged(Way way) |
java.util.Collection<OsmPrimitive> |
getAllSelected()
Replies an unmodifiable collection of primitives currently selected
in this dataset, including deleted ones.
|
java.util.Map<java.lang.String,java.lang.String> |
getChangeSetTags()
Replies the set of changeset tags to be applied when or if this is ever uploaded.
|
ConflictCollection |
getConflicts()
Replies the set of conflicts currently managed in this layer.
|
java.awt.geom.Area |
getDataSourceArea()
Returns the total area of downloaded data (the "yellow rectangles").
|
ProjectionBounds |
getDataSourceBoundingBox()
Returns the data sources bounding box.
|
java.util.List<Bounds> |
getDataSourceBounds()
Replies the list of data source bounds.
|
java.util.Collection<DataSource> |
getDataSources()
Returns the collection of data sources.
|
DownloadPolicy |
getDownloadPolicy()
Get the download policy.
|
java.util.Collection<WaySegment> |
getHighlightedVirtualNodes()
Returns an unmodifiable collection of *WaySegments* whose virtual
nodes should be highlighted.
|
java.util.Collection<WaySegment> |
getHighlightedWaySegments()
Returns an unmodifiable collection of WaySegments that should be highlighted.
|
short |
getMappaintCacheIndex()
Returns mappaint cache index for this DataSet.
|
java.lang.String |
getName()
Returns the name of this data set (optional).
|
java.util.Collection<Node> |
getNodes()
Replies an unmodifiable collection of nodes in this dataset
|
OsmPrimitive |
getPrimitiveById(PrimitiveId primitiveId)
Returns a primitive with a given id from the data set.
|
private OsmPrimitive |
getPrimitiveByIdChecked(PrimitiveId primitiveId)
Show message and stack trace in log in case primitive is not found
|
<T extends OsmPrimitive> |
getPrimitives(java.util.function.Predicate<? super OsmPrimitive> predicate)
Gets a filtered collection of primitives matching the given predicate.
|
java.util.concurrent.locks.Lock |
getReadLock()
Returns the lock used for reading.
|
java.util.Collection<Relation> |
getRelations()
Replies an unmodifiable collection of relations in this dataset
|
java.util.Collection<OsmPrimitive> |
getSelectedNodesAndWays()
Returns selected nodes and ways.
|
java.util.LinkedList<java.util.Collection<? extends OsmPrimitive>> |
getSelectionHistory()
Replies the history of JOSM selections
|
UploadPolicy |
getUploadPolicy()
Get the upload policy.
|
java.lang.String |
getVersion()
Replies the API version this dataset was created from.
|
java.util.Collection<Way> |
getWays()
Replies an unmodifiable collection of ways in this dataset
|
void |
invalidateEastNorthCache()
Invalidates the internal cache of projected east/north coordinates.
|
boolean |
isLocked()
Determines if this is read-only/locked (thus it cannot be modified).
|
boolean |
isModified()
Replies true if there is at least one primitive in this dataset with
IPrimitive.isModified() == true . |
boolean |
isSelected(OsmPrimitive osm)
Determines whether the given primitive is selected or not
|
void |
lock()
Enables the read-only/locked mode.
|
void |
mergeFrom(DataSet from)
Moves all primitives and datasources from DataSet "from" to this DataSet.
|
void |
mergeFrom(DataSet from,
ProgressMonitor progressMonitor)
Moves all primitives and datasources from DataSet "from" to this DataSet.
|
void |
projectionChanged(Projection oldValue,
Projection newValue) |
void |
removeDataSetListener(DataSetListener dsl)
Removes a data set listener.
|
void |
removeHighlightUpdateListener(HighlightUpdateListener listener)
Removes a listener that was added with
OsmData.addHighlightUpdateListener(HighlightUpdateListener) |
(package private) void |
removePrimitive(OsmPrimitive primitive) |
void |
removePrimitive(PrimitiveId primitiveId)
Removes a primitive from the dataset.
|
private void |
removePrimitiveImpl(OsmPrimitive primitive) |
void |
removeSelectionListener(DataSelectionListener listener)
Remove a listener that listens to selection changes in this specific data set.
|
static void |
removeSelectionListener(SelectionChangedListener listener)
Deprecated.
|
boolean |
requiresUploadToServer()
Replies true if there is at least one primitive in this dataset which requires to be uploaded to server.
|
java.util.List<Node> |
searchNodes(BBox bbox)
Searches for nodes in the given bounding box.
|
java.util.List<Relation> |
searchRelations(BBox bbox)
Searches for relations in the given bounding box.
|
java.util.List<Way> |
searchWays(BBox bbox)
Searches for ways in the given bounding box.
|
boolean |
selectionEmpty()
Determines whether the selection is empty or not
|
void |
setDownloadPolicy(DownloadPolicy downloadPolicy)
Sets the download policy.
|
void |
setHighlightedVirtualNodes(java.util.Collection<WaySegment> waySegments)
set what virtual nodes should be highlighted.
|
void |
setHighlightedWaySegments(java.util.Collection<WaySegment> waySegments)
set what virtual ways should be highlighted.
|
void |
setName(java.lang.String name)
Sets the name of this data set.
|
void |
setSelected(java.util.Collection<? extends PrimitiveId> selection)
Sets the current selection to the primitives in
selection
and notifies all DataSelectionListener . |
void |
setSelected(PrimitiveId... osm)
Sets the current selection to the primitives in
osm
and notifies all DataSelectionListener . |
private void |
setSelected(java.util.stream.Stream<? extends PrimitiveId> stream) |
void |
setUploadPolicy(UploadPolicy uploadPolicy)
Sets the upload policy.
|
void |
setVersion(java.lang.String version)
Sets the API version this dataset was created from.
|
void |
toggleSelected(java.util.Collection<? extends PrimitiveId> osm)
Toggles the selected state of the given collection of primitives.
|
void |
toggleSelected(PrimitiveId... osm)
Toggles the selected state of the given collection of primitives.
|
private void |
toggleSelected(java.util.stream.Stream<? extends PrimitiveId> stream) |
java.util.Set<Way> |
unlinkNodeFromWays(Node node)
Removes all references from ways in this dataset to a particular node.
|
java.util.Set<Relation> |
unlinkPrimitiveFromRelations(OsmPrimitive primitive)
removes all references from relations in this dataset to this primitive
|
java.util.Set<OsmPrimitive> |
unlinkReferencesToPrimitive(OsmPrimitive referencedPrimitive)
Removes all references from other primitives to the referenced primitive.
|
void |
unlock()
Disables the read-only/locked mode.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allModifiedPrimitives, allNonDeletedCompletePrimitives, allNonDeletedPhysicalPrimitives, allNonDeletedPrimitives, allPreservedPrimitives, allPrimitives, clearHighlightedVirtualNodes, clearHighlightedWaySegments, getPrimitiveById, getSelected, getSelectedNodes, getSelectedRelations, getSelectedWays
private static final int MAX_SINGLE_EVENTS
private static final int MAX_EVENTS
private final QuadBucketPrimitiveStore<Node,Way,Relation> store
private final Storage<OsmPrimitive> allPrimitives
private final java.util.Map<PrimitiveId,OsmPrimitive> primitivesMap
private final java.util.concurrent.CopyOnWriteArrayList<DataSetListener> listeners
private java.util.Collection<WaySegment> highlightedVirtualNodes
private java.util.Collection<WaySegment> highlightedWaySegments
private final ListenerList<HighlightUpdateListener> highlightUpdateListeners
private int updateCount
private final java.util.List<AbstractDatasetChangedEvent> cachedEvents
private java.lang.String name
private DownloadPolicy downloadPolicy
private UploadPolicy uploadPolicy
private final java.util.concurrent.atomic.AtomicBoolean isReadOnly
private final java.util.concurrent.locks.ReadWriteLock lock
private final java.lang.Object selectionLock
private java.util.Set<OsmPrimitive> currentSelectedPrimitives
private final ListenerList<DataSelectionListener> selectionListeners
private java.awt.geom.Area cachedDataSourceArea
private java.util.List<Bounds> cachedDataSourceBounds
private final java.util.Collection<DataSource> dataSources
private final ConflictCollection conflicts
private short mappaintCacheIdx
private final java.util.LinkedList<java.util.Collection<? extends OsmPrimitive>> selectionHistory
private java.lang.String version
private final java.util.Map<java.lang.String,java.lang.String> changeSetTags
@Deprecated private static final java.util.Collection<SelectionChangedListener> selListeners
public DataSet()
DataSet
.public DataSet(DataSet copyFrom)
DataSet
.copyFrom
- An other DataSet
to copy the contents of this dataset from.public DataSet(OsmPrimitive... osmPrimitives)
DataSet
initially filled with the given primitives.osmPrimitives
- primitives to add to this data setpublic boolean addDataSource(DataSource source)
source
- data source to addtrue
if the collection changed as a result of the callpublic boolean addDataSources(java.util.Collection<DataSource> sources)
sources
- data sources to addtrue
if the collection changed as a result of the callpublic java.util.concurrent.locks.Lock getReadLock()
OsmData
getReadLock
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public java.util.LinkedList<java.util.Collection<? extends OsmPrimitive>> getSelectionHistory()
public void clearSelectionHistory()
public java.lang.String getVersion()
OsmData
getVersion
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public void setVersion(java.lang.String version)
version
- the API version, i.e. "0.6"java.lang.IllegalStateException
- if the dataset is read-onlypublic DownloadPolicy getDownloadPolicy()
OsmData
getDownloadPolicy
in interface OsmData<OsmPrimitive,Node,Way,Relation>
OsmData.setDownloadPolicy(DownloadPolicy)
public void setDownloadPolicy(DownloadPolicy downloadPolicy)
OsmData
setDownloadPolicy
in interface OsmData<OsmPrimitive,Node,Way,Relation>
downloadPolicy
- the download policyOsmData.getUploadPolicy()
public UploadPolicy getUploadPolicy()
OsmData
getUploadPolicy
in interface OsmData<OsmPrimitive,Node,Way,Relation>
OsmData.setUploadPolicy(UploadPolicy)
public void setUploadPolicy(UploadPolicy uploadPolicy)
OsmData
setUploadPolicy
in interface OsmData<OsmPrimitive,Node,Way,Relation>
uploadPolicy
- the upload policyOsmData.getUploadPolicy()
public java.util.Map<java.lang.String,java.lang.String> getChangeSetTags()
addChangeSetTag(java.lang.String, java.lang.String)
public void addChangeSetTag(java.lang.String k, java.lang.String v)
k
- Keyv
- ValuegetChangeSetTags()
public <T extends OsmPrimitive> java.util.Collection<T> getPrimitives(java.util.function.Predicate<? super OsmPrimitive> predicate)
OsmData
getPrimitives
in interface OsmData<OsmPrimitive,Node,Way,Relation>
T
- The primitive type.predicate
- The predicate to matchpublic java.util.Collection<Node> getNodes()
OsmData
public java.util.List<Node> searchNodes(BBox bbox)
OsmData
searchNodes
in interface OsmData<OsmPrimitive,Node,Way,Relation>
bbox
- the bounding boxpublic java.util.Collection<Way> getWays()
OsmData
public java.util.List<Way> searchWays(BBox bbox)
OsmData
searchWays
in interface OsmData<OsmPrimitive,Node,Way,Relation>
bbox
- the bounding boxpublic java.util.List<Relation> searchRelations(BBox bbox)
OsmData
searchRelations
in interface OsmData<OsmPrimitive,Node,Way,Relation>
bbox
- the bounding boxpublic java.util.Collection<Relation> getRelations()
OsmData
getRelations
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public boolean containsNode(Node n)
containsNode
in interface OsmData<OsmPrimitive,Node,Way,Relation>
n
- The node to searchtrue
if n
can be retrieved in this data set, false
otherwisepublic boolean containsWay(Way w)
containsWay
in interface OsmData<OsmPrimitive,Node,Way,Relation>
w
- The way to searchtrue
if w
can be retrieved in this data set, false
otherwisepublic boolean containsRelation(Relation r)
containsRelation
in interface OsmData<OsmPrimitive,Node,Way,Relation>
r
- The relation to searchtrue
if r
can be retrieved in this data set, false
otherwisepublic void addPrimitive(OsmPrimitive primitive)
addPrimitive
in interface OsmData<OsmPrimitive,Node,Way,Relation>
primitive
- the primitive.java.lang.IllegalStateException
- if the dataset is read-onlypublic void removePrimitive(PrimitiveId primitiveId)
store.nodes
, store.ways
, or
store.relations
. References from other primitives to this
primitive are left unchanged.primitiveId
- the id of the primitivejava.lang.IllegalStateException
- if the dataset is read-onlyprivate void removePrimitiveImpl(OsmPrimitive primitive)
void removePrimitive(OsmPrimitive primitive)
public void addSelectionListener(DataSelectionListener listener)
OsmData
addSelectionListener
in interface OsmData<OsmPrimitive,Node,Way,Relation>
listener
- The listener.OsmData.removeSelectionListener(DataSelectionListener)
,
To add a global listener.
public void removeSelectionListener(DataSelectionListener listener)
OsmData
removeSelectionListener
in interface OsmData<OsmPrimitive,Node,Way,Relation>
listener
- The listener.OsmData.addSelectionListener(DataSelectionListener)
@Deprecated public static void addSelectionListener(SelectionChangedListener listener)
SelectionEventManager.addSelectionListener(DataSelectionListener)
insteadlistener
- The selection listener to addaddSelectionListener(DataSelectionListener)
,
SelectionEventManager.removeSelectionListener(SelectionChangedListener)
@Deprecated public static void removeSelectionListener(SelectionChangedListener listener)
SelectionEventManager.removeSelectionListener(DataSelectionListener)
insteadlistener
- The selection listener to removeremoveSelectionListener(DataSelectionListener)
,
SelectionEventManager.removeSelectionListener(SelectionChangedListener)
@Deprecated private static void fireSelectionChange(java.util.Collection<? extends OsmPrimitive> currentSelection)
currentSelection
- current selectionpublic java.util.Collection<OsmPrimitive> getSelectedNodesAndWays()
public java.util.Collection<WaySegment> getHighlightedVirtualNodes()
OsmData
getHighlightedVirtualNodes
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public java.util.Collection<WaySegment> getHighlightedWaySegments()
OsmData
getHighlightedWaySegments
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public void addHighlightUpdateListener(HighlightUpdateListener listener)
OsmData
addHighlightUpdateListener
in interface OsmData<OsmPrimitive,Node,Way,Relation>
listener
- The Listenerpublic void removeHighlightUpdateListener(HighlightUpdateListener listener)
OsmData
OsmData.addHighlightUpdateListener(HighlightUpdateListener)
removeHighlightUpdateListener
in interface OsmData<OsmPrimitive,Node,Way,Relation>
listener
- The Listenerpublic java.util.Collection<OsmPrimitive> getAllSelected()
OsmData
getAllSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public boolean selectionEmpty()
OsmData
selectionEmpty
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public boolean isSelected(OsmPrimitive osm)
OsmData
isSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
osm
- the primitiveosm
is selected or notpublic void setHighlightedVirtualNodes(java.util.Collection<WaySegment> waySegments)
OsmData
setHighlightedVirtualNodes
in interface OsmData<OsmPrimitive,Node,Way,Relation>
waySegments
- Collection of way segmentspublic void setHighlightedWaySegments(java.util.Collection<WaySegment> waySegments)
OsmData
setHighlightedWaySegments
in interface OsmData<OsmPrimitive,Node,Way,Relation>
waySegments
- Collection of way segmentspublic void setSelected(java.util.Collection<? extends PrimitiveId> selection)
OsmData
selection
and notifies all DataSelectionListener
.setSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
selection
- the selectionpublic void setSelected(PrimitiveId... osm)
OsmData
osm
and notifies all DataSelectionListener
.setSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
osm
- the primitives to set. null
values are ignored for now, but this may be removed in the future.private void setSelected(java.util.stream.Stream<? extends PrimitiveId> stream)
public void addSelected(java.util.Collection<? extends PrimitiveId> selection)
OsmData
selection
to the current selection
and notifies all DataSelectionListener
.addSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
selection
- the selectionpublic void addSelected(PrimitiveId... osm)
OsmData
osm
to the current selection
and notifies all DataSelectionListener
.addSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
osm
- the primitives to addprivate void addSelected(java.util.stream.Stream<? extends PrimitiveId> stream)
public void clearSelection(PrimitiveId... osm)
OsmData
clearSelection
in interface OsmData<OsmPrimitive,Node,Way,Relation>
osm
- The collection of ids to remove the selection from.public void clearSelection(java.util.Collection<? extends PrimitiveId> list)
OsmData
clearSelection
in interface OsmData<OsmPrimitive,Node,Way,Relation>
list
- The collection of ids to remove the selection from.public void clearSelection()
OsmData
clearSelection
in interface OsmData<OsmPrimitive,Node,Way,Relation>
private void clearSelection(java.util.stream.Stream<? extends PrimitiveId> stream)
public void toggleSelected(java.util.Collection<? extends PrimitiveId> osm)
OsmData
toggleSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
osm
- The primitives to togglepublic void toggleSelected(PrimitiveId... osm)
OsmData
toggleSelected
in interface OsmData<OsmPrimitive,Node,Way,Relation>
osm
- The primitives to toggleprivate void toggleSelected(java.util.stream.Stream<? extends PrimitiveId> stream)
private boolean doSelectionChange(java.util.function.Function<java.util.Set<OsmPrimitive>,DataSelectionListener.SelectionChangeEvent> command)
This is the only method that changes the current selection state.
command
- A generator that generates the DataSelectionListener.SelectionChangeEvent
for the given base set of currently selected primitives.public java.awt.geom.Area getDataSourceArea()
Data
getDataSourceArea
in interface Data
public java.util.List<Bounds> getDataSourceBounds()
Data
Replies the list of data source bounds.
Dataset maintains a list of data sources which have been merged into the data set. Each of these sources can optionally declare a bounding box of the data it supplied to the dataset.
This method replies the list of defined (non null
) bounding boxes.
getDataSourceBounds
in interface Data
public java.util.Collection<DataSource> getDataSources()
Data
getDataSources
in interface Data
public OsmPrimitive getPrimitiveById(PrimitiveId primitiveId)
OsmData
getPrimitiveById
in interface OsmData<OsmPrimitive,Node,Way,Relation>
primitiveId
- type and uniqueId of the primitive. Might be < 0 for newly created primitivesprivate OsmPrimitive getPrimitiveByIdChecked(PrimitiveId primitiveId)
primitiveId
- primitive id to look forpublic java.util.Set<Way> unlinkNodeFromWays(Node node)
node
- the nodejava.lang.IllegalStateException
- if the dataset is read-onlypublic java.util.Set<Relation> unlinkPrimitiveFromRelations(OsmPrimitive primitive)
primitive
- the primitivejava.lang.IllegalStateException
- if the dataset is read-onlypublic java.util.Set<OsmPrimitive> unlinkReferencesToPrimitive(OsmPrimitive referencedPrimitive)
referencedPrimitive
- the referenced primitivejava.lang.IllegalStateException
- if the dataset is read-onlypublic boolean isModified()
OsmData
IPrimitive.isModified()
== true
.isModified
in interface OsmData<OsmPrimitive,Node,Way,Relation>
IPrimitive.isModified()
== true
.public boolean requiresUploadToServer()
public void addDataSetListener(DataSetListener dsl)
dsl
- The data set listener to addpublic void removeDataSetListener(DataSetListener dsl)
dsl
- The data set listener to removepublic void beginUpdate()
endUpdate()
.
DataSetListener.dataChanged(DataChangedEvent event)
event is triggered after end of changes
ds.beginUpdate(); try { ... } finally { ds.endUpdate(); }
endUpdate()
public void endUpdate()
beginUpdate()
to fire change events.
ds.beginUpdate(); try { ... } finally { ds.endUpdate(); }
beginUpdate()
private void fireEventToListeners(AbstractDatasetChangedEvent event)
private void fireEvent(AbstractDatasetChangedEvent event)
void firePrimitivesAdded(java.util.Collection<? extends OsmPrimitive> added, boolean wasIncomplete)
void firePrimitivesRemoved(java.util.Collection<? extends OsmPrimitive> removed, boolean wasComplete)
void fireTagsChanged(OsmPrimitive prim, java.util.Map<java.lang.String,java.lang.String> originalKeys)
void fireRelationMembersChanged(Relation r)
void fireNodeMoved(Node node, LatLon newCoor, EastNorth eastNorth)
void fireWayNodesChanged(Way way)
void fireChangesetIdChanged(OsmPrimitive primitive, int oldChangesetId, int newChangesetId)
void firePrimitiveFlagsChanged(OsmPrimitive primitive)
void fireFilterChanged()
void fireHighlightingChanged()
public void invalidateEastNorthCache()
public void cleanupDeletedPrimitives()
public void clear()
public void deleteInvisible()
java.lang.IllegalStateException
- if the dataset is read-onlypublic void mergeFrom(DataSet from)
from
- The source DataSetpublic void mergeFrom(DataSet from, ProgressMonitor progressMonitor)
from
- The source DataSetprogressMonitor
- The progress monitorjava.lang.IllegalStateException
- if the dataset is read-onlypublic ConflictCollection getConflicts()
public java.lang.String getName()
OsmData
public void setName(java.lang.String name)
OsmData
public void projectionChanged(Projection oldValue, Projection newValue)
projectionChanged
in interface ProjectionChangeListener
public ProjectionBounds getDataSourceBoundingBox()
OsmData
getDataSourceBoundingBox
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public short getMappaintCacheIndex()
OsmPrimitive.mappaintCacheIdx
is not equal to the DataSet mappaint
cache index, this means the cache for that primitive is out of date.public void clearMappaintCache()
OsmData
clearMappaintCache
in interface OsmData<OsmPrimitive,Node,Way,Relation>
public void lock()
Lockable
public void unlock()
Lockable
public boolean isLocked()
Lockable
private void checkModifiable()
java.lang.IllegalStateException
- if the dataset is read-only