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 Color |
backgroundColorOverride |
MapCSSStyleSource.MapCSSRuleIndex |
canvasRules |
private String |
css |
static String |
MAPCSS_STYLE_MIME_TYPES
The accepted MIME types sent in the HTTP Accept header.
|
MapCSSStyleSource.MapCSSRuleIndex |
multipolygonRules |
MapCSSStyleSource.MapCSSRuleIndex |
nodeRules |
MapCSSStyleSource.MapCSSRuleIndex |
relationRules |
List<MapCSSRule> |
rules |
static 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.OsmPrimitive) . |
protected static Set<String> |
SUPPORTED_KEYS
Set of all supported MapCSS keys.
|
MapCSSStyleSource.MapCSSRuleIndex |
wayNoAreaRules |
MapCSSStyleSource.MapCSSRuleIndex |
wayRules |
private ZipFile |
zipFile |
icon, settings, settingValues, zipIcons
active, isZip, name, title, url, zipEntryPath
Constructor and Description |
---|
MapCSSStyleSource(SourceEntry entry)
Constructs a new
MapCSSStyleSource |
MapCSSStyleSource(String css)
Creates a new style source from the MapCSS styles supplied in
css |
MapCSSStyleSource(String url,
String name,
String shortdescription)
Constructs a new, active
MapCSSStyleSource . |
Modifier and Type | Method and Description |
---|---|
void |
apply(MultiCascade mc,
OsmPrimitive osm,
double scale,
boolean pretendWayIsClosed)
Apply style to osm primitive.
|
void |
closeSourceInputStream(InputStream is)
Closes the source input stream previously returned by
StyleSource.getSourceInputStream() and other linked resources, if applicable. |
private Cascade |
constructSpecial(String type) |
boolean |
evalSupportsDeclCondition(String feature,
Object val) |
Color |
getBackgroundColorOverride() |
CachedFile |
getCachedFile()
Returns a new
CachedFile to the local file containing style source (can be a text file or an archive). |
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() |
void |
loadStyleSource()
Loads the style source.
|
String |
toString() |
getErrors, getIcon, getIconProvider, getSourceIconProvider, getToolTipText, init, logError
equals, getDisplayString, getFileNamePart, getLocalSourceDir, getPrefName, getZipEntryDirName, hashCode, isLocal
public static final String MAPCSS_STYLE_MIME_TYPES
public final 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 Color backgroundColorOverride
public static final ReadWriteLock STYLE_SOURCE_LOCK
MapCSSStyleSource.MapCSSRuleIndex.clear()
/
MapCSSStyleSource.MapCSSRuleIndex.initIndex()
and MapCSSStyleSource.MapCSSRuleIndex.getRuleCandidates(org.openstreetmap.josm.data.osm.OsmPrimitive)
.
For efficiency reasons, these methods are synchronized higher up the
stack trace.protected static final Set<String> SUPPORTED_KEYS
public MapCSSStyleSource(String url, String name, 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(String css)
Creates a new style source from the MapCSS styles supplied in
css
css
- the MapCSS style declaration. Must not be null.IllegalArgumentException
- if css
is nullpublic void loadStyleSource()
StyleSource
loadStyleSource
in class StyleSource
public InputStream getSourceInputStream() throws 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 callerIOException
- if any I/O error occurs.StyleSource.closeSourceInputStream(InputStream)
public CachedFile getCachedFile() throws 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 sourceIOException
- if any I/O error occurs.public void closeSourceInputStream(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 void loadSettings()
private Cascade constructSpecial(String type)
public Color getBackgroundColorOverride()
getBackgroundColorOverride
in class StyleSource
public void apply(MultiCascade mc, OsmPrimitive 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(String feature, Object val)
public String toString()
toString
in class SourceEntry