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