Mercurial > mxd2map
annotate src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 251:6b80e46b8f38
Added picture symbol support to the converter.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 12 Aug 2011 16:08:57 +0200 |
parents | df4e0946ef02 |
children | 2cb2f26d0d54 |
rev | line source |
---|---|
243
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
1 /* |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
3 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
4 * This file is part of MXD2map. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
5 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
6 * This program is free software under the LGPL (>=v2.1) |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
7 * Read the file LICENCE.txt coming with the software for details |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
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:
242
diff
changeset
|
9 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
10 * MXD2map has been developed on behalf of the |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
12 * by Intevation GmbH. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
13 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
14 * Authors: |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
15 * Raimund Renkert <raimund.renkert@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
17 * Stephan Holl <stephan.holl@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
18 */ |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
242
diff
changeset
|
19 |
97 | 20 package de.intevation.mxd.writer; |
21 | |
22 import java.io.IOException; | |
23 import java.awt.Color; | |
24 import org.apache.log4j.Logger; | |
25 | |
26 import org.w3c.dom.Element; | |
27 import org.w3c.dom.NodeList; | |
28 | |
29 import edu.umn.gis.mapscript.mapObj; | |
30 import edu.umn.gis.mapscript.layerObj; | |
31 import edu.umn.gis.mapscript.classObj; | |
32 import edu.umn.gis.mapscript.styleObj; | |
33 import edu.umn.gis.mapscript.colorObj; | |
34 import edu.umn.gis.mapscript.symbolObj; | |
35 import edu.umn.gis.mapscript.symbolSetObj; | |
36 import edu.umn.gis.mapscript.lineObj; | |
37 import edu.umn.gis.mapscript.pointObj; | |
38 | |
39 | |
40 /** | |
41 * The interface to the mapfile writer. | |
42 * | |
43 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
44 */ | |
45 public class FillStyleWriter { | |
46 | |
47 /** | |
48 * The Logger. | |
49 */ | |
50 private static final Logger logger = | |
51 Logger.getLogger(FillStyleWriter.class); | |
52 | |
181 | 53 /** |
54 * Private member. | |
55 */ | |
97 | 56 private mapObj map; |
57 private classObj cl; | |
58 private styleObj style; | |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
59 private colorObj fill; |
97 | 60 |
181 | 61 /** |
62 * Constructor with map object and class object. | |
63 * | |
64 * @param map The map object. | |
65 * @param cl The class object containing the style. | |
66 */ | |
97 | 67 public FillStyleWriter (mapObj map, classObj cl) { |
68 logger.debug("contructor(mapObj, classObj)"); | |
69 this.map = map; | |
70 this.cl = cl; | |
71 this.style = new styleObj(cl); | |
72 } | |
73 | |
74 /** | |
75 * Write the content. | |
181 | 76 * |
77 * @param symbolElement DOM element containing style attributes. | |
97 | 78 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
101
diff
changeset
|
79 public boolean write(Element symbolElement) { |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
80 logger.debug("write(Element)"); |
97 | 81 symbolSetObj symbolSet = map.getSymbolset(); |
82 | |
83 if(symbolElement.hasChildNodes()) { | |
84 NodeList symbols = symbolElement.getChildNodes(); | |
85 for (int i = 0; i < symbols.getLength(); i++) { | |
86 Element nextSym = (Element)symbols.item(i); | |
87 String type = nextSym.getAttribute("type"); | |
88 if(((symbols.getLength() > 1 && i == 0) || | |
89 (symbols.getLength() == 1 && | |
90 !symbolElement.hasAttribute("hatch"))) && | |
91 type.equals("line")) { | |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
92 if(symbolElement.hasAttribute("color")) { |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
93 Color oCol = Color.decode( |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
94 symbolElement.getAttribute("color")); |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
95 fill = new colorObj( |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
96 oCol.getRed(), |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
97 oCol.getGreen(), |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
98 oCol.getBlue(), |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
99 -4); |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
100 } |
97 | 101 writeOutline(nextSym); |
102 if (symbols.getLength() == 1) { | |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
103 String stype = symbolElement.getAttribute("style"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
104 if(stype.equals("picture")) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
105 double gap = 0; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
106 if(symbolElement.hasAttribute("xseparation")) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
107 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
108 gap = Double.parseDouble( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
109 symbolElement.getAttribute("xseparation")); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
110 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
111 catch(NumberFormatException nfe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
112 gap = 0; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
113 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
114 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
115 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
116 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
117 SymbolWriter sw = |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
118 new SymbolWriter(this.map, this.cl); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
119 sw.write(symbolElement); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
120 sw.saveSymbolSet(symbolSet); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
121 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
122 catch(Exception e) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
123 logger.warn("Could not save symbol set."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
124 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
125 writeMarker(symbolElement, gap); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
126 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
127 else { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
128 writeSimple(symbolElement); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
129 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
130 SymbolWriter sw = |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
131 new SymbolWriter(this.map, this.cl); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
132 sw.saveSymbolSet(symbolSet); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
133 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
134 catch(Exception e) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
135 logger.warn("Could not save symbol set."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
136 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
137 } |
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
|
138 } |
97 | 139 } |
140 else if(nextSym.getTagName().equals("symbol") && | |
141 !symbolElement.hasAttribute("hatch") || | |
142 (i == 1 && type.equals("marker"))) { | |
143 double gap = 0; | |
144 if(symbolElement.hasAttribute("xseparation")) { | |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
145 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
146 gap = Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
147 symbolElement.getAttribute("xseparation")); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
148 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
149 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
150 gap = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
151 } |
97 | 152 } |
153 writeMarker(nextSym, gap); | |
154 } | |
155 else if (nextSym.getTagName().equals("symbol") && | |
156 symbolElement.hasAttribute("hatch")) { | |
168
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
157 if(i == 0) { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
158 writeOutline(nextSym); |
97 | 159 } |
168
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
160 else { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
161 if(symbolElement.hasAttribute("angle")) { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
162 nextSym.setAttribute( |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
163 "angle", |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
164 symbolElement.getAttribute("angle")); |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
165 } |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
166 if(symbolElement.hasAttribute("separation")) { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
167 nextSym.setAttribute( |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
168 "size", |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
169 symbolElement.getAttribute("separation")); |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
170 } |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
171 writeMarker(nextSym, -1); |
97 | 172 } |
173 } | |
174 else { | |
175 writeSimple(symbolElement); | |
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
|
176 try { |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
177 SymbolWriter sw = |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
178 new SymbolWriter(this.map, this.cl); |
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
|
179 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
|
180 } |
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
|
181 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
|
182 logger.warn("Could not save 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
|
183 } |
97 | 184 } |
185 } | |
186 } | |
187 else { | |
188 writeSimple(symbolElement); | |
189 if(symbolElement.hasAttribute("outline_color")) { | |
190 Color oCol = Color.decode( | |
191 symbolElement.getAttribute("outline_color")); | |
192 colorObj outlineColor = new colorObj( | |
193 oCol.getRed(), | |
194 oCol.getGreen(), | |
195 oCol.getBlue(), | |
196 -4); | |
197 style.setOutlinecolor(outlineColor); | |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
198 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
199 style.setOutlinewidth(Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
200 symbolElement.getAttribute("outline_size"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
201 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
202 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
203 logger.warn("Error setting outline width."); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
204 style.setOutlinewidth(0.0); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
205 } |
97 | 206 } |
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
|
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 save 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 } |
97 | 214 } |
215 return true; | |
216 } | |
217 | |
218 /** | |
219 * Write the outline for a polygon. | |
181 | 220 * |
221 * @param symbolElement Dom element containing the symbol attributes. | |
97 | 222 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
101
diff
changeset
|
223 private void writeOutline(Element symbolElement) { |
97 | 224 logger.debug("writeOutline()"); |
225 //write transparent outline | |
226 colorObj color = new colorObj(-1, -1, -1, -4); | |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
227 double w = 0; |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
228 double transp = -1; |
131
cd18c61cbcf6
Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents:
123
diff
changeset
|
229 if(symbolElement.hasAttribute("width")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
230 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
231 w = Double.parseDouble(symbolElement.getAttribute("width")); |
167
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
232 if(symbolElement.hasAttribute("transparency")) { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
233 transp = Double.parseDouble( |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
234 symbolElement.getAttribute("transparency")); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
235 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
236 else { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
237 transp = -1; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
238 } |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
239 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
240 catch(NumberFormatException nfe) { |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
241 logger.warn("Error setting outline width or transparency."); |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
242 w = 0; |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
243 transp = -1; |
131
cd18c61cbcf6
Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents:
123
diff
changeset
|
244 } |
cd18c61cbcf6
Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents:
123
diff
changeset
|
245 } |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
168
diff
changeset
|
246 |
97 | 247 Color oCol = Color.decode( |
248 symbolElement.getAttribute("color")); | |
249 | |
250 styleObj outline = new styleObj (cl); | |
242
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
251 if (w < 1.0) { |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
252 symbolElement.setAttribute("width", "1"); |
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
253 } |
242
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
254 colorObj outlinecolor = new colorObj( |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
255 oCol.getRed(), |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
256 oCol.getGreen(), |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
257 oCol.getBlue(), |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
258 -4); |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
259 outline.setOutlinecolor(outlinecolor); |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
260 if(transp >= 0) { |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
261 int opacity = (int)((1 - (transp/255)) * 100); |
bb25c7a4553e
Refactored outline handling for polygons.
raimund renkert <raimund.renkert@intevation.de>
parents:
240
diff
changeset
|
262 outline.setOpacity(opacity); |
150
7b1433d3b574
Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
263 } |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
264 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
265 outline.setOutlinewidth(Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
266 symbolElement.getAttribute("width"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
267 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
268 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
269 logger.warn("Error setting outline width."); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
270 outline.setOutlinewidth(0.0); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
271 } |
123
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
272 if(symbolElement.hasAttribute("linestyle")) { |
181 | 273 //Write predefined dashed or dotted lines. |
123
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
274 String ls = symbolElement.getAttribute("linestyle"); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
275 double[] vals; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
276 if(ls.equals("dash")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
277 outline.setPatternlength(2); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
278 vals = new double[] {4.0, 4.0, 0, 0, 0, 0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
279 outline.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
280 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
281 else if(ls.equals("dot")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
282 outline.setPatternlength(2); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
283 vals = new double[] {1.0, 3.0, 0, 0, 0, 0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
284 outline.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
285 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
286 else if(ls.equals("dashdot")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
287 outline.setPatternlength(4); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
288 vals = new double[] {4.0, 3.0, 1.0, 3.0, 0, 0, 0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
289 outline.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
290 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
291 else if (ls.equals("dashdotdot")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
292 outline.setPatternlength(6); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
293 vals = new double[] {5.0, 3.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
294 outline.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
295 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
296 } |
167
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
297 else if(symbolElement.hasAttribute("pattern_count")) { |
181 | 298 //Write dashed or dotted lines defined with a template. |
167
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
299 int count = 0; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
300 try { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
301 count = Integer.parseInt( |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
302 symbolElement.getAttribute("pattern_count")); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
303 double[] vals = new double[10]; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
304 double move = 0.0; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
305 int pos = 0; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
306 for(int i = 0; i < count; i++) { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
307 double mark = |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
308 Double.parseDouble(symbolElement.getAttribute("mark_" + i)); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
309 double gap = |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
310 Double.parseDouble(symbolElement.getAttribute("gap_" + i)); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
311 if(i == 0 && mark == 0.0) { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
312 move = gap; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
313 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
314 else if(i == count - 1 && move > 0.0) { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
315 vals[pos++] = mark; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
316 vals[pos++] = gap + move; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
317 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
318 else { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
319 vals[pos++] = mark; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
320 vals[pos++] = gap; |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
321 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
322 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
323 if(move > 0.0) { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
324 outline.setPatternlength((count*2) -2); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
325 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
326 else { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
327 outline.setPatternlength(count*2); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
328 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
329 outline.setPattern(vals); |
123
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
330 |
167
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
331 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
332 catch(NumberFormatException nfe) { |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
333 logger.warn("Could not write PATTERN."); |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
334 } |
b1e4a871033e
Write special pattern for outlines.
vc11884admin@VC11884.win.bsh.de
parents:
150
diff
changeset
|
335 } |
97 | 336 } |
337 | |
338 /** | |
339 * Write marker attributes and a symbol for the polygon fill. | |
181 | 340 * |
341 * @param symbolElement DOM element containingg the symbol attributes. | |
342 * @param gap The initial gap at the begining of a line. | |
97 | 343 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
101
diff
changeset
|
344 private void writeMarker(Element symbolElement, double gap) { |
97 | 345 logger.debug("writeMarker()"); |
346 String name = symbolElement.getAttribute("name"); | |
347 String type = symbolElement.getAttribute("type"); | |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
348 String stype = symbolElement.getAttribute("style"); |
97 | 349 if (symbolElement.hasAttribute("angle")) { |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
350 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
351 style.setAngle( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
352 Double.parseDouble(symbolElement.getAttribute("angle"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
353 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
354 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
355 logger.warn("Error setting angle."); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
356 style.setAngle(0.0); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
357 } |
97 | 358 } |
359 if(symbolElement.hasAttribute("color")) { | |
360 String c = symbolElement.getAttribute("color"); | |
361 Color col = Color.decode(c); | |
362 colorObj color = new colorObj( | |
363 col.getRed(), | |
364 col.getGreen(), | |
365 col.getBlue(), | |
366 -4); | |
367 style.setColor(color); | |
368 } | |
369 if (symbolElement.hasAttribute ("size")) { | |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
370 double size = 1; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
371 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
372 size = Double.parseDouble(symbolElement.getAttribute("size")); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
373 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
374 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
375 size = 1.0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
376 } |
97 | 377 style.setSize(size); |
378 //In arcgis the separation goes from center to center, so the gap is | |
379 //the separation - size | |
380 if (gap > 0) { | |
381 style.setGap(gap - size); | |
382 } | |
383 } | |
168
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
384 if(symbolElement.hasAttribute("width")) { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
385 double width = 1; |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
386 try { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
387 width = Double.parseDouble(symbolElement.getAttribute("width")); |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
388 } |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
389 catch(NumberFormatException nfe) { |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
390 width = 1.0; |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
391 } |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
392 style.setWidth(width); |
f3a539ace2a4
Write line width and outline for polygons filled with hatch symbol.
vc11884admin@VC11884.win.bsh.de
parents:
167
diff
changeset
|
393 } |
97 | 394 if(symbolElement.hasAttribute("outline_color")) { |
395 Color oCol = Color.decode( | |
396 symbolElement.getAttribute("outline_color")); | |
397 colorObj outlineColor = new colorObj( | |
398 oCol.getRed(), | |
399 oCol.getGreen(), | |
400 oCol.getBlue(), | |
401 -4); | |
402 style.setOutlinecolor(outlineColor); | |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
403 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
404 style.setOutlinewidth(Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
405 symbolElement.getAttribute("outline_size"))); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
406 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
407 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
408 logger.warn("Error setting angle."); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
409 style.setOutlinewidth(0.0); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
410 } |
97 | 411 } |
412 if(type.equals("marker")) { | |
413 style.setSymbolByName(map, name); | |
414 SymbolWriter sw = new SymbolWriter(this.map, this.cl); | |
415 sw.write(symbolElement); | |
416 } | |
417 else if(type.equals("line")) { | |
418 style.setSymbolByName(map, "hatch"); | |
419 SymbolWriter sw = new SymbolWriter(this.map, this.cl); | |
420 symbolElement.setAttribute("name", "hatch"); | |
421 sw.write(symbolElement); | |
123
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
422 if(symbolElement.hasAttribute("linestyle")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
423 String ls = symbolElement.getAttribute("linestyle"); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
424 double[] vals; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
425 if(ls.equals("dash")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
426 style.setPatternlength(2); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
427 vals = new double[] {4.0, 4.0, 0, 0, 0, 0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
428 style.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
429 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
430 else if(ls.equals("dot")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
431 style.setPatternlength(2); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
432 vals = new double[] {1.0, 3.0, 0, 0, 0, 0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
433 style.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
434 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
435 else if(ls.equals("dashdot")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
436 style.setPatternlength(4); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
437 vals = new double[] {4.0, 3.0, 1.0, 3.0, 0, 0, 0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
438 style.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
439 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
440 else if (ls.equals("dashdotdot")) { |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
441 style.setPatternlength(6); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
442 vals = new double[] {5.0, 3.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0}; |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
443 style.setPattern(vals); |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
444 } |
3c792458a716
Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
445 } |
97 | 446 } |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
447 if(stype.equals("picture")) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
448 style.setSymbolByName(map, name); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
449 } |
97 | 450 } |
451 | |
452 /** | |
453 * Write simple fill attributes. | |
181 | 454 * |
455 * @param symbolElement DOM element containing the symbol attributes. | |
97 | 456 */ |
457 private void writeSimple(Element symbolElement) { | |
458 logger.debug("writeSimple(Element)"); | |
459 if(symbolElement.hasAttribute("transparency")) { | |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
460 double value = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
461 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
462 value = Double.parseDouble( |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
463 symbolElement.getAttribute("transparency")); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
464 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
465 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
466 value = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
131
diff
changeset
|
467 } |
240
b54afdbc5892
Set opacity for simple polygons in a range from 0 - 100.
raimund renkert <raimund.renkert@intevation.de>
parents:
184
diff
changeset
|
468 int opacity = (int)(1 - (value/255)) * 100; |
b54afdbc5892
Set opacity for simple polygons in a range from 0 - 100.
raimund renkert <raimund.renkert@intevation.de>
parents:
184
diff
changeset
|
469 style.setOpacity(opacity); |
97 | 470 } |
471 if(symbolElement.hasAttribute("color")) { | |
472 String c = symbolElement.getAttribute("color"); | |
473 Color col = Color.decode(c); | |
474 colorObj color = new colorObj( | |
475 col.getRed(), | |
476 col.getGreen(), | |
477 col.getBlue(), | |
478 -4); | |
479 style.setColor(color); | |
480 } | |
481 } | |
482 } | |
483 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |