source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java@ 3858

Last change on this file since 3858 was 3858, checked in by bastiK, 14 years ago

mapcss: support for opacity & icon-image

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.mapcss;
3
4import java.util.Arrays;
5
6import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
7
8abstract public class Instruction {
9
10 public abstract void execute(Environment env);
11
12 public static class RelativeFloat {
13 public float val;
14
15 public RelativeFloat(float val) {
16 this.val = val;
17 }
18
19 @Override
20 public String toString() {
21 return "RelativeFloat{" + "val=" + val + '}';
22 }
23 }
24
25 public static class AssignmentInstruction extends Instruction {
26 String key;
27 Object val;
28
29 public AssignmentInstruction(String key, Object val) {
30 this.key = key;
31 this.val = val;
32 }
33
34 @Override
35 public void execute(Environment env) {
36 Object value = (val instanceof Expression) ? ((Expression) val).evaluate(env) : val;
37 if (key.equals("icon-image")) {
38 if (value instanceof String) {
39 value = new IconReference((String) value, env.source);
40 }
41 }
42 env.getCascade().putOrClear(key, value);
43 }
44
45 @Override
46 public String toString() {
47 return key + ':' + (val instanceof float[] ? Arrays.toString((float[]) val) : val) + ';';
48 }
49 }
50}
Note: See TracBrowser for help on using the repository browser.