Class Environment
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.Environment
-
public class Environment extends java.lang.Object
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
Fields Modifier and Type Field Description IPrimitivechildThe same for parent selector.java.util.Set<IPrimitive>childrenSet of matched children filled by ContainsFinder and CrossingFinder, null if nothing matchedprivate Condition.Contextcontextjava.lang.Integercountcount of nodes in parent way or members in parent relation.java.util.Map<IPrimitive,java.util.Map<java.util.List<Way>,java.util.List<WaySegment>>>crossingWaysMapCrossing ways result from CrossingFinder, filled for incomplete ways/relationsstatic java.lang.StringDEFAULT_LAYERThe name of the default layer.java.lang.Integerindexindex of node in parent way or member in parent relation.java.util.Map<IPrimitive,java.awt.geom.Area>intersectionsIntersection areas (only filled with CrossingFinder if children is not null)java.lang.StringlayerThe current MapCSS layerMultiCascademcThe cascades that are currently evaluatedjava.util.Map<IPrimitive,java.awt.geom.Area>mpAreaCacheCache for multipolygon areas, can be null, used with CrossingFinderjava.util.Map<IRelation<?>,Pair<java.util.List<MultipolygonBuilder.JoinedPolygon>,java.util.List<MultipolygonBuilder.JoinedPolygon>>>mpJoinedAreaCacheCache for multipolygon areas as calculated byMultipolygonBuilder.joinWays(Relation), can benullIPrimitiveosmThe primitive that is currently evaluatedIPrimitiveparentIf not null, this is the matching parent object if a condition or an expression is evaluated in aSelector.LinkSelector(within a child selector)private SelectorselectorThe selector that is currently being evaluatedStyleSourcesourceThe style source that is evaluatedjava.util.Set<IPrimitive>toMatchForSurroundingCan be null, may contain primitives when surrounding objects of the primitives are tested
-
Constructor Summary
Constructors Modifier Constructor Description Environment()Creates a new uninitialized environment.Environment(IPrimitive osm)Creates a new environment.Environment(IPrimitive osm, MultiCascade mc, java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EnvironmentclearSelectorMatchingInformation()Clears all matching context informationCascadegetCascade()Gets the current cascade for the current layer of this environmentCascadegetCascade(java.lang.String layer)Gets the current cascade for a given layerCondition.ContextgetContext()Replies the current context.java.lang.StringgetRole()Gets the role of the matching primitive in the relationbooleanhasParentRelation()Determines if this environment has a relation as parent.booleanisLinkContext()Determines if the context of this environment isCondition.Context.LINK.Selectorselector()Get the selector for this environmentEnvironmentwithChild(IPrimitive child)Creates a clone of this environment, with the specified child.EnvironmentwithChildAndIndexAndLinkContext(IPrimitive child, int index, int count)Creates a clone of this environment, with the specified child, index, and context set toCondition.Context.LINK.EnvironmentwithContext(Condition.Context context)Creates a clone of this environment, with the specifiedCondition.Context.EnvironmentwithIndex(int index, int count)Creates a clone of this environment, with the specified index.EnvironmentwithLinkContext()Creates a clone of this environment, with context set toCondition.Context.LINK.EnvironmentwithParent(IPrimitive parent)Creates a clone of this environment, with the specified parent.EnvironmentwithParentAndIndexAndLinkContext(IPrimitive parent, int index, int count)Creates a clone of this environment, with the specified parent, index, and context set toCondition.Context.LINK.EnvironmentwithPrimitive(IPrimitive osm)Creates a clone of this environment, with the specified primitive.EnvironmentwithSelector(Selector selector)Creates a clone of this environment, with the selector set
-
-
-
Field Detail
-
osm
public IPrimitive osm
The primitive that is currently evaluated
-
mc
public MultiCascade mc
The cascades that are currently evaluated
-
layer
public java.lang.String layer
The current MapCSS layer
-
source
public StyleSource source
The style source that is evaluated
-
context
private Condition.Context context
-
DEFAULT_LAYER
public static final java.lang.String DEFAULT_LAYER
The name of the default layer. It is used if no layer is specified in the MapCSS rule- See Also:
- Constant Field Values
-
parent
public IPrimitive 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
public IPrimitive child
The same for parent selector. Only one of the 2 fields (parent or child) is not null in any environment.
-
index
public java.lang.Integer index
index of node in parent way or member in parent relation. Must be != null in LINK context.
-
count
public java.lang.Integer count
count of nodes in parent way or members in parent relation. Must be != null in LINK context.
-
children
public java.util.Set<IPrimitive> children
Set of matched children filled by ContainsFinder and CrossingFinder, null if nothing matched
-
crossingWaysMap
public java.util.Map<IPrimitive,java.util.Map<java.util.List<Way>,java.util.List<WaySegment>>> crossingWaysMap
Crossing ways result from CrossingFinder, filled for incomplete ways/relations
-
intersections
public java.util.Map<IPrimitive,java.awt.geom.Area> intersections
Intersection areas (only filled with CrossingFinder if children is not null)
-
mpAreaCache
public java.util.Map<IPrimitive,java.awt.geom.Area> mpAreaCache
Cache for multipolygon areas, can be null, used with CrossingFinder
-
mpJoinedAreaCache
public java.util.Map<IRelation<?>,Pair<java.util.List<MultipolygonBuilder.JoinedPolygon>,java.util.List<MultipolygonBuilder.JoinedPolygon>>> mpJoinedAreaCache
Cache for multipolygon areas as calculated byMultipolygonBuilder.joinWays(Relation), can benull
-
toMatchForSurrounding
public java.util.Set<IPrimitive> toMatchForSurrounding
Can be null, may contain primitives when surrounding objects of the primitives are tested
-
-
Constructor Detail
-
Environment
public Environment()
Creates a new uninitialized environment.
-
Environment
public Environment(IPrimitive osm)
Creates a new environment.- Parameters:
osm- OSM primitive- Since:
- 8415, 13810 (signature)
-
Environment
public Environment(IPrimitive osm, MultiCascade mc, java.lang.String layer, StyleSource source)
Creates a new environment.- Parameters:
osm- OSM primitivemc- multi cascadelayer- layersource- style source- Since:
- 13810 (signature)
-
Environment
public Environment(Environment other)
Creates a clone of the environmentother.- Parameters:
other- the other environment. Must not be null.- Throws:
java.lang.IllegalArgumentException- ifparamisnull
-
Environment
private Environment(Environment other, Selector selector)
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:
java.lang.IllegalArgumentException- ifparamisnull
-
-
Method Detail
-
withPrimitive
public Environment withPrimitive(IPrimitive osm)
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:
osm
-
withParent
public Environment withParent(IPrimitive parent)
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:
parent
-
withParentAndIndexAndLinkContext
public Environment withParentAndIndexAndLinkContext(IPrimitive parent, int index, int count)
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:
parent,index
-
withChild
public Environment withChild(IPrimitive child)
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:
child
-
withChildAndIndexAndLinkContext
public Environment withChildAndIndexAndLinkContext(IPrimitive child, int index, int count)
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:
child,index
-
withIndex
public Environment withIndex(int index, int count)
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:
index
-
withContext
public Environment withContext(Condition.Context context)
Creates a clone of this environment, with the specifiedCondition.Context.- Parameters:
context- context- Returns:
- A clone of this environment, with the specified
Context
-
withLinkContext
public Environment 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
public Environment withSelector(Selector selector)
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
public boolean isLinkContext()
Determines if the context of this environment isCondition.Context.LINK.- Returns:
trueif the context of this environment isContext#LINK,falseotherwise
-
hasParentRelation
public boolean hasParentRelation()
Determines if this environment has a relation as parent.- Returns:
trueif this environment has a relation as parent,falseotherwise- See Also:
parent
-
getContext
public Condition.Context getContext()
Replies the current context.- Returns:
- the current context
-
getRole
public java.lang.String getRole()
Gets the role of the matching primitive in the relation- Returns:
- The role
-
selector
public Selector selector()
Get the selector for this environment- Returns:
- The selector. May be
null. - Since:
- 18757
-
clearSelectorMatchingInformation
public Environment clearSelectorMatchingInformation()
Clears all matching context information- Returns:
- this
-
getCascade
public Cascade getCascade()
Gets the current cascade for the current layer of this environment- Returns:
- The cascade
-
getCascade
public Cascade getCascade(java.lang.String layer)
Gets the current cascade for a given layer- Parameters:
layer- The layer to use,nullto use the layer of theEnvironment- Returns:
- The cascade
-
-