public class MapCSSStyleSource extends StyleSource
Modifier and Type | Class and Description |
---|---|
static class |
MapCSSStyleSource.MapCSSRuleIndex
A collection of
MapCSSRule s, that are indexed by tag key and value. |
Modifier and Type | Field and Description |
---|---|
private java.awt.Color |
backgroundColorOverride |
MapCSSStyleSource.MapCSSRuleIndex |
canvasRules
rules to apply canvas properties
|
private java.lang.String |
css |
static java.lang.String |
MAPCSS_STYLE_MIME_TYPES
The accepted MIME types sent in the HTTP Accept header.
|
MapCSSStyleSource.MapCSSRuleIndex |
multipolygonRules
Rules for multipolygon relations
|
MapCSSStyleSource.MapCSSRuleIndex |
nodeRules
Rules for nodes
|
MapCSSStyleSource.MapCSSRuleIndex |
relationRules
Rules for relations that are not multipolygon relations
|
java.util.List<MapCSSRule> |
rules
all rules in this style file
|
static java.util.concurrent.locks.ReadWriteLock |
STYLE_SOURCE_LOCK
This lock prevents concurrent execution of
MapCSSStyleSource.MapCSSRuleIndex.clear() /
MapCSSStyleSource.MapCSSRuleIndex.initIndex() and MapCSSStyleSource.MapCSSRuleIndex.getRuleCandidates(org.openstreetmap.josm.data.osm.IPrimitive) . |
(package private) static java.util.Set<java.lang.String> |
SUPPORTED_KEYS
Set of all supported MapCSS keys.
|
MapCSSStyleSource.MapCSSRuleIndex |
wayNoAreaRules
Rules for ways with tag area=no
|
MapCSSStyleSource.MapCSSRuleIndex |
wayRules
Rules for ways without tag area=no
|
private java.util.zip.ZipFile |
zipFile |
icon, loaded, settingGroups, settings, settingValues, zipIcons
active, isZip, name, title, type, url, zipEntryPath
Constructor and Description |
---|
MapCSSStyleSource(SourceEntry entry)
Constructs a new
MapCSSStyleSource |
MapCSSStyleSource(java.lang.String css)
Creates a new style source from the MapCSS styles supplied in
css |
MapCSSStyleSource(java.lang.String url,
java.lang.String name,
java.lang.String shortdescription)
Constructs a new, active
MapCSSStyleSource . |
Modifier and Type | Method and 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 by
StyleSource.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 condition
|
java.awt.Color |
getBackgroundColorOverride()
Gets the background color that was set in this style
|
CachedFile |
getCachedFile()
Returns a new
CachedFile to the local file containing style source (can be a text file or an archive). |
java.io.InputStream |
getSourceInputStream()
Returns a new
InputStream to the style source. |
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 |
removeAreaStyleClasses()
Removes "areaStyle" pseudo-classes.
|
private static void |
removeAreaStyleClasses(Selector.AbstractSelector sel) |
private static void |
removeAreaStyleClasses(Selector.ChildOrParentSelector sel) |
private static void |
removeAreaStyleClasses(Selector sel) |
void |
removeMetaRules()
Removes "meta" rules.
|
java.lang.String |
toString() |
getErrors, getIcon, getIconProvider, getSourceIconProvider, getToolTipText, getWarnings, init, isLoaded, isValid, loadStyleSource, logError, logWarning
equals, getDisplayString, getFileNamePart, getLocalSourceDir, getPrefName, getZipEntryDirName, hashCode, isLocal
public static final java.lang.String MAPCSS_STYLE_MIME_TYPES
public final java.util.List<MapCSSRule> rules
public final MapCSSStyleSource.MapCSSRuleIndex nodeRules
public final MapCSSStyleSource.MapCSSRuleIndex wayRules
public final MapCSSStyleSource.MapCSSRuleIndex wayNoAreaRules
public final MapCSSStyleSource.MapCSSRuleIndex relationRules
public final MapCSSStyleSource.MapCSSRuleIndex multipolygonRules
public final MapCSSStyleSource.MapCSSRuleIndex canvasRules
private java.awt.Color backgroundColorOverride
private java.lang.String css
private java.util.zip.ZipFile zipFile
public static final java.util.concurrent.locks.ReadWriteLock STYLE_SOURCE_LOCK
MapCSSStyleSource.MapCSSRuleIndex.clear()
/
MapCSSStyleSource.MapCSSRuleIndex.initIndex()
and MapCSSStyleSource.MapCSSRuleIndex.getRuleCandidates(org.openstreetmap.josm.data.osm.IPrimitive)
.
For efficiency reasons, these methods are synchronized higher up the
stack trace.static final java.util.Set<java.lang.String> SUPPORTED_KEYS
public MapCSSStyleSource(java.lang.String url, java.lang.String name, java.lang.String shortdescription)
MapCSSStyleSource
.url
- URL that CachedFile
understandsname
- The name for this StyleSourceshortdescription
- The title for that source.public MapCSSStyleSource(SourceEntry entry)
MapCSSStyleSource
entry
- The entry to copy the data (url, name, ...) from.public MapCSSStyleSource(java.lang.String css)
Creates a new style source from the MapCSS styles supplied in
css
css
- the MapCSS style declaration. Must not be null.java.lang.IllegalArgumentException
- if css
is nullpublic void loadStyleSource(boolean metadataOnly)
StyleSource
loadStyleSource
in class StyleSource
metadataOnly
- if true
, only metadata are loadedpublic java.io.InputStream getSourceInputStream() throws java.io.IOException
StyleSource
InputStream
to the style source. When finished, StyleSource.closeSourceInputStream(InputStream)
must be called.getSourceInputStream
in class StyleSource
InputStream
to the style source that must be closed by the callerjava.io.IOException
- if any I/O error occurs.StyleSource.closeSourceInputStream(InputStream)
public CachedFile getCachedFile() throws java.io.IOException
StyleSource
CachedFile
to the local file containing style source (can be a text file or an archive).getCachedFile
in class StyleSource
CachedFile
to the local file containing style sourcejava.io.IOException
- if any I/O error occurs.public void closeSourceInputStream(java.io.InputStream is)
StyleSource
StyleSource.getSourceInputStream()
and other linked resources, if applicable.closeSourceInputStream
in class StyleSource
is
- The source input stream that must be closedStyleSource.getSourceInputStream()
private void loadMeta()
private void loadCanvas()
private static void loadSettings(MapCSSRule r, Selector.GeneralSelector gs, Environment env)
private void loadSettings()
private Cascade constructSpecial(java.lang.String type)
public java.awt.Color getBackgroundColorOverride()
StyleSource
getBackgroundColorOverride
in class StyleSource
null
if it was not setpublic void apply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed)
StyleSource
StyleSource
s add
their properties on after the other. At a later stage, concrete painting
primitives (lines, icons, text, ...) are derived from the MultiCascade.apply
in class StyleSource
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.public boolean evalSupportsDeclCondition(java.lang.String feature, java.lang.Object val)
feature
- The feature to evaluate forval
- The additional parameter passed to evaluatetrue
if JSOM supports that featurepublic void removeMetaRules()
public void removeAreaStyleClasses()
private static void removeAreaStyleClasses(Selector sel)
private static void removeAreaStyleClasses(Selector.ChildOrParentSelector sel)
private static void removeAreaStyleClasses(Selector.AbstractSelector sel)
public java.lang.String toString()
toString
in class SourceEntry