annotate src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 167:b1e4a871033e

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