annotate src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java @ 44:9b5fb5e5914d

Added expressions for mapserver classes.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 18 Apr 2011 14:50:49 +0200
parents 7a927921eb6c
children 90d4de478f15
rev   line source
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
1 package de.intevation.mxd.reader;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import com.esri.arcgis.carto.IFeatureRenderer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import com.esri.arcgis.carto.ClassBreaksRenderer;
44
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
9 import com.esri.arcgis.display.ISymbol;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
11 import org.w3c.dom.Element;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
12
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
13 import de.intevation.mxd.utils.MapToXMLUtils;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
14
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 * Reads the ClassBreaksRender Object Attributes.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 */
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
20 public class ClassBreakRendererReader
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
21 implements IRendererReader {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
23 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
24 * The logger.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
25 */
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 private static final Logger logger =
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 Logger.getLogger(ClassBreakRendererReader.class);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
29 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
30 * Private member.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
31 */
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 private ClassBreaksRenderer renderer;
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
33 private Element layer;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
34 private MapToXMLUtils util;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
36
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
37 public ClassBreakRendererReader(IFeatureRenderer renderer)
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
38 throws Exception {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 logger.debug("contructor()");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 if(renderer instanceof ClassBreaksRenderer)
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 this.renderer = (ClassBreaksRenderer)renderer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 else
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 throw new Exception("Not a ClassBreaksRenderer!");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
46 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
47 * Setter for the parent XML element.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
48 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
49 * @param parent The XML parent node.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
50 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
51 public void setParent(Element parent) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
52 this.layer = parent;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
55 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
56 * Setter for XML document helper.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
57 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
58 * @param util The helper class for storing map information.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
59 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
60 public void setUtil(MapToXMLUtils util) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
61 this.util = util;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
62 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
63
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
64 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
65 * Reads the Renderer attributes.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
66 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
67 * @return The XML node.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
68 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
69 public Element read()
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
70 throws IOException {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
71 logger.debug("read()");
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
72
44
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
73 for(int i = 0; i < renderer.getBreakCount(); i++){
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
74 Element rendererElement;
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
75 try {
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
76 rendererElement = util.addRenderer(layer);
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
77 rendererElement.setAttribute("break",
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
78 String.valueOf(renderer.getBreak(i)));
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
79 rendererElement.setAttribute(
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
80 "field_count",
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
81 String.valueOf(renderer.getFieldCount()));
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
82 for(int j = 0; j < renderer.getFieldCount(); j++) {
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
83 rendererElement.setAttribute(
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
84 "expression_field_" + j,
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
85 renderer.getField(j));
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
86
44
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
87 }
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
88 rendererElement.setAttribute(
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
89 "min_value",
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
90 String.valueOf(renderer.getMinimumBreak()));
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
91 rendererElement.setAttribute("expression_operator", "<=");
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
92 ISymbol sym = renderer.getSymbol(i);
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
93 ISymbolReader symReader;
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
94 symReader = new SimpleFillSymbolReader(renderer.getSymbol(i));
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
95 symReader.setUtil(util);
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
96 symReader.setParent(rendererElement);
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
97 symReader.read();
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
98 }
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
99 catch(Exception e) {
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
100 e.printStackTrace();
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
101 return null;
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
102 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
103 }
44
9b5fb5e5914d Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
104 return layer;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 // 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)