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.ColorbackgroundColorOverrideprivate java.lang.Stringcssstatic java.lang.StringMAPCSS_STYLE_MIME_TYPESThe accepted MIME types sent in the HTTP Accept header.private booleanremoveAreaStylePseudoClassprivate MapCSSStyleIndexruleIndexIndex of rules in this style filejava.util.List<MapCSSRule>rulesall rules in this style filestatic java.util.concurrent.locks.ReadWriteLockSTYLE_SOURCE_LOCKThis 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_KEYSSet of all supported MapCSS keys.private java.util.zip.ZipFilezipFile-
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 incssMapCSSStyleSource(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 voidapply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed)Apply style to osm primitive.voidcloseSourceInputStream(java.io.InputStream is)Closes the source input stream previously returned byStyleSource.getSourceInputStream()and other linked resources, if applicable.private CascadeconstructSpecial(java.lang.String type)booleanevalSupportsDeclCondition(java.lang.String feature, java.lang.Object val)Evaluate a supports conditionjava.awt.ColorgetBackgroundColorOverride()Gets the background color that was set in this styleCachedFilegetCachedFile()Returns a newCachedFileto the local file containing style source (can be a text file or an archive).java.io.InputStreamgetSourceInputStream()Returns a newInputStreamto the style source.booleanisRemoveAreaStylePseudoClass()Whether to remove "areaStyle" pseudo classes.private voidloadCanvas()private voidloadMeta()load meta info from a selector "meta"private voidloadSettings()private static voidloadSettings(MapCSSRule r, Selector.GeneralSelector gs, Environment env)voidloadStyleSource(boolean metadataOnly)Loads the style source.voidremoveMetaRules()Removes "meta" rules.java.lang.StringtoString()-
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 thatCachedFileunderstandsname- 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- ifcssis null
-
-
Method Detail
-
loadStyleSource
public void loadStyleSource(boolean metadataOnly)
Description copied from class:StyleSourceLoads the style source.- Specified by:
loadStyleSourcein classStyleSource- Parameters:
metadataOnly- iftrue, only metadata are loaded
-
getSourceInputStream
public java.io.InputStream getSourceInputStream() throws java.io.IOException
Description copied from class:StyleSourceReturns a newInputStreamto the style source. When finished,StyleSource.closeSourceInputStream(InputStream)must be called.- Specified by:
getSourceInputStreamin classStyleSource- Returns:
- A new
InputStreamto 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:StyleSourceReturns a newCachedFileto the local file containing style source (can be a text file or an archive).- Specified by:
getCachedFilein classStyleSource- Returns:
- A new
CachedFileto 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:StyleSourceCloses the source input stream previously returned byStyleSource.getSourceInputStream()and other linked resources, if applicable.- Overrides:
closeSourceInputStreamin 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:StyleSourceGets the background color that was set in this style- Overrides:
getBackgroundColorOverridein classStyleSource- Returns:
- The color or
nullif it was not set
-
apply
public void apply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed)
Description copied from class:StyleSourceApply style to osm primitive. Adds properties to a MultiCascade. All activeStyleSources add their properties on after the other. At a later stage, concrete painting primitives (lines, icons, text, ...) are derived from the MultiCascade.- Specified by:
applyin 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:
trueif 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:
toStringin classSourceEntry
-
-