Last change
on this file since 8256 was 8086, checked in by bastiK, 9 years ago |
MapCSS: add support for dynamic subparts
This feature is not useful on its own (aimed at loops & jumps).
Will keep this undocumented for now.
|
File size:
1.2 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.mapcss;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.gui.mappaint.Cascade;
|
---|
5 | import org.openstreetmap.josm.gui.mappaint.Environment;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * A subpart identifies different rendering layers (<code>::subpart</code> syntax).
|
---|
9 | */
|
---|
10 | public interface Subpart {
|
---|
11 | String getId(Environment env);
|
---|
12 |
|
---|
13 | public static Subpart DEFAULT_SUBPART = new StringSubpart("default");
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Simple static subpart identifier.
|
---|
17 | *
|
---|
18 | * E.g. ::layer_1
|
---|
19 | */
|
---|
20 | public static class StringSubpart implements Subpart {
|
---|
21 | private final String id;
|
---|
22 |
|
---|
23 | public StringSubpart(String id) {
|
---|
24 | this.id = id;
|
---|
25 | }
|
---|
26 | @Override
|
---|
27 | public String getId(Environment env) {
|
---|
28 | return id;
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Subpart identifier given by an expression.
|
---|
34 | *
|
---|
35 | * E.g. ::(concat("layer_", prop("i", "default")))
|
---|
36 | */
|
---|
37 | public static class ExpressionSubpart implements Subpart {
|
---|
38 | private final Expression id;
|
---|
39 |
|
---|
40 | public ExpressionSubpart(Expression id) {
|
---|
41 | this.id = id;
|
---|
42 | }
|
---|
43 | @Override
|
---|
44 | public String getId(Environment env) {
|
---|
45 | return Cascade.convertTo(id.evaluate(env), String.class);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.