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 ofOsmPrimitiveandPrimitiveData.- 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 Modifier and Type Method Description voidaccept(PrimitiveVisitor visitor)Makes the given visitor visit this primitive.BBoxgetBBox()Fetches the bounding box of the primitive.intgetChangesetId()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.StringgetDisplayName(NameFormatter formatter)Replies the display name of a primitive formatted byformatterdefault OsmPrimitiveTypegetDisplayType()Gets the type this primitive is displayed atlonggetId()Replies the id of this primitive.java.time.InstantgetInstant()Time of last modification to this object.java.util.Map<java.lang.String,java.lang.String>getInterestingTags()ReturnsTagged.getKeys()for whichkeydoes not fulfill uninteresting criteria.default java.lang.StringgetLocalName()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.StringgetName()Replies the name of this primitive.default longgetOsmId()Replies the OSM id of this primitive.default PrimitiveIdgetOsmPrimitiveId()Replies the OSM primitive id for this primitive.default PrimitiveIdgetPrimitiveId()Replies the unique primitive id for this primitive.intgetRawTimestamp()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.ObjectgetStyleCacheSyncObject()Get an object to synchronize the style cache on.UsergetUser()Replies the user who has last touched this object.intgetVersion()Replies the version number as returned by the API.booleanhasDirectionKeys()true if this object has direction dependent tags (e.g.default booleanhasSameInterestingTags(IPrimitive other)Replies true if other isn't null and has the same interesting tags (key/value-pairs) as this.booleanisAnnotated()Determines if this object is considered "annotated".booleanisDeleted()Repliestrue, if the object has been deleted.default booleanisDisabled()Replies true, if this primitive is disabled.default booleanisDisabledAndHidden()Replies true, if this primitive is disabled and marked as completely hidden on the map.default booleanisDrawable()Determines if this object is drawable.booleanisHighlighted()Checks if the highlight flag for this primitive was setbooleanisIncomplete()Determines if this primitive is incomplete.default booleanisMemberOfSelected()Determines if this primitive is a member of a selected relation.booleanisModified()Repliestrueif the object has been modified since it was loaded from the server.default booleanisMultipolygon()Determines if this object is a relation and behaves as a multipolygon.booleanisNewOrUndeleted()Determines if this primitive is new or undeleted.default booleanisOuterMemberOfSelected()Determines if this primitive is an outer member of a selected multipolygon relation.default booleanisPreserved()Replies true, if this primitive is preserved from filtering.default booleanisReferrersDownloaded()Determines if this primitive is fully downloadeddefault booleanisSelectable()Determines if this object is selectable.default booleanisSelected()Determines whether the primitive is selectedbooleanisTagged()Determines if this object is considered "tagged".booleanisTimestampEmpty()Determines if this primitive has no timestamp information.booleanisUndeleted()Repliestrueif the object has been deleted on the server and was undeleted by the user.booleanisUsable()Repliestrue, if the object is usable (i.e.booleanisVisible()Checks if object is known to the server.static voidresetPrimitiveChildren(IPrimitive p)Resets primitive children, if applicable.booleanreversedDirection()true if this object has the "reversed direction" flag enabledvoidsetChangesetId(int changesetId)Sets the changeset id of this primitive.voidsetDeleted(boolean deleted)Sets whether this primitive is deleted or not.voidsetHighlighted(boolean highlighted)Updates the highlight flag for this primitive.voidsetInstant(java.time.Instant timestamp)Sets time of last modification to this objectvoidsetModified(boolean modified)Marks this primitive as being modified.voidsetOsmId(long id, int version)Sets the id and the version of this primitive if it is known to the OSM API.voidsetRawTimestamp(int timestamp)Sets time of last modification to this objectdefault voidsetReferrersDownloaded(boolean referrersDownloaded)Set the status of the referrersvoidsetUser(User user)Sets the user who has last touched this object.voidsetVisible(boolean visible)Sets whether this primitive is visible, i.e.voidvisitReferrers(PrimitiveVisitor visitor)Visitsvisitorfor 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()
Repliestrueif 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:
trueif 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-trueif all referrers for this object have been downloaded- Since:
- 19078
-
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-trueif 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:
trueif the primitive is fully downloaded and all parents and children should be available.falseotherwise.- Since:
- 19078
-
isIncomplete
boolean isIncomplete()
Determines if this primitive is incomplete.- Returns:
trueif this primitive is incomplete,falseotherwise
-
isUndeleted
boolean isUndeleted()
Repliestrueif the object has been deleted on the server and was undeleted by the user.- Returns:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif this primitive is a member of a selected relation,falseotherwise- Since:
- 13664
-
isOuterMemberOfSelected
default boolean isOuterMemberOfSelected()
Determines if this primitive is an outer member of a selected multipolygon relation.- Returns:
trueif this primitive is an outer member of a selected multipolygon relation,falseotherwise- 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
-
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)
-
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:
trueif this primitive has no timestamp information- See Also:
getInstant(),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
visitorfor 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 tagnameor 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,
nullif 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-
nullobject 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:
trueif 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:
trueif this object has direction dependent tags- Since:
- 13662
-
reversedDirection
boolean reversedDirection()
true if this object has the "reversed direction" flag enabled- Returns:
trueif 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:
getBBoxin 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 whichkeydoes 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
-
-