Class Environment
java.lang.Object
org.openstreetmap.josm.gui.mappaint.Environment
Environment is a data object to provide access to various "global" parameters.
It is used during processing of MapCSS rules and for the generation of
style elements.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe same for parent selector.Set of matched children filled by ContainsFinder and CrossingFinder, null if nothing matchedprivate Condition.Contextcount of nodes in parent way or members in parent relation.Map<IPrimitive,Map<List<Way>, List<WaySegment>>> Crossing ways result from CrossingFinder, filled for incomplete ways/relationsstatic final StringThe name of the default layer.index of node in parent way or member in parent relation.Intersection areas (only filled with CrossingFinder if children is not null)The current MapCSS layerThe cascades that are currently evaluatedCache for multipolygon areas, can be null, used with CrossingFinderMap<IRelation<?>,Pair<List<MultipolygonBuilder.JoinedPolygon>, List<MultipolygonBuilder.JoinedPolygon>>> Cache for multipolygon areas as calculated byMultipolygonBuilder.joinWays(Relation), can benullThe primitive that is currently evaluatedIf not null, this is the matching parent object if a condition or an expression is evaluated in aSelector.LinkSelector(within a child selector)private final SelectorThe selector that is currently being evaluatedThe style source that is evaluatedCan be null, may contain primitives when surrounding objects of the primitives are tested -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new uninitialized environment.Environment(IPrimitive osm) Creates a new environment.Environment(IPrimitive osm, MultiCascade mc, String layer, StyleSource source) Creates a new environment.Environment(Environment other) Creates a clone of the environmentother.privateEnvironment(Environment other, Selector selector) Creates a clone of the environmentother. -
Method Summary
Modifier and TypeMethodDescriptionClears all matching context informationGets the current cascade for the current layer of this environmentgetCascade(String layer) Gets the current cascade for a given layerReplies the current context.getRole()Gets the role of the matching primitive in the relationbooleanDetermines if this environment has a relation as parent.booleanDetermines if the context of this environment isCondition.Context.LINK.selector()Get the selector for this environmentwithChild(IPrimitive child) Creates a clone of this environment, with the specified child.withChildAndIndexAndLinkContext(IPrimitive child, int index, int count) Creates a clone of this environment, with the specified child, index, and context set toCondition.Context.LINK.withContext(Condition.Context context) Creates a clone of this environment, with the specifiedCondition.Context.withIndex(int index, int count) Creates a clone of this environment, with the specified index.Creates a clone of this environment, with context set toCondition.Context.LINK.withParent(IPrimitive parent) Creates a clone of this environment, with the specified parent.withParentAndIndexAndLinkContext(IPrimitive parent, int index, int count) Creates a clone of this environment, with the specified parent, index, and context set toCondition.Context.LINK.withPrimitive(IPrimitive osm) Creates a clone of this environment, with the specified primitive.withSelector(Selector selector) Creates a clone of this environment, with the selector set
-
Field Details
-
osm
The primitive that is currently evaluated -
mc
The cascades that are currently evaluated -
layer
The current MapCSS layer -
source
The style source that is evaluated -
context
-
selector
The selector that is currently being evaluated -
DEFAULT_LAYER
The name of the default layer. It is used if no layer is specified in the MapCSS rule- See Also:
-
parent
If not null, this is the matching parent object if a condition or an expression is evaluated in aSelector.LinkSelector(within a child selector) -
child
The same for parent selector. Only one of the 2 fields (parent or child) is not null in any environment. -
index
index of node in parent way or member in parent relation. Must be != null in LINK context. -
count
count of nodes in parent way or members in parent relation. Must be != null in LINK context. -
children
Set of matched children filled by ContainsFinder and CrossingFinder, null if nothing matched -
crossingWaysMap
Crossing ways result from CrossingFinder, filled for incomplete ways/relations -
intersections
Intersection areas (only filled with CrossingFinder if children is not null) -
mpAreaCache
Cache for multipolygon areas, can be null, used with CrossingFinder -
mpJoinedAreaCache
public Map<IRelation<?>,Pair<List<MultipolygonBuilder.JoinedPolygon>, mpJoinedAreaCacheList<MultipolygonBuilder.JoinedPolygon>>> Cache for multipolygon areas as calculated byMultipolygonBuilder.joinWays(Relation), can benull -
toMatchForSurrounding
Can be null, may contain primitives when surrounding objects of the primitives are tested
-
-
Constructor Details
-
Environment
public Environment()Creates a new uninitialized environment. -
Environment
Creates a new environment.- Parameters:
osm- OSM primitive- Since:
- 8415, 13810 (signature)
-
Environment
Creates a new environment.- Parameters:
osm- OSM primitivemc- multi cascadelayer- layersource- style source- Since:
- 13810 (signature)
-
Environment
Creates a clone of the environmentother.- Parameters:
other- the other environment. Must not be null.- Throws:
IllegalArgumentException- ifparamisnull
-
Environment
Creates a clone of the environmentother.- Parameters:
other- the other environment. Must not be null.selector- the selector for this environment. May be null.- Throws:
IllegalArgumentException- ifparamisnull
-
-
Method Details
-
withPrimitive
Creates a clone of this environment, with the specified primitive.- Parameters:
osm- OSM primitive- Returns:
- A clone of this environment, with the specified primitive
- Since:
- 13810 (signature)
- See Also:
-
withParent
Creates a clone of this environment, with the specified parent.- Parameters:
parent- the matching parent object- Returns:
- A clone of this environment, with the specified parent
- Since:
- 13810 (signature)
- See Also:
-
withParentAndIndexAndLinkContext
Creates a clone of this environment, with the specified parent, index, and context set toCondition.Context.LINK.- Parameters:
parent- the matching parent objectindex- index of node in parent way or member in parent relationcount- count of nodes in parent way or members in parent relation- Returns:
- A clone of this environment, with the specified parent, index, and context set to
Condition.Context.LINK - Since:
- 6175, 13810 (signature)
- See Also:
-
withChild
Creates a clone of this environment, with the specified child.- Parameters:
child- the matching child object- Returns:
- A clone of this environment, with the specified child
- Since:
- 13810 (signature)
- See Also:
-
withChildAndIndexAndLinkContext
Creates a clone of this environment, with the specified child, index, and context set toCondition.Context.LINK.- Parameters:
child- the matching child objectindex- index of node in parent way or member in parent relationcount- count of nodes in parent way or members in parent relation- Returns:
- A clone of this environment, with the specified child, index, and context set to
Context#LINK - Since:
- 6175, 13810 (signature)
- See Also:
-
withIndex
Creates a clone of this environment, with the specified index.- Parameters:
index- index of node in parent way or member in parent relationcount- count of nodes in parent way or members in parent relation- Returns:
- A clone of this environment, with the specified index
- See Also:
-
withContext
Creates a clone of this environment, with the specifiedCondition.Context.- Parameters:
context- context- Returns:
- A clone of this environment, with the specified
Context
-
withLinkContext
Creates a clone of this environment, with context set toCondition.Context.LINK.- Returns:
- A clone of this environment, with context set to
Context#LINK
-
withSelector
Creates a clone of this environment, with the selector set- Parameters:
selector- The selector to use- Returns:
- A clone of this environment, with the specified selector
- Since:
- 18757
-
isLinkContext
Determines if the context of this environment isCondition.Context.LINK.- Returns:
trueif the context of this environment isContext#LINK,falseotherwise
-
hasParentRelation
Determines if this environment has a relation as parent.- Returns:
trueif this environment has a relation as parent,falseotherwise- See Also:
-
getContext
Replies the current context.- Returns:
- the current context
-
getRole
Gets the role of the matching primitive in the relation- Returns:
- The role
-
selector
Get the selector for this environment- Returns:
- The selector. May be
null. - Since:
- 18757
-
clearSelectorMatchingInformation
Clears all matching context information- Returns:
- this
-
getCascade
Gets the current cascade for the current layer of this environment- Returns:
- The cascade
-
getCascade
Gets the current cascade for a given layer- Parameters:
layer- The layer to use,nullto use the layer of theEnvironment- Returns:
- The cascade
-