Class VectorPrimitive
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.AbstractPrimitive
-
- org.openstreetmap.josm.data.vector.VectorPrimitive
-
- All Implemented Interfaces:
java.lang.Comparable<IPrimitive>
,IQuadBucketType
,IFilterablePrimitive
,IPrimitive
,PrimitiveId
,Stylable
,Tagged
,DataLayer<java.lang.String>
- Direct Known Subclasses:
VectorNode
,VectorRelation
,VectorWay
public abstract class VectorPrimitive extends AbstractPrimitive implements DataLayer<java.lang.String>
The base class for Vector primitives- Since:
- 17862
-
-
Field Summary
Fields Modifier and Type Field Description private VectorDataSet
dataSet
private boolean
highlighted
private java.lang.String
layer
private StyleCache
mappaintStyle
private java.lang.Object
referrers
-
Fields inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
changesetId, FLAG_ALL_REFERRERS_DOWNLOADED, FLAG_ANNOTATED, FLAG_DELETED, FLAG_DIRECTION_REVERSED, FLAG_DISABLED, FLAG_DISABLED_TYPE, FLAG_HAS_DIRECTIONS, FLAG_HIDDEN_TYPE, FLAG_HIDE_IF_DISABLED, FLAG_HIGHLIGHTED, FLAG_INCOMPLETE, FLAG_MODIFIED, FLAG_PRESERVED, FLAG_TAGGED, FLAG_VISIBLE, flags, id, keys, mappaintCacheIdx, timestamp, user, version
-
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
VectorPrimitive(java.lang.String layer)
Create a primitive for a specific vector layer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addReferrer(IPrimitive referrer)
Add new referrer.void
declareCachedStyleUpToDate()
Declare that the cached style for this primitive is up to date.private void
doVisitReferrers(java.util.function.Consumer<IPrimitive> visitor)
StyleCache
getCachedStyle()
Returns the cached style.VectorDataSet
getDataSet()
Returns the parent data set of this primitive.java.lang.String
getLayer()
Data layer information *java.util.List<VectorPrimitive>
getReferrers(boolean allowWithoutDataset)
Find primitives that reference this primitive.boolean
hasDirectionKeys()
true if this object has direction dependent tags (e.g.boolean
isAnnotated()
Determines if this object is considered "annotated".boolean
isCachedStyleUpToDate()
Check if the cached style for this primitive is up to date.boolean
isHighlighted()
Checks if the highlight flag for this primitive was setprotected void
keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
What to do, when the tags have changed by one of the tag-changing methods.private <T extends IPrimitive>
java.util.stream.Stream<T>referrers(boolean allowWithoutDataset, java.lang.Class<T> filter)
<T extends IPrimitive>
java.util.stream.Stream<T>referrers(java.lang.Class<T> filter)
Gets all primitives in the current dataset that reference this primitive.protected void
removeReferrer(IPrimitive referrer)
Remove referrer.boolean
reversedDirection()
true if this object has the "reversed direction" flag enabledvoid
setCachedStyle(StyleCache mappaintStyle)
Sets the cached style.protected void
setDataSet(VectorDataSet newDataSet)
void
setDisabled(boolean disabled)
Make this object disabledvoid
setHighlighted(boolean highlighted)
Updates the highlight flag for this primitive.protected void
setId(long id)
Set the id of the objectvoid
setVisible(boolean visible)
Make this object visiblevoid
visitReferrers(PrimitiveVisitor visitor)
Visitsvisitor
for all referrers.-
Methods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive
clearOsmMetadata, cloneFrom, doGet, get, getChangesetId, getDisabledType, getDiscardableKeys, getFlagsAsString, getHiddenType, getId, getIdGenerator, getIgnoreCase, getInstant, getInterestingTags, getKeys, getNumKeys, getRawTimestamp, getTimestamp, getUninterestingKeys, getUniqueId, getUser, getVersion, getWorkInProgressKeys, hasKey, hasKey, hasKeys, isDeleted, isDisabled, isDisabledAndHidden, isDrawable, isIncomplete, isModified, isNew, isNewOrUndeleted, isPreserved, isReferrersDownloaded, isTagged, isTimestampEmpty, isUndeleted, isUninterestingKey, isUsable, isVisible, keys, keySet, put, putAll, remove, removeAll, setChangesetId, setDeleted, setDisabledState, setDisabledType, setHiddenType, setIncomplete, setInstant, setKeys, setKeys, setModified, setOsmId, setRawTimestamp, setReferrersDownloaded, setTimestamp, setUser, unsetDisabledState, updateFlags, updateFlagsChanged, visitKeys
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
accept, getBBox, getChildren, getDisplayName, getDisplayType, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getReferrers, getStyleCacheSyncObject, hasSameInterestingTags, isMemberOfSelected, isMultipolygon, isOuterMemberOfSelected, isSelectable, isSelected
-
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getType
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Tagged
hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, put
-
-
-
-
Field Detail
-
dataSet
private VectorDataSet dataSet
-
highlighted
private boolean highlighted
-
mappaintStyle
private StyleCache mappaintStyle
-
layer
private final java.lang.String layer
-
referrers
private java.lang.Object referrers
-
-
Constructor Detail
-
VectorPrimitive
protected VectorPrimitive(java.lang.String layer)
Create a primitive for a specific vector layer- Parameters:
layer
- The layer for the primitive
-
-
Method Detail
-
keysChangedImpl
protected void keysChangedImpl(java.util.Map<java.lang.String,java.lang.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 classAbstractPrimitive
- 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 interfaceIPrimitive
- Overrides:
isHighlighted
in classAbstractPrimitive
- 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 interfaceIPrimitive
- 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 interfaceIPrimitive
- Overrides:
isAnnotated
in classAbstractPrimitive
- Returns:
- true if this object is considered "annotated"
-
getDataSet
public VectorDataSet getDataSet()
Description copied from interface:IPrimitive
Returns the parent data set of this primitive.- Specified by:
getDataSet
in interfaceIPrimitive
- Returns:
- OsmData this primitive is part of.
-
setDataSet
protected void setDataSet(VectorDataSet newDataSet)
-
getCachedStyle
public final StyleCache getCachedStyle()
Description copied from interface:Stylable
Returns the cached style.- Specified by:
getCachedStyle
in interfaceStylable
- Returns:
- the cached style
-
setCachedStyle
public final void setCachedStyle(StyleCache mappaintStyle)
Description copied from interface:Stylable
Sets the cached style.- Specified by:
setCachedStyle
in interfaceStylable
- Parameters:
mappaintStyle
- the cached style
-
isCachedStyleUpToDate
public final boolean isCachedStyleUpToDate()
Description copied from interface:Stylable
Check if the cached style for this primitive is up to date.- Specified by:
isCachedStyleUpToDate
in interfaceStylable
- Returns:
- true if the cached style for this primitive is up to date
-
declareCachedStyleUpToDate
public final void declareCachedStyleUpToDate()
Description copied from interface:Stylable
Declare that the cached style for this primitive is up to date.- Specified by:
declareCachedStyleUpToDate
in interfaceStylable
-
hasDirectionKeys
public boolean hasDirectionKeys()
Description copied from interface:IPrimitive
true if this object has direction dependent tags (e.g. oneway)- Specified by:
hasDirectionKeys
in interfaceIPrimitive
- Overrides:
hasDirectionKeys
in classAbstractPrimitive
- 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 interfaceIPrimitive
- Overrides:
reversedDirection
in classAbstractPrimitive
- Returns:
true
if this object has the "reversed direction" flag enabled
-
getReferrers
public final java.util.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 interfaceIPrimitive
- 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> java.util.stream.Stream<T> referrers(boolean allowWithoutDataset, java.lang.Class<T> filter)
-
referrers
public final <T extends IPrimitive> java.util.stream.Stream<T> referrers(java.lang.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 interfaceIPrimitive
- Parameters:
visitor
- the visitor. Ignored, if null.
-
doVisitReferrers
private void doVisitReferrers(java.util.function.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 interfaceIPrimitive
- Overrides:
setVisible
in classAbstractPrimitive
- Parameters:
visible
-true
to make this object visible (default)- See Also:
IPrimitive.isVisible()
-
-