Interface IPrimitive

    • Method Detail

      • 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:
        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()
        Replies true, 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()
        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:
        setDeleted(boolean)
      • 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

        default PrimitiveId getOsmPrimitiveId()
        Replies the OSM primitive id for this primitive.
        Returns:
        the OSM primitive id for this primitive
        Since:
        13924
        See Also:
        getOsmId()
      • 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 required
        version - the version > 0 required
        Throws:
        java.lang.IllegalArgumentException - if id <= 0
        java.lang.IllegalArgumentException - if version <= 0
        DataIntegrityProblemException - 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, use getInstant() instead
        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:
        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, use setInstant(java.time.Instant) instead
        Sets 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()
      • 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 tag name 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 by formatter
        Parameters:
        formatter - formatter to use
        Returns:
        the display name
        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 an UnsupportedOperationException.
        Specified by:
        getBBox in interface IQuadBucketType
        Returns:
        Bounding box of the object
        Since:
        13764
      • getReferrers

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

        java.util.List<? extends IPrimitivegetReferrers​(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()
        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

        static void resetPrimitiveChildren​(IPrimitive p)
        Resets primitive children, if applicable.
        Parameters:
        p - primitive
        Since:
        17981
      • getChildren

        default java.util.List<? extends IPrimitivegetChildren()
        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