Mercurial > mxd2map
annotate src/java/de/intevation/mxd/writer/LineStyleWriter.java @ 350:f7462ffaa645
Fix install documentation. Make Linux Doku presentable
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 16 Nov 2012 18:28:02 +0100 |
parents | 6b80e46b8f38 |
children |
rev | line source |
---|---|
243
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
1 /* |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
3 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
4 * This file is part of MXD2map. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
5 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
6 * This program is free software under the LGPL (>=v2.1) |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
7 * Read the file LICENCE.txt coming with the software for details |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
8 * or visit http://www.gnu.org/licenses/ if it does not exist. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
9 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
10 * MXD2map has been developed on behalf of the |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
12 * by Intevation GmbH. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
13 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
14 * Authors: |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
15 * Raimund Renkert <raimund.renkert@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
17 * Stephan Holl <stephan.holl@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
18 */ |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
184
diff
changeset
|
19 |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 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
|
21 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 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
|
23 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 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
|
25 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 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
|
27 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 /** |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 * 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
|
38 * |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 * @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
|
40 */ |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 public class LineStyleWriter { |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 /** |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 * The Logger. |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 */ |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 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
|
47 |
181 | 48 /** |
49 * Private mamber | |
50 */ | |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 private mapObj map; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 private classObj cl; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 private styleObj style; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 |
181 | 55 /** |
56 * Contructor with map object and class object. | |
57 * | |
58 * @param map The map object. | |
59 * @param cl The class object containing the style. | |
60 */ | |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 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
|
62 this.map = map; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 this.cl = cl; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 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
|
65 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 |
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 * Write the content. |
181 | 69 * |
70 * @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
|
71 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
95
diff
changeset
|
72 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
|
73 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
|
74 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
|
75 if(symbolElement.hasAttribute("width")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
76 double w = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
77 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
78 w = Double.parseDouble(symbolElement.getAttribute("width")); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
79 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
80 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
81 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
|
82 w = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
83 } |
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
|
84 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
|
85 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
|
86 } |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
87 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
|
88 } |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 if(symbolElement.hasAttribute("angle")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
90 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
91 style.setAngle( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
92 Double.parseDouble(symbolElement.getAttribute("angle"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
93 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
94 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
95 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
|
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 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
|
99 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
|
100 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
|
101 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
|
102 col.getRed(), |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 col.getGreen(), |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 col.getBlue(), |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 -4); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 style.setColor(color); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 } |
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
|
108 |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 if(symbolElement.hasAttribute("size")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
110 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
111 style.setSize((int)Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
112 symbolElement.getAttribute("size"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
113 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
114 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
115 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
|
116 style.setSize (1); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
117 } |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 } |
177
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("offset")) { |
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 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
|
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 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
|
124 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
|
125 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
|
126 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
|
127 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
128 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
|
129 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
|
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 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
|
132 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
|
133 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
134 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
|
135 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
|
136 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
137 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
138 |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
139 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
|
140 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
|
141 try { |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
146 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
|
147 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
|
148 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
149 } |
9fd61f4ac0e3
Write lines with width smaller than 1 and write further line attributes.
raimund renkert <raimund.renkert@intevation.de>
parents:
147
diff
changeset
|
150 |
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
|
151 |
95
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 //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
|
154 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
|
155 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
|
156 double[] vals; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 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
|
158 style.setPatternlength(2); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
159 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
|
160 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
161 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
162 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
|
163 style.setPatternlength(2); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
164 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
|
165 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
166 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
167 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
|
168 style.setPatternlength(4); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
169 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
|
170 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
171 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
172 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
|
173 style.setPatternlength(6); |
122
f0a72d232aa8
Set PATTERN for line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
174 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
|
175 style.setPattern(vals); |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
176 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
177 } |
136
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
178 else if(symbolElement.hasAttribute("pattern_count")) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
179 int count = 0; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
180 try { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
181 count = Integer.parseInt( |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
182 symbolElement.getAttribute("pattern_count")); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
183 double[] vals = new double[10]; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
184 double move = 0.0; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
185 int pos = 0; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
186 for(int i = 0; i < count; i++) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
187 double mark = |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
188 Double.parseDouble(symbolElement.getAttribute("mark_" + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
189 i)); |
136
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
190 double gap = |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
191 Double.parseDouble(symbolElement.getAttribute("gap_" + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
177
diff
changeset
|
192 i)); |
136
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
193 if(i == 0 && mark == 0.0) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
194 move = gap; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
195 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
196 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
|
197 vals[pos++] = mark; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
198 vals[pos++] = gap + move; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
199 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
200 else { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
201 vals[pos++] = mark; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
202 vals[pos++] = gap; |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
203 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
204 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
205 if(move > 0.0) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
206 style.setPatternlength((count*2) -2); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
207 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
208 else { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
209 style.setPatternlength(count*2); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
210 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
211 style.setPattern(vals); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
212 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
213 catch(NumberFormatException nfe) { |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
214 logger.warn("Could not write PATTERN."); |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
215 } |
7632850b9520
Convert cartographic line template to mapfile pattern.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
216 } |
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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 } |
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
|
225 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
|
226 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
|
227 SymbolWriter sw = new SymbolWriter (this.map, this.cl); |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
228 if(symbolElement.getAttribute("style").equals("picture")){ |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
229 sw.write(symbolElement); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
230 style.setSymbolByName( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
231 map, |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
232 symbolElement.getAttribute("name")); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
233 } |
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
|
234 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
|
235 } |
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
|
236 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
|
237 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
|
238 } |
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
|
239 } |
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
|
240 |
95
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
241 return false; |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
242 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
243 } |
1ae8e05b863f
Use the line style writer to write simple lines and marker lines.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
244 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |