Package org.openstreetmap.josm.data.osm
Interface IPrimitive
- All Superinterfaces:
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, Comparable<IPrimitive>
IPrimitive captures the common functions of
OsmPrimitive and PrimitiveData.- Since:
- 4098
-
Field Summary
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(PrimitiveVisitor visitor) Makes the given visitor visit this primitive.getBBox()Fetches the bounding box of the primitive.intReplies the id of the changeset this primitive was last uploaded to.default List<? extends IPrimitive>Get child primitives that are referred by this primitive.OsmData<?,?, ?, ?> Returns the parent data set of this primitive.getDisplayName(NameFormatter formatter) Replies the display name of a primitive formatted byformatterdefault OsmPrimitiveTypeGets the type this primitive is displayed atlonggetId()Replies the id of this primitive.Time of last modification to this object.ReturnsTagged.getKeys()for whichkeydoes not fulfill uninteresting criteria.default StringReplies 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 StringgetName()Replies the name of this primitive.default longgetOsmId()Replies the OSM id of this primitive.default PrimitiveIdReplies the OSM primitive id for this primitive.default PrimitiveIdReplies the unique primitive id for this primitive.intTime of last modification to this object.default List<? extends IPrimitive>Gets a list of all primitives in the current dataset that reference this primitive.List<? extends IPrimitive>getReferrers(boolean allowWithoutDataset) Find primitives that reference this primitive.default ObjectGet an object to synchronize the style cache on.getUser()Replies the user who has last touched this object.intReplies the version number as returned by the API.booleantrue 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.booleanDetermines if this object is considered "annotated".booleanRepliestrue, if the object has been deleted.default booleanReplies true, if this primitive is disabled.default booleanReplies true, if this primitive is disabled and marked as completely hidden on the map.default booleanDetermines if this object is drawable.booleanChecks if the highlight flag for this primitive was setbooleanDetermines if this primitive is incomplete.default booleanDetermines if this primitive is a member of a selected relation.booleanRepliestrueif the object has been modified since it was loaded from the server.default booleanDetermines if this object is a relation and behaves as a multipolygon.booleanDetermines if this primitive is new or undeleted.default booleanDetermines if this primitive is an outer member of a selected multipolygon relation.default booleanReplies true, if this primitive is preserved from filtering.default booleanDetermines if this primitive is fully downloadeddefault booleanDetermines if this object is selectable.default booleanDetermines whether the primitive is selectedbooleanisTagged()Determines if this object is considered "tagged".booleanDetermines if this primitive has no timestamp information.booleanRepliestrueif the object has been deleted on the server and was undeleted by the user.booleanisUsable()Repliestrue, if the object is usable (i.e.booleanChecks if object is known to the server.static voidResets primitive children, if applicable.booleantrue 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(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 referrersvoidSets 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 java.lang.Comparable
compareToMethods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getType, getUniqueId, isNewMethods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyleMethods 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 Details
-
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
Marks this primitive as being modified.- Parameters:
modified- true, if this primitive is to be modified
-
setReferrersDownloaded
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
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:
IllegalStateException- if visible is set to false on an primitive with id==0- See Also:
-
isDeleted
boolean isDeleted()Repliestrue, if the object has been deleted.- Returns:
true, if the object has been deleted.- See Also:
-
setDeleted
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
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:
-
isNewOrUndeleted
boolean isNewOrUndeleted()Determines if this primitive is new or undeleted.- Returns:
- True if primitive is new or undeleted
- See Also:
-
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
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
Replies true, if this primitive is preserved from filtering.- Returns:
trueif this object has the "preserved" flag enabled- Since:
- 13764
-
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
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
Determines whether the primitive is selected- Returns:
- whether the primitive is selected
- Since:
- 13664
-
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
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
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
Replies the OSM primitive id for this primitive.- Returns:
- the OSM primitive id for this primitive
- Since:
- 13924
- See Also:
-
getPrimitiveId
Replies the unique primitive id for this primitive.- Returns:
- the unique primitive id for this primitive
- See Also:
-
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:
-
setOsmId
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:
IllegalArgumentException- if id <= 0IllegalArgumentException- if version <= 0DataIntegrityProblemException- if id is changed and primitive was already added to the dataset
-
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
Sets the user who has last touched this object.- Parameters:
user- the user
-
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:
-
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:
-
setInstant
Sets time of last modification to this object- Parameters:
timestamp- date of last modification- See Also:
-
setRawTimestamp
Sets time of last modification to this object- Parameters:
timestamp- date of last modification- See Also:
-
isTimestampEmpty
boolean isTimestampEmpty()Determines if this primitive has no timestamp information.- Returns:
trueif this primitive has no timestamp information- See Also:
-
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
Sets the changeset id of this primitive. Can't be set on a new primitive.- Parameters:
changesetId- the id. >= 0 required.- Throws:
IllegalStateException- if this primitive is new.IllegalArgumentException- if id < 0
-
accept
Makes the given visitor visit this primitive.- Parameters:
visitor- visitor
-
visitReferrers
Visits
visitorfor all referrers.- Parameters:
visitor- the visitor. Ignored, if null.- Since:
- 13806
-
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
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:
-
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
Replies the display name of a primitive formatted byformatter- Parameters:
formatter- formatter to use- Returns:
- the display name
- Since:
- 13564
-
getDisplayType
Gets the type this primitive is displayed at- Returns:
- A
OsmPrimitiveType - Since:
- 13564
-
setHighlighted
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
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
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
Gets a list of all primitives in the current dataset that reference this primitive.- Returns:
- The referrers
- Since:
- 13764
-
getReferrers
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
ReturnsTagged.getKeys()for whichkeydoes not fulfill uninteresting criteria.- Returns:
- A map of interesting tags
- Since:
- 13809
-
hasSameInterestingTags
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
Resets primitive children, if applicable.- Parameters:
p- primitive- Since:
- 17981
-
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
-