comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java @ 3814:8083f6384023

merged flys-artifacts/pre2.6-2012-01-04
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:56 +0200
parents 84cf67a2a19e
children 27cc95e65f18
comparison
equal deleted inserted replaced
1491:2a00f4849738 3814:8083f6384023
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");
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 sb.append("OUTLINECOLOR " + outlinecolor + "\n");
72
73 if (color != null) {
74 sb.append("COLOR " + color + "\n");
75 }
76
77 if (symbol != null) {
78 sb.append("SYMBOL '" + symbol + "'\n");
79 }
80
81 sb.append("END\n");
82 }
83 } // end of Style
84
85 public static class Label implements ClazzItem {
86 protected String color;
87 protected int size;
88
89 public void setColor(String color) {
90 this.color = color;
91 }
92
93 public void setSize(int size) {
94 this.size = size;
95 }
96
97 @Override
98 public void toString(StringBuilder sb) {
99 sb.append("LABEL\n");
100 sb.append("ANGLE auto\n");
101 sb.append("SIZE " + String.valueOf(size) + "\n");
102 sb.append("COLOR " + color + "\n");
103 sb.append("TYPE truetype\n");
104 sb.append("FONT DefaultFont\n");
105 sb.append("POSITION ur\n");
106 sb.append("OFFSET 2 2\n");
107 sb.append("END\n");
108 }
109 }
110
111
112 protected List<Clazz> classes;
113
114
115 public MapserverStyle() {
116 classes = new ArrayList<Clazz>();
117 }
118
119 public void addClazz(Clazz clazz) {
120 if (clazz != null) {
121 classes.add(clazz);
122 }
123 }
124
125 public String toString() {
126 StringBuilder sb = new StringBuilder();
127
128 for (Clazz clazz: classes) {
129 sb.append(clazz.toString());
130 }
131
132 return sb.toString();
133 }
134 }
135 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org