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 IPrimitive
child
The same for parent selector.java.util.Set<IPrimitive>
children
Set of matched children filled by ContainsFinder and CrossingFinder, null if nothing matchedprivate Condition.Context
context
java.lang.Integer
count
count 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>>>
crossingWaysMap
Crossing ways result from CrossingFinder, filled for incomplete ways/relationsstatic java.lang.String
DEFAULT_LAYER
The name of the default layer.java.lang.Integer
index
index of node in parent way or member in parent relation.java.util.Map<IPrimitive,java.awt.geom.Area>
intersections
Intersection areas (only filled with CrossingFinder if children is not null)java.lang.String
layer
The current MapCSS layerMultiCascade
mc
The cascades that are currently evaluatedjava.util.Map<IPrimitive,java.awt.geom.Area>
mpAreaCache
Cache for multipolygon areas, can be null, used with CrossingFinderIPrimitive
osm
The primitive that is currently evaluatedIPrimitive
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)private Selector
selector
The selector that is currently being evaluatedStyleSource
source
The style source that is evaluatedjava.util.Set<IPrimitive>
toMatchForSurrounding
Can 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
.private
Environment(Environment other, Selector selector)
Creates a clone of the environmentother
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Environment
clearSelectorMatchingInformation()
Clears all matching context informationCascade
getCascade()
Gets the current cascade for the current layer of this environmentCascade
getCascade(java.lang.String layer)
Gets the current cascade for a given layerCondition.Context
getContext()
Replies the current context.java.lang.String
getRole()
Gets the role of the matching primitive in the relationboolean
hasParentRelation()
Determines if this environment has a relation as parent.boolean
isLinkContext()
Determines if the context of this environment isCondition.Context.LINK
.Selector
selector()
Get the selector for this environmentEnvironment
withChild(IPrimitive child)
Creates a clone of this environment, with the specified child.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
.Environment
withContext(Condition.Context context)
Creates a clone of this environment, with the specifiedCondition.Context
.Environment
withIndex(int index, int count)
Creates a clone of this environment, with the specified index.Environment
withLinkContext()
Creates a clone of this environment, with context set toCondition.Context.LINK
.Environment
withParent(IPrimitive parent)
Creates a clone of this environment, with the specified parent.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
.Environment
withPrimitive(IPrimitive osm)
Creates a clone of this environment, with the specified primitive.Environment
withSelector(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
-
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
- ifparam
isnull
-
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
- ifparam
isnull
-
-
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:
true
if the context of this environment isContext#LINK
,false
otherwise
-
hasParentRelation
public boolean hasParentRelation()
Determines if this environment has a relation as parent.- Returns:
true
if this environment has a relation as parent,false
otherwise- 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,null
to use the layer of theEnvironment
- Returns:
- The cascade
-
-