annotate src/java/de/intevation/mxd/writer/LineStyleWriter.java @ 147:03daf386f19a

Manage symbol name for line symbols.
author vc11884admin@VC11884.win.bsh.de
date Wed, 29 Jun 2011 17:36:07 +0200
parents b2c5a66022f1
children 9fd61f4ac0e3
rev   line source
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.writer;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Element;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import edu.umn.gis.mapscript.mapObj;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import edu.umn.gis.mapscript.classObj;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import edu.umn.gis.mapscript.styleObj;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import edu.umn.gis.mapscript.colorObj;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import edu.umn.gis.mapscript.symbolObj;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import edu.umn.gis.mapscript.symbolSetObj;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 /**
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 * The interface to the mapfile writer.
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 *
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 */
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 public class LineStyleWriter {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 /**
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 * The Logger.
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 */
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 private static final Logger logger = Logger.getLogger(LineStyleWriter.class);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 private mapObj map;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 private classObj cl;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 private styleObj style;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 public LineStyleWriter (mapObj map, classObj cl) {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 this.map = map;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 this.cl = cl;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 this.style = new styleObj(cl);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 /**
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 * Write the content.
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 */
120
11d63bf00326 Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 95
diff changeset
42 public boolean write(Element symbolElement) {
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 logger.debug("write(Element)");
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 symbolSetObj symbolSet = map.getSymbolset();
131
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 122
diff changeset
45 if(symbolElement.hasAttribute("width")) {
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
46 double w = 0;
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
47 try {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
48 w = Double.parseDouble(symbolElement.getAttribute("width"));
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
49 }
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
50 catch(NumberFormatException nfe) {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
51 logger.warn("Error setting width. No line width set.");
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
52 w = 0;
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
53 }
131
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 122
diff changeset
54 if(w < 1.0) {
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 122
diff changeset
55 return false;
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 122
diff changeset
56 }
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
57 style.setWidth((int)w);
131
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 122
diff changeset
58 }
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 if(symbolElement.hasAttribute("angle")) {
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
60 try {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
61 style.setAngle(
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
62 Double.parseDouble(symbolElement.getAttribute("angle")));
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
63 }
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
64 catch(NumberFormatException nfe) {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
65 logger.info("Error setting angle. Could not get value.");
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
66 }
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 if(symbolElement.hasAttribute("color")) {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 String c = symbolElement.getAttribute("color");
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 Color col = Color.decode(c);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 colorObj color = new colorObj(
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 col.getRed(),
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 col.getGreen(),
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 col.getBlue(),
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 -4);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 style.setColor(color);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 }
131
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 122
diff changeset
78
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 if(symbolElement.hasAttribute("size")) {
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
80 try {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
81 style.setSize((int)Double.parseDouble(
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
82 symbolElement.getAttribute("size")));
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
83 }
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
84 catch(NumberFormatException nfe) {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
85 logger.warn("Error setting size. Setting size to 1.");
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
86 style.setSize (1);
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
87 }
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 }
141
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 136
diff changeset
89 String type = symbolElement.getAttribute("type");
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 136
diff changeset
90 if(type.equals("marker")) {
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 136
diff changeset
91 SymbolWriter sw = new SymbolWriter(this.map, this.cl);
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 136
diff changeset
92 sw.write(symbolElement);
147
03daf386f19a Manage symbol name for line symbols.
vc11884admin@VC11884.win.bsh.de
parents: 145
diff changeset
93 String name = symbolElement.getAttribute("name");
03daf386f19a Manage symbol name for line symbols.
vc11884admin@VC11884.win.bsh.de
parents: 145
diff changeset
94 style.setSymbolByName(map, name);
03daf386f19a Manage symbol name for line symbols.
vc11884admin@VC11884.win.bsh.de
parents: 145
diff changeset
95 symbolObj sym = symbolSet.getSymbolByName(name);
141
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 136
diff changeset
96 }
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 //The following lines are for dashed and/or dotted lines.
122
f0a72d232aa8 Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
99 if(symbolElement.hasAttribute("linestyle")) {
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 String ls = symbolElement.getAttribute("linestyle");
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 double[] vals;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 if(ls.equals("dash")) {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 style.setPatternlength(2);
122
f0a72d232aa8 Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
104 vals = new double[] {4.0, 4.0, 0, 0, 0, 0, 0, 0, 0, 0};
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 style.setPattern(vals);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 else if(ls.equals("dot")) {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 style.setPatternlength(2);
122
f0a72d232aa8 Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
109 vals = new double[] {1.0, 4.0, 0, 0, 0, 0, 0, 0, 0, 0};
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 style.setPattern(vals);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 else if(ls.equals("dashdot")) {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 style.setPatternlength(4);
122
f0a72d232aa8 Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
114 vals = new double[] {5.0, 4.0, 1.0, 4.0, 0, 0, 0, 0, 0, 0};
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115 style.setPattern(vals);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 else if (ls.equals("dashdotdot")) {
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118 style.setPatternlength(6);
122
f0a72d232aa8 Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
119 vals = new double[] {5.0, 4.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0};
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 style.setPattern(vals);
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 }
136
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
123 else if(symbolElement.hasAttribute("pattern_count")) {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
124 int count = 0;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
125 try {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
126 count = Integer.parseInt(
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
127 symbolElement.getAttribute("pattern_count"));
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
128 double[] vals = new double[10];
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
129 double move = 0.0;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
130 int pos = 0;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
131 for(int i = 0; i < count; i++) {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
132 double mark =
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
133 Double.parseDouble(symbolElement.getAttribute("mark_" + i));
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
134 double gap =
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
135 Double.parseDouble(symbolElement.getAttribute("gap_" + i));
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
136 if(i == 0 && mark == 0.0) {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
137 move = gap;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
138 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
139 else if(i == count - 1 && move > 0.0) {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
140 vals[pos++] = mark;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
141 vals[pos++] = gap + move;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
142 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
143 else {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
144 vals[pos++] = mark;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
145 vals[pos++] = gap;
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
146 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
147 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
148 if(move > 0.0) {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
149 style.setPatternlength((count*2) -2);
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
150 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
151 else {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
152 style.setPatternlength(count*2);
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
153 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
154 style.setPattern(vals);
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
155
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
156 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
157 catch(NumberFormatException nfe) {
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
158 logger.warn("Could not write PATTERN.");
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
159 }
7632850b9520 Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents: 131
diff changeset
160 }
95
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
161 return false;
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
162 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
163 }
1ae8e05b863f Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
164 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)