annotate src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java @ 61:e00deee347a5

Added first line symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 23 May 2011 13:16:42 +0200
parents
children 5c5ef5768893
rev   line source
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import java.awt.Color;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import org.apache.log4j.Logger;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.ISymbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.MultiLayerLineSymbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.display.SimpleLineSymbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.display.esriSimpleMarkerStyle;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import com.esri.arcgis.display.IRgbColor;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import com.esri.arcgis.display.RgbColor;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Element;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 import de.intevation.mxd.utils.MapToXMLUtils;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 * Reads multi layer line symbol information.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 public class MultiLayerLineSymbolReader implements ISymbolReader{
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 * The logger.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 private static final Logger logger =
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 Logger.getLogger(MultiLayerLineSymbolReader.class);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 * Private member.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 private Element renderer;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 private MultiLayerLineSymbol symbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 private MapToXMLUtils util;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 public MultiLayerLineSymbolReader(ISymbol symbol)
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 throws Exception {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 logger.debug("contructor()");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 if(symbol instanceof MultiLayerLineSymbol) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 this.symbol = (MultiLayerLineSymbol)symbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 else {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 throw new Exception("Not a MultiLayerLineSymbol!");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 * Setter for the parent XML element.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 * @param parent The XML parent node.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 public void setParent(Element parent) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 this.renderer = parent;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 * Setter for XML document helper.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 * @param util The helper class for storing map information.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 public void setUtil(MapToXMLUtils util) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 this.util = util;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 * Reads the symbol attributes.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 * @return The XML node.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 public Element read()
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 throws IOException {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 logger.debug("read()");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 for(int i = 0; i < symbol.getLayerCount(); i++) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 try {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 ISymbol sym = (ISymbol)symbol.getLayer(i);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 if(sym instanceof SimpleLineSymbol) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 ISymbolReader sreader = new SimpleLineSymbolReader(sym);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 sreader.setParent(renderer);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 sreader.setUtil(util);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 sreader.read();
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 else {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 logger.debug("The type of " + sym.getClass().toString() +
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 " is not implemented!");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 System.out.println(
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 "No known instance: " + sym.getClass().toString());
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 catch(Exception e) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 e.printStackTrace();
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 return null;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 return renderer;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 // 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)