source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Subpart.java@ 8624

Last change on this file since 8624 was 8624, checked in by bastiK, 9 years ago

add missing svn:eol-style=native

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.mapcss;
3
4import org.openstreetmap.josm.gui.mappaint.Cascade;
5import org.openstreetmap.josm.gui.mappaint.Environment;
6
7/**
8 * A subpart identifies different rendering layers (<code>::subpart</code> syntax).
9 */
10public interface Subpart {
11 String getId(Environment env);
12
13 Subpart DEFAULT_SUBPART = new StringSubpart("default");
14
15 /**
16 * Simple static subpart identifier.
17 *
18 * E.g. ::layer_1
19 */
20 class StringSubpart implements Subpart {
21 private final String id;
22
23 public StringSubpart(String id) {
24 this.id = id;
25 }
26
27 @Override
28 public String getId(Environment env) {
29 return id;
30 }
31 }
32
33 /**
34 * Subpart identifier given by an expression.
35 *
36 * E.g. ::(concat("layer_", prop("i", "default")))
37 */
38 class ExpressionSubpart implements Subpart {
39 private final Expression id;
40
41 public ExpressionSubpart(Expression id) {
42 this.id = id;
43 }
44
45 @Override
46 public String getId(Environment env) {
47 return Cascade.convertTo(id.evaluate(env), String.class);
48 }
49 }
50}
Note: See TracBrowser for help on using the repository browser.