annotate src/java/de/intevation/mxd/writer/MarkerStyleWriter.java @ 188:43f1cbdcd597

Modified and beautified the documentation: * INSTALL.txt, doku/Makefile, doku/source/conf.py, doku/source/functionality.txt, doku/source/index.txt, doku/source/restrictions.txt, website/favicon.png, LICENCE.txt: added more details to the content of the documentation. some more configurations. * doku/source/LICENCE.txt: New. Added a licence-text (symlinking into the documentation). * doku/source/_static/favicon.png, doku/source/_static/logo_wide.png, doku/source/_templates/indexsidebar.html, doku/source/_templates/layout.html: Optic-cosmetics.
author Stephan Holl <stephan.holl@intevation.de>
date Wed, 20 Jul 2011 15:53:01 +0200
parents 0bde090506f9
children 17b4aaa159ec
rev   line source
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.writer;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Element;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import edu.umn.gis.mapscript.mapObj;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import edu.umn.gis.mapscript.classObj;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import edu.umn.gis.mapscript.styleObj;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import edu.umn.gis.mapscript.colorObj;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import edu.umn.gis.mapscript.symbolSetObj;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 /**
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 * The interface to the mapfile writer.
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 *
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 */
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 public class MarkerStyleWriter {
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 /**
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 * The Logger.
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 */
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 private static final Logger logger = Logger.getLogger(MarkerStyleWriter.class);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
28 /**
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
29 * Private member.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
30 */
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 private mapObj map;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 private classObj cl;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 private styleObj style;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
35 /**
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
36 * Contructor with map object and class object.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
37 *
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
38 * @param map The map object.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
39 * @param cl The class object containing the style.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
40 */
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 public MarkerStyleWriter (mapObj map, classObj cl) {
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 this.map = map;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 this.cl = cl;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 this.style = new styleObj(cl);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 /**
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 * Write the content.
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
49 *
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 145
diff changeset
50 * @param symbolElement DOM element containing style attributes.
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 */
120
11d63bf00326 Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 87
diff changeset
52 public boolean write(Element symbolElement) {
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 logger.debug("write(Element)");
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 symbolSetObj symbolSet = map.getSymbolset();
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 if (symbolElement.hasAttribute("angle")) {
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
57 try {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
58 style.setAngle(
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
59 Double.parseDouble(symbolElement.getAttribute("angle")));
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
60 }
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
61 catch(NumberFormatException nfe) {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
62 logger.warn("Error setting angle.");
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
63 style.setAngle(0.0);
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
64 }
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 if(symbolElement.hasAttribute("color")) {
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 String c = symbolElement.getAttribute("color");
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 Color col = Color.decode(c);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 colorObj color = new colorObj(
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 col.getRed(),
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 col.getGreen(),
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 col.getBlue(),
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 -4);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 style.setColor(color);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 if (symbolElement.hasAttribute ("size")) {
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
77 try {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
78 style.setSize(Double.parseDouble(
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
79 symbolElement.getAttribute("size")));
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
80 }
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
81 catch(NumberFormatException nfe) {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
82 logger.warn("Error setting size. Setting to deafult: 1.");
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
83 style.setSize(1);
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
84 }
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 if(symbolElement.hasAttribute("outline_color")) {
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 Color oCol = Color.decode(
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 symbolElement.getAttribute("outline_color"));
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 colorObj outlineColor = new colorObj(
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 oCol.getRed(),
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 oCol.getGreen(),
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 oCol.getBlue(),
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 -4);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 style.setOutlinecolor(outlineColor);
145
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
95 try {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
96 style.setOutlinewidth(Double.parseDouble(
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
97 symbolElement.getAttribute("outline_size")));
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
98 }
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
99 catch(NumberFormatException nfe) {
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
100 logger.warn("Error setting outline width.");
b2c5a66022f1 Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents: 141
diff changeset
101 }
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 String symType = symbolElement.getAttribute("style");
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 if(symType.equals("point") ||
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 symType.equals("arrow") ||
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 symType.equals("char")) {
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 SymbolWriter sw = new SymbolWriter(this.map, this.cl);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 sw.write(symbolElement);
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 else {
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 return false;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 }
141
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 120
diff changeset
113 String name = symbolElement.getAttribute("name");
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 120
diff changeset
114 style.setSymbolByName(map, name);
8f30f7e802d6 Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents: 120
diff changeset
115
87
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 return true;
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118 }
7d4cf2db43f1 Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
119 // 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)