Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java @ 1876:dd467951335c
Added support for labels in Mapserver layers and options to modify its style.
flys-artifacts/trunk@3234 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 11 Nov 2011 09:43:36 +0000 |
parents | 5364b86a0880 |
children | 1a6018d5f0b7 |
comparison
equal
deleted
inserted
replaced
1875:4fb81eb8b45b | 1876:dd467951335c |
---|---|
5 | 5 |
6 | 6 |
7 public class MapserverStyle { | 7 public class MapserverStyle { |
8 | 8 |
9 public static class Clazz { | 9 public static class Clazz { |
10 protected String name; | 10 protected List<ClazzItem> items; |
11 protected String name; | |
12 | |
13 public Clazz(String name) { | |
14 this.name = name; | |
15 this.items = new ArrayList<ClazzItem>(); | |
16 } | |
17 | |
18 public void addItem(ClazzItem item) { | |
19 if (item != null) { | |
20 items.add(item); | |
21 } | |
22 } | |
23 | |
24 @Override | |
25 public String toString() { | |
26 StringBuilder sb = new StringBuilder(); | |
27 sb.append("CLASS\n"); | |
28 sb.append("NAME \"" + name + "\"\n"); | |
29 | |
30 for (ClazzItem item: items) { | |
31 item.toString(sb); | |
32 } | |
33 | |
34 sb.append("END"); | |
35 | |
36 return sb.toString(); | |
37 } | |
38 } | |
39 | |
40 public interface ClazzItem { | |
41 void toString(StringBuilder sb); | |
42 } | |
43 | |
44 public static class Style implements ClazzItem { | |
11 protected String outlinecolor; | 45 protected String outlinecolor; |
12 protected String symbol; | 46 protected String symbol; |
13 protected int size; | 47 protected int size; |
14 | |
15 public Clazz(String name) { | |
16 this.name = name; | |
17 } | |
18 | 48 |
19 public void setOutlineColor(String outlinecolor) { | 49 public void setOutlineColor(String outlinecolor) { |
20 this.outlinecolor = outlinecolor; | 50 this.outlinecolor = outlinecolor; |
21 } | 51 } |
22 | 52 |
28 if (symbol != null && symbol.length() > 0) { | 58 if (symbol != null && symbol.length() > 0) { |
29 this.symbol = symbol; | 59 this.symbol = symbol; |
30 } | 60 } |
31 } | 61 } |
32 | 62 |
33 public String toString() { | 63 public void toString(StringBuilder sb) { |
34 StringBuilder sb = new StringBuilder(); | |
35 sb.append("CLASS\n"); | |
36 sb.append("NAME \"" + name + "\"\n"); | |
37 sb.append("STYLE\n"); | 64 sb.append("STYLE\n"); |
38 sb.append("SIZE " + String.valueOf(size) + "\n"); | 65 sb.append("SIZE " + String.valueOf(size) + "\n"); |
39 sb.append("OUTLINECOLOR " + outlinecolor + "\n"); | 66 sb.append("OUTLINECOLOR " + outlinecolor + "\n"); |
40 | 67 |
41 if (symbol != null) { | 68 if (symbol != null) { |
42 sb.append("SYMBOL '" + symbol + "'\n"); | 69 sb.append("SYMBOL '" + symbol + "'\n"); |
43 } | 70 } |
44 | 71 |
45 sb.append("END\n"); | 72 sb.append("END\n"); |
73 } | |
74 } // end of Style | |
75 | |
76 public static class Label implements ClazzItem { | |
77 protected String color; | |
78 protected int size; | |
79 | |
80 public void setColor(String color) { | |
81 this.color = color; | |
82 } | |
83 | |
84 public void setSize(int size) { | |
85 this.size = size; | |
86 } | |
87 | |
88 @Override | |
89 public void toString(StringBuilder sb) { | |
90 sb.append("LABEL\n"); | |
91 sb.append("ANGLE auto\n"); | |
92 sb.append("SIZE " + String.valueOf(size) + "\n"); | |
93 sb.append("COLOR " + color + "\n"); | |
94 sb.append("TYPE truetype\n"); | |
95 sb.append("FONT DefaultFont\n"); | |
96 sb.append("POSITION ur\n"); | |
97 sb.append("OFFSET 2 2\n"); | |
46 sb.append("END\n"); | 98 sb.append("END\n"); |
47 | |
48 return sb.toString(); | |
49 } | 99 } |
50 } // end of Clazz | 100 } |
51 | 101 |
52 | 102 |
53 protected List<Clazz> classes; | 103 protected List<Clazz> classes; |
54 | 104 |
55 | 105 |