Class VectorPrimitive

java.lang.Object
org.openstreetmap.josm.data.osm.AbstractPrimitive
org.openstreetmap.josm.data.vector.VectorPrimitive
All Implemented Interfaces:
Comparable<IPrimitive>, IQuadBucketType, IFilterablePrimitive, IPrimitive, PrimitiveId, Stylable, Tagged, DataLayer<String>
Direct Known Subclasses:
VectorNode, VectorRelation, VectorWay

public abstract class VectorPrimitive extends AbstractPrimitive implements DataLayer<String>
The base class for Vector primitives
Since:
17862
  • Field Details

  • Constructor Details

    • VectorPrimitive

      protected VectorPrimitive(String layer)
      Create a primitive for a specific vector layer
      Parameters:
      layer - The layer for the primitive
  • Method Details

    • keysChangedImpl

      protected void keysChangedImpl(Map<String,String> originalKeys)
      Description copied from class: AbstractPrimitive
      What to do, when the tags have changed by one of the tag-changing methods.
      Specified by:
      keysChangedImpl in class AbstractPrimitive
      Parameters:
      originalKeys - original tags
    • isHighlighted

      public boolean isHighlighted()
      Description copied from interface: IPrimitive
      Checks if the highlight flag for this primitive was set
      Specified by:
      isHighlighted in interface IPrimitive
      Overrides:
      isHighlighted in class AbstractPrimitive
      Returns:
      The highlight flag.
    • setHighlighted

      public void setHighlighted(boolean highlighted)
      Description copied from interface: IPrimitive
      Updates the highlight flag for this primitive.
      Specified by:
      setHighlighted in interface IPrimitive
      Parameters:
      highlighted - The new highlight flag.
    • isAnnotated

      public boolean isAnnotated()
      Description copied from interface: IPrimitive
      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".
      Specified by:
      isAnnotated in interface IPrimitive
      Overrides:
      isAnnotated in class AbstractPrimitive
      Returns:
      true if this object is considered "annotated"
    • getDataSet

      Description copied from interface: IPrimitive
      Returns the parent data set of this primitive.
      Specified by:
      getDataSet in interface IPrimitive
      Returns:
      OsmData this primitive is part of.
    • setDataSet

      protected void setDataSet(VectorDataSet newDataSet)
    • getCachedStyle

      public final StyleCache getCachedStyle(ElemStyles elemStyles)
      Description copied from interface: Stylable
      Returns the cached style.
      Specified by:
      getCachedStyle in interface Stylable
      Parameters:
      elemStyles - styles for which the data is retrieved
      Returns:
      the cached style
    • setCachedStyle

      public final void setCachedStyle(ElemStyles elemStyles, StyleCache mappaintStyle)
      Description copied from interface: Stylable
      Sets the cached style.
      Specified by:
      setCachedStyle in interface Stylable
      Parameters:
      elemStyles - styles for which the data is stored
      mappaintStyle - the cached style
    • isCachedStyleUpToDate

      public final boolean isCachedStyleUpToDate(ElemStyles elemStyles)
      Description copied from interface: Stylable
      Check if the cached style for this primitive is up to date.
      Specified by:
      isCachedStyleUpToDate in interface Stylable
      Parameters:
      elemStyles - styles for which the data is checked
      Returns:
      true if the cached style for this primitive is up to date
    • declareCachedStyleUpToDate

      public final void declareCachedStyleUpToDate(ElemStyles elemStyles)
      Description copied from interface: Stylable
      Declare that the cached style for this primitive is up to date.
      Specified by:
      declareCachedStyleUpToDate in interface Stylable
      Parameters:
      elemStyles - styles for which the data is handled
    • clearCachedStyle

      public void clearCachedStyle()
      Description copied from interface: Stylable
      Clears the cached style. This should not be called from outside. Fixing the UI to add relevant get/set functions calling this implicitly is preferred, so we can have transparent cache handling in the future.
      Specified by:
      clearCachedStyle in interface Stylable
    • hasDirectionKeys

      public boolean hasDirectionKeys()
      Description copied from interface: IPrimitive
      true if this object has direction dependent tags (e.g. oneway)
      Specified by:
      hasDirectionKeys in interface IPrimitive
      Overrides:
      hasDirectionKeys in class AbstractPrimitive
      Returns:
      true if this object has direction dependent tags
    • reversedDirection

      public boolean reversedDirection()
      Description copied from interface: IPrimitive
      true if this object has the "reversed direction" flag enabled
      Specified by:
      reversedDirection in interface IPrimitive
      Overrides:
      reversedDirection in class AbstractPrimitive
      Returns:
      true if this object has the "reversed direction" flag enabled
    • getReferrers

      public final List<VectorPrimitive> getReferrers(boolean allowWithoutDataset)
      Description copied from interface: IPrimitive
      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)
      Specified by:
      getReferrers in interface IPrimitive
      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.
    • addReferrer

      protected void addReferrer(IPrimitive referrer)
      Add new referrer. If referrer is already included then no action is taken
      Parameters:
      referrer - The referrer to add
    • removeReferrer

      protected void removeReferrer(IPrimitive referrer)
      Remove referrer. No action is taken if referrer is not registered
      Parameters:
      referrer - The referrer to remove
    • referrers

      private <T extends IPrimitive> Stream<T> referrers(boolean allowWithoutDataset, Class<T> filter)
    • referrers

      public final <T extends IPrimitive> Stream<T> referrers(Class<T> filter)
      Gets all primitives in the current dataset that reference this primitive.
      Type Parameters:
      T - type of primitives
      Parameters:
      filter - restrict primitives to subclasses
      Returns:
      the referrers as Stream
    • visitReferrers

      public void visitReferrers(PrimitiveVisitor visitor)
      Description copied from interface: IPrimitive

      Visits visitor for all referrers.

      Specified by:
      visitReferrers in interface IPrimitive
      Parameters:
      visitor - the visitor. Ignored, if null.
    • doVisitReferrers

      private void doVisitReferrers(Consumer<IPrimitive> visitor)
    • setId

      protected void setId(long id)
      Set the id of the object
      Parameters:
      id - The id
    • setDisabled

      public void setDisabled(boolean disabled)
      Make this object disabled
      Parameters:
      disabled - true to disable the object
    • setVisible

      public void setVisible(boolean visible)
      Make this object visible
      Specified by:
      setVisible in interface IPrimitive
      Overrides:
      setVisible in class AbstractPrimitive
      Parameters:
      visible - true to make this object visible (default)
      See Also:
    • getLayer

      public String getLayer()
      Data layer information *
      Specified by:
      getLayer in interface DataLayer<String>
      Returns:
      The layer