Interface IPrimitive

All Superinterfaces:
Comparable<IPrimitive>, IQuadBucketType, PrimitiveId, Stylable, Tagged
All Known Subinterfaces:
INode, IRelation<M>, IWay<N>
All Known Implementing Classes:
AbstractPrimitive, Node, NodeData, OsmPrimitive, PrimitiveData, Relation, RelationData, VectorNode, VectorPrimitive, VectorRelation, VectorWay, Way, WayData

IPrimitive captures the common functions of OsmPrimitive and PrimitiveData.
Since:
4098
  • Method Details

    • isModified

      boolean isModified()
      Replies true 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:
      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

      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:
      IllegalStateException - if visible is set to false on an primitive with id==0
      See Also:
    • isDeleted

      boolean isDeleted()
      Replies true, if the object has been deleted.
      Returns:
      true, if the object has been deleted.
      See Also:
    • 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:
      19078
    • isIncomplete

      boolean isIncomplete()
      Determines if this primitive is incomplete.
      Returns:
      true if this primitive is incomplete, false otherwise
    • isUndeleted

      boolean isUndeleted()
      Replies true 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()
      Replies true, 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

      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 as getId(). 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

      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 required
      version - the version > 0 required
      Throws:
      IllegalArgumentException - if id <= 0
      IllegalArgumentException - if version <= 0
      DataIntegrityProblemException - 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

      void setUser(User user)
      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

      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

      void setInstant(Instant timestamp)
      Sets time of last modification to this object
      Parameters:
      timestamp - date of last modification
      See Also:
    • setRawTimestamp

      void setRawTimestamp(int timestamp)
      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:
      true if this primitive has no timestamp information
      See Also:
    • 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:
      IllegalStateException - if this primitive is new.
      IllegalArgumentException - if id < 0
    • accept

      void accept(PrimitiveVisitor visitor)
      Makes the given visitor visit this primitive.
      Parameters:
      visitor - visitor
    • visitReferrers

      Visits visitor for all referrers.

      Parameters:
      visitor - the visitor. Ignored, if null.
      Since:
      13806
    • getName

      default String getName()
      Replies the name of this primitive. The default implementation replies the value of the tag name or null, if this tag is not present.
      Returns:
      the name of this primitive
    • getLocalName

      default 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:
    • 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

      Replies the display name of a primitive formatted by formatter
      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

      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

      true if this object has the "reversed direction" flag enabled
      Returns:
      true if 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 an UnsupportedOperationException.
      Specified by:
      getBBox in interface IQuadBucketType
      Returns:
      Bounding box of the object
      Since:
      13764
    • getReferrers

      default List<? extends IPrimitive> getReferrers()
      Gets a list of all primitives in the current dataset that reference this primitive.
      Returns:
      The referrers
      Since:
      13764
    • getReferrers

      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

      Returns Tagged.getKeys() for which key 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

      Resets primitive children, if applicable.
      Parameters:
      p - primitive
      Since:
      17981
    • getChildren

      default List<? extends IPrimitive> getChildren()
      Get child primitives that are referred by this primitive. Relation: Members of the relation Way: Nodes used by the way Node: None
      Returns:
      List of child primitives
      Since:
      18814