comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java @ 3318:dbe2f85bf160

merged flys-artifacts/2.8
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:35 +0200
parents 27cc95e65f18
children
comparison
equal deleted inserted replaced
2987:98c7a46ec5ae 3318:dbe2f85bf160
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6
7 public class MapserverStyle {
8
9 public static class Clazz {
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\n");
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 {
45 protected String color;
46 protected String outlinecolor;
47 protected String symbol;
48 protected int size;
49
50 public void setColor(String color) {
51 this.color = color;
52 }
53
54 public void setOutlineColor(String outlinecolor) {
55 this.outlinecolor = outlinecolor;
56 }
57
58 public void setSize(int size) {
59 this.size = size;
60 }
61
62 public void setSymbol(String symbol) {
63 if (symbol != null && symbol.length() > 0) {
64 this.symbol = symbol;
65 }
66 }
67
68 public void toString(StringBuilder sb) {
69 sb.append("STYLE\n");
70 sb.append("WIDTH " + String.valueOf(size) + "\n");
71
72 if (outlinecolor != null) {
73 sb.append("OUTLINECOLOR " + outlinecolor + "\n");
74 }
75
76 if (color != null) {
77 sb.append("COLOR " + color + "\n");
78 }
79
80 if (symbol != null) {
81 sb.append("SYMBOL '" + symbol + "'\n");
82 }
83
84 sb.append("END\n");
85 }
86 } // end of Style
87
88 public static class Label implements ClazzItem {
89 protected String color;
90 protected int size;
91
92 public void setColor(String color) {
93 this.color = color;
94 }
95
96 public void setSize(int size) {
97 this.size = size;
98 }
99
100 @Override
101 public void toString(StringBuilder sb) {
102 sb.append("LABEL\n");
103 sb.append("ANGLE auto\n");
104 sb.append("SIZE " + String.valueOf(size) + "\n");
105 sb.append("COLOR " + color + "\n");
106 sb.append("TYPE truetype\n");
107 sb.append("FONT DefaultFont\n");
108 sb.append("POSITION ur\n");
109 sb.append("OFFSET 2 2\n");
110 sb.append("END\n");
111 }
112 }
113
114 public static class Expression implements ClazzItem {
115 protected String value;
116
117 public Expression(String value) {
118 this.value = value;
119 }
120
121 @Override
122 public void toString(StringBuilder sb) {
123 sb.append("EXPRESSION " + value);
124 sb.append("\n");
125 }
126 }
127
128
129 protected List<Clazz> classes;
130
131
132 public MapserverStyle() {
133 classes = new ArrayList<Clazz>();
134 }
135
136 public void addClazz(Clazz clazz) {
137 if (clazz != null) {
138 classes.add(clazz);
139 }
140 }
141
142 public String toString() {
143 StringBuilder sb = new StringBuilder();
144
145 for (Clazz clazz: classes) {
146 sb.append(clazz.toString());
147 }
148
149 return sb.toString();
150 }
151 }
152 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org