annotate src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 356:1e0c7e134e7b tip

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