Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/SimpleRendererReader.java @ 31:40c0b4e5f91a
Added utility class to store map attributes.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 11 Apr 2011 16:04:03 +0200 |
parents | 3e24fffdf2bb |
children | c51376f8e24c |
comparison
equal
deleted
inserted
replaced
30:c34c450edb06 | 31:40c0b4e5f91a |
---|---|
7 import com.esri.arcgis.carto.IFeatureRenderer; | 7 import com.esri.arcgis.carto.IFeatureRenderer; |
8 import com.esri.arcgis.display.ISymbol; | 8 import com.esri.arcgis.display.ISymbol; |
9 import com.esri.arcgis.carto.SimpleRenderer; | 9 import com.esri.arcgis.carto.SimpleRenderer; |
10 import com.esri.arcgis.display.SimpleMarkerSymbol; | 10 import com.esri.arcgis.display.SimpleMarkerSymbol; |
11 | 11 |
12 import org.w3c.dom.Element; | |
13 | |
12 /** | 14 /** |
13 * Reads simple renderer information. | 15 * Reads simple renderer information. |
14 * | 16 * |
15 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 17 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
16 */ | 18 */ |
17 public class SimpleRendererReader implements IRendererReader{ | 19 public class SimpleRendererReader |
20 implements IRendererReader { | |
18 | 21 |
19 //Member | 22 /** |
23 * The logger. | |
24 */ | |
25 private static final Logger logger = | |
26 Logger.getLogger(FeatureLayerReader.class); | |
27 | |
28 /** | |
29 * Private member. | |
30 */ | |
20 private ISymbol symbol; | 31 private ISymbol symbol; |
21 private IFeatureRenderer renderer; | 32 private SimpleRenderer renderer; |
22 private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); | 33 private Element layer; |
34 private MapToXMLUtils util; | |
23 | 35 |
24 //Constructor | 36 |
25 public SimpleRendererReader(IFeatureRenderer renderer){ | 37 public SimpleRendererReader(IFeatureRenderer renderer) |
26 this.renderer = renderer; | 38 throws Exception { |
39 logger.debug("constructor()"); | |
40 if(renderer instanceof SimpleRenderer) { | |
41 this.renderer = (SimpleRenderer)renderer; | |
42 } | |
43 else{ | |
44 throw new Exception ("Not an instance of SimpleRenderer!"); | |
45 } | |
27 } | 46 } |
28 | 47 |
29 | 48 /** |
30 //Methods | 49 * Setter for the parent XML element. |
31 public boolean read() throws IOException{ | 50 * |
32 logger.debug("read()"); | 51 * @param parent The XML parent node. |
33 if(renderer instanceof SimpleRenderer){ | 52 */ |
34 SimpleRenderer sr = (SimpleRenderer)renderer; | 53 public void setParent(Element parent) { |
35 System.out.println("--------------------"); | 54 this.layer = parent; |
36 System.out.println("Renderer inforamtion:"); | |
37 System.out.println("Label\t\t = " + sr.getLabel()); | |
38 System.out.println("Description\t\t = " + sr.getDescription()); | |
39 System.out.println(""); | |
40 symbol = sr.getSymbol(); | |
41 try{ | |
42 ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); | |
43 isr.read(); | |
44 return true; | |
45 } | |
46 catch(Exception e){ | |
47 e.printStackTrace(); | |
48 } | |
49 } | |
50 return false; | |
51 } | 55 } |
52 | 56 |
53 public void getRenderer() throws IOException{ | 57 /** |
54 logger.debug("getRenderer() -> not implemented jet."); | 58 * Setter for the XML document helper. |
59 * | |
60 * @param util The helper class for storing map information. | |
61 */ | |
62 public void setUtil(MapToXMLUtils util) { | |
63 this.util = util; | |
64 } | |
65 | |
66 /** | |
67 * Reads the renderer attributes. | |
68 * | |
69 * @return The XML node. | |
70 */ | |
71 public Element read() | |
72 throws IOException { | |
73 logger.debug("read()"); | |
74 Element rendererElement; | |
75 try { | |
76 rendererElement = util.addRenderer(layer); | |
77 } | |
78 catch(Exception e) { | |
79 e.printStackTrace(); | |
80 return null; | |
81 } | |
82 | |
83 rendererElement.setAttribute("label", renderer.getLabel()); | |
84 rendererElement.setAttribute("description", renderer.getDescription()); | |
85 symbol = renderer.getSymbol(); | |
86 try{ | |
87 ISymbolReader isr= new SimpleMarkerSymbolReader(symbol); | |
88 isr.setParent(rendererElement); | |
89 isr.setUtil(util); | |
90 isr.read(); | |
91 return rendererElement; | |
92 } | |
93 catch(Exception e){ | |
94 e.printStackTrace(); | |
95 } | |
96 return rendererElement; | |
55 } | 97 } |
56 } | 98 } |
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 99 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |