annotate src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 141:8f30f7e802d6

Manage symbol names and symbol comparison.
author vc11884admin@VC11884.win.bsh.de
date Mon, 27 Jun 2011 16:07:13 +0200
parents cd18c61cbcf6
children b2c5a66022f1
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;
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 public FillStyleWriter (mapObj map, classObj cl) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 logger.debug("contructor(mapObj, classObj)");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 this.map = map;
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 this.cl = cl;
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 this.style = new styleObj(cl);
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
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 * Write the content.
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 */
120
11d63bf00326 Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 101
diff changeset
48 public boolean write(Element symbolElement) {
123
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
49 logger.debug("write()Element");
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 symbolSetObj symbolSet = map.getSymbolset();
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 if(symbolElement.hasChildNodes()) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 NodeList symbols = symbolElement.getChildNodes();
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 for (int i = 0; i < symbols.getLength(); i++) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 Element nextSym = (Element)symbols.item(i);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 String type = nextSym.getAttribute("type");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 if(((symbols.getLength() > 1 && i == 0) ||
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 (symbols.getLength() == 1 &&
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 !symbolElement.hasAttribute("hatch"))) &&
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 type.equals("line")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 writeOutline(nextSym);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 if (symbols.getLength() == 1) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 writeSimple(symbolElement);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 }
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 else if(nextSym.getTagName().equals("symbol") &&
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 !symbolElement.hasAttribute("hatch") ||
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 (i == 1 && type.equals("marker"))) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 double gap = 0;
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 if(symbolElement.hasAttribute("xseparation")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 gap = Double.parseDouble(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 symbolElement.getAttribute("xseparation"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 writeMarker(nextSym, gap);
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 if(symbolElement.hasAttribute("angle")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 nextSym.setAttribute(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 "angle",
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 symbolElement.getAttribute("angle"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 if(symbolElement.hasAttribute("separation")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 nextSym.setAttribute(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 "size",
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 symbolElement.getAttribute("separation"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 writeMarker(nextSym, -1);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 else {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 writeSimple(symbolElement);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 else {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 writeSimple(symbolElement);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 if(symbolElement.hasAttribute("outline_color")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 Color oCol = Color.decode(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 symbolElement.getAttribute("outline_color"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 colorObj outlineColor = new colorObj(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 oCol.getRed(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 oCol.getGreen(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 oCol.getBlue(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 -4);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 style.setOutlinecolor(outlineColor);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 style.setOutlinewidth(Double.parseDouble(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 symbolElement.getAttribute("outline_size")));
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 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 return true;
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 /**
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 * Write the outline for a polygon.
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118 */
120
11d63bf00326 Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 101
diff changeset
119 private void writeOutline(Element symbolElement) {
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 logger.debug("writeOutline()");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 //write transparent outline
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 colorObj color = new colorObj(-1, -1, -1, -4);
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
123 if(symbolElement.hasAttribute("width")) {
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 123
diff changeset
124 double w = Double.parseDouble(symbolElement.getAttribute("width"));
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 123
diff changeset
125 if (w < 1.0) {
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 123
diff changeset
126 return;
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 123
diff changeset
127 }
cd18c61cbcf6 Do not write lines or outlines if their width is smaller than 1.0.
vc11884admin@VC11884.win.bsh.de
parents: 123
diff changeset
128 }
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 //write new style for the outline
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130 //TODO write further attribute like pattern etc.
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 Color oCol = Color.decode(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
132 symbolElement.getAttribute("color"));
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 styleObj outline = new styleObj (cl);
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 colorObj outlinecolor = new colorObj(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 oCol.getRed(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 oCol.getGreen(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
139 oCol.getBlue(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
140 -4);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
141 outline.setOutlinecolor(outlinecolor);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
142 outline.setOutlinewidth(Double.parseDouble(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
143 symbolElement.getAttribute("width")));
123
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
144 if(symbolElement.hasAttribute("linestyle")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
145 String ls = symbolElement.getAttribute("linestyle");
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
146 double[] vals;
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
147 if(ls.equals("dash")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
148 outline.setPatternlength(2);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
149 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
150 outline.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
151 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
152 else if(ls.equals("dot")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
153 outline.setPatternlength(2);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
154 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
155 outline.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
156 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
157 else if(ls.equals("dashdot")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
158 outline.setPatternlength(4);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
159 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
160 outline.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
161 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
162 else if (ls.equals("dashdotdot")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
163 outline.setPatternlength(6);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
164 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
165 outline.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
166 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
167 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
168
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
169
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
170 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
171
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
172 /**
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
173 * Write marker attributes and a symbol for the polygon fill.
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
174 */
120
11d63bf00326 Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 101
diff changeset
175 private void writeMarker(Element symbolElement, double gap) {
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
176 logger.debug("writeMarker()");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
177 String name = symbolElement.getAttribute("name");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
178 String type = symbolElement.getAttribute("type");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
179 if (symbolElement.hasAttribute("angle")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
180 style.setAngle(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
181 Double.parseDouble(symbolElement.getAttribute("angle")));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
182 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
183 if(symbolElement.hasAttribute("color")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
184 String c = symbolElement.getAttribute("color");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
185 Color col = Color.decode(c);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
186 colorObj color = new colorObj(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
187 col.getRed(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
188 col.getGreen(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
189 col.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.setColor(color);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
192 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
193 if (symbolElement.hasAttribute ("size")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
194 double size = Double.parseDouble(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
195 symbolElement.getAttribute("size"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
196 style.setSize(size);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
197 //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
198 //the separation - size
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
199 if (gap > 0) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
200 style.setGap(gap - size);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
201 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
202 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
203 if(symbolElement.hasAttribute("outline_color")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
204 Color oCol = Color.decode(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
205 symbolElement.getAttribute("outline_color"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
206 colorObj outlineColor = new colorObj(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
207 oCol.getRed(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
208 oCol.getGreen(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
209 oCol.getBlue(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
210 -4);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
211 style.setOutlinecolor(outlineColor);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
212 style.setOutlinewidth(Double.parseDouble(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
213 symbolElement.getAttribute("outline_size")));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
214 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
215 if(type.equals("marker")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
216 style.setSymbolByName(map, name);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
217 SymbolWriter sw = new SymbolWriter(this.map, this.cl);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
218 sw.write(symbolElement);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
219 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
220 else if(type.equals("line")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
221 style.setSymbolByName(map, "hatch");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
222 SymbolWriter sw = new SymbolWriter(this.map, this.cl);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
223 symbolElement.setAttribute("name", "hatch");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
224 sw.write(symbolElement);
123
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
225 if(symbolElement.hasAttribute("linestyle")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
226 String ls = symbolElement.getAttribute("linestyle");
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
227 double[] vals;
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
228 if(ls.equals("dash")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
229 style.setPatternlength(2);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
230 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
231 style.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
232 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
233 else if(ls.equals("dot")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
234 style.setPatternlength(2);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
235 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
236 style.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
237 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
238 else if(ls.equals("dashdot")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
239 style.setPatternlength(4);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
240 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
241 style.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
242 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
243 else if (ls.equals("dashdotdot")) {
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
244 style.setPatternlength(6);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
245 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
246 style.setPattern(vals);
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
247 }
3c792458a716 Write PATTERN for polygon outlines and hatch symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 120
diff changeset
248 }
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
249 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
250 }
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 * Write simple fill attributes.
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
254 */
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
255 private void writeSimple(Element symbolElement) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
256 logger.debug("writeSimple(Element)");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
257 if(symbolElement.hasAttribute("transparency")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
258 double value = Double.parseDouble(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
259 symbolElement.getAttribute("transparency"));
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
260 int opacity = (int)(value/255) * 100;
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
261 if(value >= 0) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
262 style.setOpacity(opacity);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
263 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
264 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
265 if(symbolElement.hasAttribute("color")) {
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
266 String c = symbolElement.getAttribute("color");
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
267 Color col = Color.decode(c);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
268 colorObj color = new colorObj(
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
269 col.getRed(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
270 col.getGreen(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
271 col.getBlue(),
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
272 -4);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
273 style.setColor(color);
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
274 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
275 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
276 }
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
277 // 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)