Class MapCSSStyleSource
- java.lang.Object
-
- org.openstreetmap.josm.data.preferences.sources.SourceEntry
-
- org.openstreetmap.josm.gui.mappaint.StyleSource
-
- org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource
-
public class MapCSSStyleSource extends StyleSource
This is a mappaint style that is based on MapCSS rules.
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Color
backgroundColorOverride
private java.lang.String
css
static java.lang.String
MAPCSS_STYLE_MIME_TYPES
The accepted MIME types sent in the HTTP Accept header.private boolean
removeAreaStylePseudoClass
private MapCSSStyleIndex
ruleIndex
Index of rules in this style filejava.util.List<MapCSSRule>
rules
all rules in this style filestatic java.util.concurrent.locks.ReadWriteLock
STYLE_SOURCE_LOCK
This lock prevents concurrent execution ofMapCSSRuleIndex.clear()
/MapCSSRuleIndex.initIndex()
andMapCSSRuleIndex.getRuleCandidates(org.openstreetmap.josm.data.osm.IPrimitive)
.(package private) static java.util.Set<java.lang.String>
SUPPORTED_KEYS
Set of all supported MapCSS keys.private java.util.zip.ZipFile
zipFile
-
Fields inherited from class org.openstreetmap.josm.gui.mappaint.StyleSource
icon, loaded, settingGroups, settings, settingValues, zipIcons
-
Fields inherited from class org.openstreetmap.josm.data.preferences.sources.SourceEntry
active, isZip, name, title, type, url, zipEntryPath
-
-
Constructor Summary
Constructors Constructor Description MapCSSStyleSource(java.lang.String css)
Creates a new style source from the MapCSS styles supplied incss
MapCSSStyleSource(java.lang.String url, java.lang.String name, java.lang.String shortdescription)
Constructs a new, activeMapCSSStyleSource
.MapCSSStyleSource(SourceEntry entry)
Constructs a newMapCSSStyleSource
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed)
Apply style to osm primitive.void
closeSourceInputStream(java.io.InputStream is)
Closes the source input stream previously returned byStyleSource.getSourceInputStream()
and other linked resources, if applicable.private Cascade
constructSpecial(java.lang.String type)
boolean
evalSupportsDeclCondition(java.lang.String feature, java.lang.Object val)
Evaluate a supports conditionjava.awt.Color
getBackgroundColorOverride()
Gets the background color that was set in this styleCachedFile
getCachedFile()
Returns a newCachedFile
to the local file containing style source (can be a text file or an archive).java.io.InputStream
getSourceInputStream()
Returns a newInputStream
to the style source.boolean
isRemoveAreaStylePseudoClass()
Whether to remove "areaStyle" pseudo classes.private void
loadCanvas()
private void
loadMeta()
load meta info from a selector "meta"private void
loadSettings()
private static void
loadSettings(MapCSSRule r, Selector.GeneralSelector gs, Environment env)
void
loadStyleSource(boolean metadataOnly)
Loads the style source.void
removeMetaRules()
Removes "meta" rules.java.lang.String
toString()
-
Methods inherited from class org.openstreetmap.josm.gui.mappaint.StyleSource
getErrors, getIcon, getIconProvider, getSourceIconProvider, getToolTipText, getWarnings, init, isLoaded, isValid, loadStyleSource, logError, logWarning
-
Methods inherited from class org.openstreetmap.josm.data.preferences.sources.SourceEntry
equals, getDisplayString, getFileNamePart, getLocalSourceDir, getPrefName, getZipEntryDirName, hashCode, isLocal
-
-
-
-
Field Detail
-
MAPCSS_STYLE_MIME_TYPES
public static final java.lang.String MAPCSS_STYLE_MIME_TYPES
The accepted MIME types sent in the HTTP Accept header.- Since:
- 6867
- See Also:
- Constant Field Values
-
rules
public final java.util.List<MapCSSRule> rules
all rules in this style file
-
ruleIndex
private final MapCSSStyleIndex ruleIndex
Index of rules in this style file
-
backgroundColorOverride
private java.awt.Color backgroundColorOverride
-
css
private java.lang.String css
-
zipFile
private java.util.zip.ZipFile zipFile
-
removeAreaStylePseudoClass
private boolean removeAreaStylePseudoClass
-
STYLE_SOURCE_LOCK
public static final java.util.concurrent.locks.ReadWriteLock STYLE_SOURCE_LOCK
This lock prevents concurrent execution ofMapCSSRuleIndex.clear()
/MapCSSRuleIndex.initIndex()
andMapCSSRuleIndex.getRuleCandidates(org.openstreetmap.josm.data.osm.IPrimitive)
. For efficiency reasons, these methods are synchronized higher up the stack trace.
-
SUPPORTED_KEYS
static final java.util.Set<java.lang.String> SUPPORTED_KEYS
Set of all supported MapCSS keys.
-
-
Constructor Detail
-
MapCSSStyleSource
public MapCSSStyleSource(java.lang.String url, java.lang.String name, java.lang.String shortdescription)
Constructs a new, activeMapCSSStyleSource
.- Parameters:
url
- URL thatCachedFile
understandsname
- The name for this StyleSourceshortdescription
- The title for that source.
-
MapCSSStyleSource
public MapCSSStyleSource(SourceEntry entry)
Constructs a newMapCSSStyleSource
- Parameters:
entry
- The entry to copy the data (url, name, ...) from.
-
MapCSSStyleSource
public MapCSSStyleSource(java.lang.String css)
Creates a new style source from the MapCSS styles supplied in
css
- Parameters:
css
- the MapCSS style declaration. Must not be null.- Throws:
java.lang.IllegalArgumentException
- ifcss
is null
-
-
Method Detail
-
loadStyleSource
public void loadStyleSource(boolean metadataOnly)
Description copied from class:StyleSource
Loads the style source.- Specified by:
loadStyleSource
in classStyleSource
- Parameters:
metadataOnly
- iftrue
, only metadata are loaded
-
getSourceInputStream
public java.io.InputStream getSourceInputStream() throws java.io.IOException
Description copied from class:StyleSource
Returns a newInputStream
to the style source. When finished,StyleSource.closeSourceInputStream(InputStream)
must be called.- Specified by:
getSourceInputStream
in classStyleSource
- Returns:
- A new
InputStream
to the style source that must be closed by the caller - Throws:
java.io.IOException
- if any I/O error occurs.- See Also:
StyleSource.closeSourceInputStream(InputStream)
-
getCachedFile
public CachedFile getCachedFile() throws java.io.IOException
Description copied from class:StyleSource
Returns a newCachedFile
to the local file containing style source (can be a text file or an archive).- Specified by:
getCachedFile
in classStyleSource
- Returns:
- A new
CachedFile
to the local file containing style source - Throws:
java.io.IOException
- if any I/O error occurs.
-
closeSourceInputStream
public void closeSourceInputStream(java.io.InputStream is)
Description copied from class:StyleSource
Closes the source input stream previously returned byStyleSource.getSourceInputStream()
and other linked resources, if applicable.- Overrides:
closeSourceInputStream
in classStyleSource
- Parameters:
is
- The source input stream that must be closed- See Also:
StyleSource.getSourceInputStream()
-
loadMeta
private void loadMeta()
load meta info from a selector "meta"
-
loadCanvas
private void loadCanvas()
-
loadSettings
private static void loadSettings(MapCSSRule r, Selector.GeneralSelector gs, Environment env)
-
loadSettings
private void loadSettings()
-
constructSpecial
private Cascade constructSpecial(java.lang.String type)
-
getBackgroundColorOverride
public java.awt.Color getBackgroundColorOverride()
Description copied from class:StyleSource
Gets the background color that was set in this style- Overrides:
getBackgroundColorOverride
in classStyleSource
- Returns:
- The color or
null
if it was not set
-
apply
public void apply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed)
Description copied from class:StyleSource
Apply style to osm primitive. Adds properties to a MultiCascade. All activeStyleSource
s add their properties on after the other. At a later stage, concrete painting primitives (lines, icons, text, ...) are derived from the MultiCascade.- Specified by:
apply
in classStyleSource
- Parameters:
mc
- the current MultiCascade, empty for the first StyleSourceosm
- the primitivescale
- the map scalepretendWayIsClosed
- For styles that require the way to be closed, we pretend it is. This is useful for generating area styles from the (segmented) outer ways of a multipolygon.
-
evalSupportsDeclCondition
public boolean evalSupportsDeclCondition(java.lang.String feature, java.lang.Object val)
Evaluate a supports condition- Parameters:
feature
- The feature to evaluate forval
- The additional parameter passed to evaluate- Returns:
true
if JSOM supports that feature
-
removeMetaRules
public void removeMetaRules()
Removes "meta" rules. Not needed for validator.- Since:
- 13633
-
isRemoveAreaStylePseudoClass
public boolean isRemoveAreaStylePseudoClass()
Whether to remove "areaStyle" pseudo classes. Only for use in MapCSSParser!- Returns:
- whether to remove "areaStyle" pseudo classes
-
toString
public java.lang.String toString()
- Overrides:
toString
in classSourceEntry
-
-