Package org.openstreetmap.josm.data.osm
Interface IPrimitive
-
- All Superinterfaces:
java.lang.Comparable<IPrimitive>
,IQuadBucketType
,PrimitiveId
,Stylable
,Tagged
- All Known Implementing Classes:
AbstractPrimitive
,Node
,NodeData
,OsmPrimitive
,PrimitiveData
,Relation
,RelationData
,VectorNode
,VectorPrimitive
,VectorRelation
,VectorWay
,Way
,WayData
public interface IPrimitive extends IQuadBucketType, Tagged, PrimitiveId, Stylable, java.lang.Comparable<IPrimitive>
IPrimitive captures the common functions ofOsmPrimitive
andPrimitiveData
.- Since:
- 4098
-
-
Field Summary
-
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
accept(PrimitiveVisitor visitor)
Makes the given visitor visit this primitive.BBox
getBBox()
Fetches the bounding box of the primitive.int
getChangesetId()
Replies the id of the changeset this primitive was last uploaded to.default java.util.List<? extends IPrimitive>
getChildren()
Get child primitives that are referred by this primitive.OsmData<?,?,?,?>
getDataSet()
Returns the parent data set of this primitive.java.lang.String
getDisplayName(NameFormatter formatter)
Replies the display name of a primitive formatted byformatter
default OsmPrimitiveType
getDisplayType()
Gets the type this primitive is displayed atlong
getId()
Replies the id of this primitive.java.time.Instant
getInstant()
Time of last modification to this object.java.util.Map<java.lang.String,java.lang.String>
getInterestingTags()
ReturnsTagged.getKeys()
for whichkey
does not fulfill uninteresting criteria.default java.lang.String
getLocalName()
Replies a localized name for this primitive given by the value of the name tags accessed from very specific (language variant) to more generic (default name).default java.lang.String
getName()
Replies the name of this primitive.default long
getOsmId()
Replies the OSM id of this primitive.default PrimitiveId
getOsmPrimitiveId()
Replies the OSM primitive id for this primitive.default PrimitiveId
getPrimitiveId()
Replies the unique primitive id for this primitive.int
getRawTimestamp()
Time of last modification to this object.default java.util.List<? extends IPrimitive>
getReferrers()
Gets a list of all primitives in the current dataset that reference this primitive.java.util.List<? extends IPrimitive>
getReferrers(boolean allowWithoutDataset)
Find primitives that reference this primitive.default java.lang.Object
getStyleCacheSyncObject()
Get an object to synchronize the style cache on.java.util.Date
getTimestamp()
Deprecated.since 17749, usegetInstant()
insteadUser
getUser()
Replies the user who has last touched this object.int
getVersion()
Replies the version number as returned by the API.boolean
hasDirectionKeys()
true if this object has direction dependent tags (e.g.default boolean
hasSameInterestingTags(IPrimitive other)
Replies true if other isn't null and has the same interesting tags (key/value-pairs) as this.boolean
isAnnotated()
Determines if this object is considered "annotated".boolean
isDeleted()
Repliestrue
, if the object has been deleted.default boolean
isDisabled()
Replies true, if this primitive is disabled.default boolean
isDisabledAndHidden()
Replies true, if this primitive is disabled and marked as completely hidden on the map.default boolean
isDrawable()
Determines if this object is drawable.boolean
isHighlighted()
Checks if the highlight flag for this primitive was setboolean
isIncomplete()
Determines if this primitive is incomplete.default boolean
isMemberOfSelected()
Determines if this primitive is a member of a selected relation.boolean
isModified()
Repliestrue
if the object has been modified since it was loaded from the server.default boolean
isMultipolygon()
Determines if this object is a relation and behaves as a multipolygon.boolean
isNewOrUndeleted()
Determines if this primitive is new or undeleted.default boolean
isOuterMemberOfSelected()
Determines if this primitive is an outer member of a selected multipolygon relation.default boolean
isPreserved()
Replies true, if this primitive is preserved from filtering.default boolean
isReferrersDownloaded()
Determines if this primitive is fully downloadeddefault boolean
isSelectable()
Determines if this object is selectable.default boolean
isSelected()
Determines whether the primitive is selectedboolean
isTagged()
Determines if this object is considered "tagged".boolean
isTimestampEmpty()
Determines if this primitive has no timestamp information.boolean
isUndeleted()
Repliestrue
if the object has been deleted on the server and was undeleted by the user.boolean
isUsable()
Repliestrue
, if the object is usable (i.e.boolean
isVisible()
Checks if object is known to the server.static void
resetPrimitiveChildren(IPrimitive p)
Resets primitive children, if applicable.boolean
reversedDirection()
true if this object has the "reversed direction" flag enabledvoid
setChangesetId(int changesetId)
Sets the changeset id of this primitive.void
setDeleted(boolean deleted)
Sets whether this primitive is deleted or not.void
setHighlighted(boolean highlighted)
Updates the highlight flag for this primitive.void
setInstant(java.time.Instant timestamp)
Sets time of last modification to this objectvoid
setModified(boolean modified)
Marks this primitive as being modified.void
setOsmId(long id, int version)
Sets the id and the version of this primitive if it is known to the OSM API.void
setRawTimestamp(int timestamp)
Sets time of last modification to this objectdefault void
setReferrersDownloaded(boolean referrersDownloaded)
Set the status of the referrersvoid
setTimestamp(java.util.Date timestamp)
Deprecated.since 17749, usesetInstant(java.time.Instant)
insteadvoid
setUser(User user)
Sets the user who has last touched this object.void
setVisible(boolean visible)
Sets whether this primitive is visible, i.e.void
visitReferrers(PrimitiveVisitor visitor)
Visitsvisitor
for all referrers.-
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getType, getUniqueId, isNew
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyle
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Tagged
get, getKeys, getNumKeys, hasKey, hasKeys, hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, keys, keySet, put, put, putAll, remove, removeAll, setKeys, visitKeys
-
-
-
-
Method Detail
-
isModified
boolean isModified()
Repliestrue
if the object has been modified since it was loaded from the server. In this case, on next upload, this object will be updated.Deleted objects are deleted from the server. If the objects are added (id=0), the modified is ignored and the object is added to the server.
- Returns:
true
if the object has been modified since it was loaded from the server
-
setModified
void setModified(boolean modified)
Marks this primitive as being modified.- Parameters:
modified
- true, if this primitive is to be modified
-
setReferrersDownloaded
default void setReferrersDownloaded(boolean referrersDownloaded)
Set the status of the referrers- Parameters:
referrersDownloaded
-true
if all referrers for this object have been downloaded- Since:
- xxx
-
isVisible
boolean isVisible()
Checks if object is known to the server. Replies true if this primitive is either unknown to the server (i.e. its id is 0) or it is known to the server and it hasn't be deleted on the server. Replies false, if this primitive is known on the server and has been deleted on the server.- Returns:
true
, if the object is visible on server.- See Also:
setVisible(boolean)
-
setVisible
void setVisible(boolean visible)
Sets whether this primitive is visible, i.e. whether it is known on the server and not deleted on the server.- Parameters:
visible
-true
if this primitive is visible- Throws:
java.lang.IllegalStateException
- if visible is set to false on an primitive with id==0- See Also:
isVisible()
-
isDeleted
boolean isDeleted()
Repliestrue
, if the object has been deleted.- Returns:
true
, if the object has been deleted.- See Also:
setDeleted(boolean)
-
setDeleted
void setDeleted(boolean deleted)
Sets whether this primitive is deleted or not.Also marks this primitive as modified if deleted is true.
- Parameters:
deleted
- true, if this primitive is deleted; false, otherwise
-
isReferrersDownloaded
default boolean isReferrersDownloaded()
Determines if this primitive is fully downloaded- Returns:
true
if the primitive is fully downloaded and all parents and children should be available.false
otherwise.- Since:
- xxx
-
isIncomplete
boolean isIncomplete()
Determines if this primitive is incomplete.- Returns:
true
if this primitive is incomplete,false
otherwise
-
isUndeleted
boolean isUndeleted()
Repliestrue
if the object has been deleted on the server and was undeleted by the user.- Returns:
true
if the object has been undeleted
-
isUsable
boolean isUsable()
Repliestrue
, if the object is usable (i.e. complete and not deleted).- Returns:
true
, if the object is usable.- See Also:
setDeleted(boolean)
-
isNewOrUndeleted
boolean isNewOrUndeleted()
Determines if this primitive is new or undeleted.- Returns:
- True if primitive is new or undeleted
- See Also:
PrimitiveId.isNew()
,isUndeleted()
-
isDisabled
default boolean isDisabled()
Replies true, if this primitive is disabled. (E.g. a filter applies)- Returns:
true
if this object has the "disabled" flag enabled- Since:
- 13662
-
isDisabledAndHidden
default boolean isDisabledAndHidden()
Replies true, if this primitive is disabled and marked as completely hidden on the map.- Returns:
true
if this object has both the "disabled" and "hide if disabled" flags enabled- Since:
- 13662
-
isPreserved
default boolean isPreserved()
Replies true, if this primitive is preserved from filtering.- Returns:
true
if this object has the "preserved" flag enabled- Since:
- 13764
-
isSelectable
default boolean isSelectable()
Determines if this object is selectable.A primitive can be selected if all conditions are met:
- it is drawable
- it is not disabled (greyed out) by a filter.
- Returns:
true
if this object is selectable- Since:
- 13664
-
isDrawable
default boolean isDrawable()
Determines if this object is drawable.A primitive is drawable if all conditions are met:
- type and id is known
- tags are known
- it is not deleted
- it is not hidden by a filter
- for nodes: lat/lon are known
- for ways: all nodes are known and complete
- for relations: all members are known and complete
- Returns:
true
if this object is drawable- Since:
- 13664
-
isSelected
default boolean isSelected()
Determines whether the primitive is selected- Returns:
- whether the primitive is selected
- Since:
- 13664
-
isMemberOfSelected
default boolean isMemberOfSelected()
Determines if this primitive is a member of a selected relation.- Returns:
true
if this primitive is a member of a selected relation,false
otherwise- Since:
- 13664
-
isOuterMemberOfSelected
default boolean isOuterMemberOfSelected()
Determines if this primitive is an outer member of a selected multipolygon relation.- Returns:
true
if this primitive is an outer member of a selected multipolygon relation,false
otherwise- Since:
- 13664
-
getId
long getId()
Replies the id of this primitive.- Returns:
- the id of this primitive.
-
getOsmId
default long getOsmId()
Replies the OSM id of this primitive. By default, returns the same value asgetId()
. Can be overridden by primitive implementations handling an internal id different from the OSM one.- Returns:
- the OSM id of this primitive.
- Since:
- 13924
-
getOsmPrimitiveId
default PrimitiveId getOsmPrimitiveId()
Replies the OSM primitive id for this primitive.- Returns:
- the OSM primitive id for this primitive
- Since:
- 13924
- See Also:
getOsmId()
-
getPrimitiveId
default PrimitiveId getPrimitiveId()
Replies the unique primitive id for this primitive.- Returns:
- the unique primitive id for this primitive
- See Also:
PrimitiveId.getUniqueId()
-
getVersion
int getVersion()
Replies the version number as returned by the API. The version is 0 if the id is 0 or if this primitive is incomplete.- Returns:
- the version number as returned by the API
- See Also:
PrimitiveData.setVersion(int)
-
setOsmId
void setOsmId(long id, int version)
Sets the id and the version of this primitive if it is known to the OSM API.Since we know the id and its version it can't be incomplete anymore. incomplete is set to false.
- Parameters:
id
- the id. > 0 requiredversion
- the version > 0 required- Throws:
java.lang.IllegalArgumentException
- if id <= 0java.lang.IllegalArgumentException
- if version <= 0DataIntegrityProblemException
- if id is changed and primitive was already added to the dataset
-
getUser
User getUser()
Replies the user who has last touched this object. May be null.- Returns:
- the user who has last touched this object. May be null.
-
setUser
void setUser(User user)
Sets the user who has last touched this object.- Parameters:
user
- the user
-
getTimestamp
@Deprecated(since="17749") java.util.Date getTimestamp()
Deprecated.since 17749, usegetInstant()
insteadTime of last modification to this object. This is not set by JOSM but read from the server and delivered back to the server unmodified. It is used to check against edit conflicts.- Returns:
- date of last modification
- See Also:
setTimestamp(java.util.Date)
-
getInstant
java.time.Instant getInstant()
Time of last modification to this object. This is not set by JOSM but read from the server and delivered back to the server unmodified. It is used to check against edit conflicts.- Returns:
- date of last modification
- See Also:
setInstant(java.time.Instant)
-
getRawTimestamp
int getRawTimestamp()
Time of last modification to this object. This is not set by JOSM but read from the server and delivered back to the server unmodified. It is used to check against edit conflicts.- Returns:
- last modification as timestamp
- See Also:
setRawTimestamp(int)
-
setTimestamp
@Deprecated(since="17749") void setTimestamp(java.util.Date timestamp)
Deprecated.since 17749, usesetInstant(java.time.Instant)
insteadSets time of last modification to this object- Parameters:
timestamp
- date of last modification- See Also:
getTimestamp()
-
setInstant
void setInstant(java.time.Instant timestamp)
Sets time of last modification to this object- Parameters:
timestamp
- date of last modification- See Also:
getInstant()
-
setRawTimestamp
void setRawTimestamp(int timestamp)
Sets time of last modification to this object- Parameters:
timestamp
- date of last modification- See Also:
getRawTimestamp()
-
isTimestampEmpty
boolean isTimestampEmpty()
Determines if this primitive has no timestamp information.- Returns:
true
if this primitive has no timestamp information- See Also:
getTimestamp()
,getRawTimestamp()
-
getChangesetId
int getChangesetId()
Replies the id of the changeset this primitive was last uploaded to. 0 if this primitive wasn't uploaded to a changeset yet or if the changeset isn't known.- Returns:
- the id of the changeset this primitive was last uploaded to.
-
setChangesetId
void setChangesetId(int changesetId)
Sets the changeset id of this primitive. Can't be set on a new primitive.- Parameters:
changesetId
- the id. >= 0 required.- Throws:
java.lang.IllegalStateException
- if this primitive is new.java.lang.IllegalArgumentException
- if id < 0
-
accept
void accept(PrimitiveVisitor visitor)
Makes the given visitor visit this primitive.- Parameters:
visitor
- visitor
-
visitReferrers
void visitReferrers(PrimitiveVisitor visitor)
Visits
visitor
for all referrers.- Parameters:
visitor
- the visitor. Ignored, if null.- Since:
- 13806
-
getName
default java.lang.String getName()
Replies the name of this primitive. The default implementation replies the value of the tagname
or null, if this tag is not present.- Returns:
- the name of this primitive
-
getLocalName
default java.lang.String getLocalName()
Replies a localized name for this primitive given by the value of the name tags accessed from very specific (language variant) to more generic (default name).- Returns:
- the name of this primitive,
null
if no name exists - See Also:
LanguageInfo.getOSMLocaleCodes(java.lang.String)
-
getStyleCacheSyncObject
default java.lang.Object getStyleCacheSyncObject()
Get an object to synchronize the style cache on. This should be a field that does not change during paint. By default, it returns the current object, but should be overridden to avoid some performance issues.- Returns:
- A non-
null
object to synchronize on when painting
-
getDisplayName
java.lang.String getDisplayName(NameFormatter formatter)
Replies the display name of a primitive formatted byformatter
- Parameters:
formatter
- formatter to use- Returns:
- the display name
- Since:
- 13564
-
getDisplayType
default OsmPrimitiveType getDisplayType()
Gets the type this primitive is displayed at- Returns:
- A
OsmPrimitiveType
- Since:
- 13564
-
setHighlighted
void setHighlighted(boolean highlighted)
Updates the highlight flag for this primitive.- Parameters:
highlighted
- The new highlight flag.- Since:
- 13664
-
isHighlighted
boolean isHighlighted()
Checks if the highlight flag for this primitive was set- Returns:
- The highlight flag.
- Since:
- 13664
-
isTagged
boolean isTagged()
Determines if this object is considered "tagged". To be "tagged", an object must have one or more "interesting" tags. "created_by" and "source" are typically considered "uninteresting" and do not make an object "tagged".- Returns:
- true if this object is considered "tagged"
- Since:
- 13662
-
isAnnotated
boolean isAnnotated()
Determines if this object is considered "annotated". To be "annotated", an object must have one or more "work in progress" tags, such as "note" or "fixme".- Returns:
- true if this object is considered "annotated"
- Since:
- 13662
-
isMultipolygon
default boolean isMultipolygon()
Determines if this object is a relation and behaves as a multipolygon.- Returns:
true
if it is a real multipolygon or a boundary relation- Since:
- 13667
-
hasDirectionKeys
boolean hasDirectionKeys()
true if this object has direction dependent tags (e.g. oneway)- Returns:
true
if this object has direction dependent tags- Since:
- 13662
-
reversedDirection
boolean reversedDirection()
true if this object has the "reversed direction" flag enabled- Returns:
true
if this object has the "reversed direction" flag enabled- Since:
- 13662
-
getBBox
BBox getBBox()
Fetches the bounding box of the primitive. Since 17752, the returned bounding box might be immutable, i.e., modifying calls throw anUnsupportedOperationException
.- Specified by:
getBBox
in interfaceIQuadBucketType
- Returns:
- Bounding box of the object
- Since:
- 13764
-
getReferrers
default java.util.List<? extends IPrimitive> getReferrers()
Gets a list of all primitives in the current dataset that reference this primitive.- Returns:
- The referrers
- Since:
- 13764
-
getReferrers
java.util.List<? extends IPrimitive> getReferrers(boolean allowWithoutDataset)
Find primitives that reference this primitive. Returns only primitives that are included in the same dataset as this primitive.
For example following code will add wnew as referer to all nodes of existingWay, but this method will not return wnew because it's not part of the dataset
Way wnew = new Way(existingWay)
- Parameters:
allowWithoutDataset
- If true, method will return empty list if primitive is not part of the dataset. If false, exception will be thrown in this case- Returns:
- a collection of all primitives that reference this primitive.
- Since:
- 13808
-
getDataSet
OsmData<?,?,?,?> getDataSet()
Returns the parent data set of this primitive.- Returns:
- OsmData this primitive is part of.
- Since:
- 13807
-
getInterestingTags
java.util.Map<java.lang.String,java.lang.String> getInterestingTags()
ReturnsTagged.getKeys()
for whichkey
does not fulfill uninteresting criteria.- Returns:
- A map of interesting tags
- Since:
- 13809
-
hasSameInterestingTags
default boolean hasSameInterestingTags(IPrimitive other)
Replies true if other isn't null and has the same interesting tags (key/value-pairs) as this.- Parameters:
other
- the other object primitive- Returns:
- true if other isn't null and has the same interesting tags (key/value-pairs) as this.
- Since:
- 13809
-
resetPrimitiveChildren
static void resetPrimitiveChildren(IPrimitive p)
Resets primitive children, if applicable.- Parameters:
p
- primitive- Since:
- 17981
-
getChildren
default java.util.List<? extends IPrimitive> getChildren()
Get child primitives that are referred by this primitive.Relation
: Members of the relationWay
: Nodes used by the wayNode
: None- Returns:
- List of child primitives
- Since:
- 18814
-
-