Last change
on this file since 4006 was 4006, checked in by bastiK, 13 years ago |
mapcss: new LinePattern style element similar to mapnik's LinePatternSymbolizer; split off the text part of LineElemStyle, so it also works for LinePattern
|
-
Property svn:eol-style
set to
native
|
File size:
1.7 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.mapcss;
|
---|
3 |
|
---|
4 | import java.util.Arrays;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.gui.mappaint.Environment;
|
---|
7 | import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
|
---|
8 |
|
---|
9 | abstract public class Instruction {
|
---|
10 |
|
---|
11 | public abstract void execute(Environment env);
|
---|
12 |
|
---|
13 | public static class RelativeFloat {
|
---|
14 | public float val;
|
---|
15 |
|
---|
16 | public RelativeFloat(float val) {
|
---|
17 | this.val = val;
|
---|
18 | }
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public String toString() {
|
---|
22 | return "RelativeFloat{" + "val=" + val + '}';
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | public static class AssignmentInstruction extends Instruction {
|
---|
27 | String key;
|
---|
28 | Object val;
|
---|
29 |
|
---|
30 | public AssignmentInstruction(String key, Object val) {
|
---|
31 | this.key = key;
|
---|
32 | if (val instanceof Expression.LiteralExpression) {
|
---|
33 | this.val = ((Expression.LiteralExpression) val).evaluate(null);
|
---|
34 | } else {
|
---|
35 | this.val = val;
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Override
|
---|
40 | public void execute(Environment env) {
|
---|
41 | Object value = (val instanceof Expression) ? ((Expression) val).evaluate(env) : val;
|
---|
42 | if (key.equals("icon-image") || key.equals("fill-image") || key.equals("pattern-image")) {
|
---|
43 | if (value instanceof String) {
|
---|
44 | value = new IconReference((String) value, env.source);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | env.mc.getOrCreateCascade(env.layer).putOrClear(key, value);
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public String toString() {
|
---|
52 | return key + ':' + (val instanceof float[] ? Arrays.toString((float[]) val) : val) + ';';
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.