Mercurial > mxd2map
annotate src/java/de/intevation/mxd/writer/LineStyleWriter.java @ 206:4ebba3c52924
Updated restrictions.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 21 Jul 2011 16:56:28 +0200 |
parents | c79c3c6fc99a |
children | df4e0946ef02 |
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 |
181 | 29 /** |
30 * Private mamber | |
31 */ | |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 private mapObj map; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 private classObj cl; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 private styleObj style; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 |
181 | 36 /** |
37 * Contructor with map object and class object. | |
38 * | |
39 * @param map The map object. | |
40 * @param cl The class object containing the style. | |
41 */ | |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 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
|
43 this.map = map; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 this.cl = cl; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 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
|
46 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 /** |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 * Write the content. |
181 | 50 * |
51 * @param symbolElement DOM element containing style attributes. | |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
95
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 if(symbolElement.hasAttribute("width")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
57 double w = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
58 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
59 w = Double.parseDouble(symbolElement.getAttribute("width")); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
60 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
61 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
62 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
|
63 w = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
64 } |
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
|
65 if(w < 1.0) { |
177
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
66 w = 1; |
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
|
67 } |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
68 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
|
69 } |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 if(symbolElement.hasAttribute("angle")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
71 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
72 style.setAngle( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
73 Double.parseDouble(symbolElement.getAttribute("angle"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
74 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
75 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
76 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
|
77 } |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 } |
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("color")) { |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 col.getRed(), |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 col.getGreen(), |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 col.getBlue(), |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 -4); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 style.setColor(color); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 } |
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
|
89 |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 if(symbolElement.hasAttribute("size")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
91 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
92 style.setSize((int)Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
93 symbolElement.getAttribute("size"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
94 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
95 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
96 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
|
97 style.setSize (1); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
98 } |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
99 } |
177
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
100 |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
101 if(symbolElement.hasAttribute("offset")) { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
102 double offset = 0; |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
103 try { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
104 offset = Double.parseDouble( |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
105 symbolElement.getAttribute("offset")); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
106 if(Math.abs(offset) < 1 && offset > 0) { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
107 offset = 1; |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
108 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
109 else if (Math.abs(offset) < 1 && offset < 0) { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
110 offset = -1; |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
111 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
112 style.setOffsetx(offset); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
113 style.setOffsety(-99); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
114 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
115 catch(NumberFormatException nfe) { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
116 logger.warn("Could not set offset."); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
117 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
118 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
119 |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
120 if(symbolElement.hasAttribute("miterlimit")) { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
121 double miter = 0; |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
122 try { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
123 miter = Double.parseDouble( |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
124 symbolElement.getAttribute("miterlimit")); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
125 style.setLinejoinmaxsize(miter); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
126 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
127 catch(NumberFormatException nfe) { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
128 logger.warn("Could not set miter limit."); |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
129 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
130 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
131 |
184
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
132 |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
133 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
134 //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
|
135 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
|
136 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
|
137 double[] vals; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
138 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
|
139 style.setPatternlength(2); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
140 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
|
141 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
143 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
|
144 style.setPatternlength(2); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
145 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
|
146 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
148 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
|
149 style.setPatternlength(4); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
150 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
|
151 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
152 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
153 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
|
154 style.setPatternlength(6); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
155 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
|
156 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
158 } |
136
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
159 else if(symbolElement.hasAttribute("pattern_count")) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
160 int count = 0; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
161 try { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
162 count = Integer.parseInt( |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
163 symbolElement.getAttribute("pattern_count")); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
164 double[] vals = new double[10]; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
165 double move = 0.0; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
166 int pos = 0; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
167 for(int i = 0; i < count; i++) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
168 double mark = |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
169 Double.parseDouble(symbolElement.getAttribute("mark_" + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
170 i)); |
136
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
171 double gap = |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
172 Double.parseDouble(symbolElement.getAttribute("gap_" + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
173 i)); |
136
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
174 if(i == 0 && mark == 0.0) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
175 move = gap; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
176 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
177 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
|
178 vals[pos++] = mark; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
179 vals[pos++] = gap + move; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
180 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
181 else { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
182 vals[pos++] = mark; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
183 vals[pos++] = gap; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
184 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
185 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
186 if(move > 0.0) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
187 style.setPatternlength((count*2) -2); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
188 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
189 else { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
190 style.setPatternlength(count*2); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
191 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
192 style.setPattern(vals); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
193 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
194 catch(NumberFormatException nfe) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
195 logger.warn("Could not write PATTERN."); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
196 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
197 } |
184
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
198 String type = symbolElement.getAttribute("type"); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
199 if(type.equals("marker")) { |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
200 SymbolWriter sw = new SymbolWriter(this.map, this.cl); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
201 sw.write(symbolElement); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
202 String name = symbolElement.getAttribute("name"); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
203 style.setSymbolByName(map, name); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
204 symbolObj sym = symbolSet.getSymbolByName(name); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
205 } |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
206 else { |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
207 try { |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
208 SymbolWriter sw = new SymbolWriter (this.map, this.cl); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
209 sw.saveSymbolSet (symbolSet); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
210 } |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
211 catch (Exception e) { |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
212 logger.warn("Could not write symbol set."); |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
213 } |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
214 } |
c79c3c6fc99a
Always save a symbol set, use the mapfile name as prefix for the symbol set and
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
215 |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
216 return false; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
217 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
218 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
219 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |