comparison src/java/de/intevation/mxd/reader/UniqueValueRendererReader.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
6 6
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.UniqueValueRenderer; 9 import com.esri.arcgis.carto.UniqueValueRenderer;
10 10
11 import org.w3c.dom.Element;
12
11 /** 13 /**
12 * Reads unique vaule renderer information. 14 * Reads unique vaule renderer information.
13 * 15 *
14 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
15 */ 17 */
16 public class UniqueValueRendererReader implements IRendererReader{ 18 public class UniqueValueRendererReader
19 implements IRendererReader {
17 20
18 //Member 21 /**
19 private ISymbol symbol; 22 * The logger.
20 private IFeatureRenderer renderer; 23 */
21 private static final Logger logger = Logger.getLogger(FeatureLayerReader.class); 24 private static final Logger logger =
25 Logger.getLogger(FeatureLayerReader.class);
22 26
23 //Constructor 27 /**
24 public UniqueValueRendererReader(IFeatureRenderer renderer){ 28 * Private Member.
25 this.renderer = renderer; 29 */
30 private UniqueValueRenderer renderer;
31 private Element layer;
32 private MapToXMLUtils util;
33
34
35 public UniqueValueRendererReader(IFeatureRenderer renderer)
36 throws Exception {
37 logger.debug("constructor()");
38 if (renderer instanceof UniqueValueRenderer) {
39 this.renderer = (UniqueValueRenderer)renderer;
40 }
41 else {
42 throw new Exception ("Not an instance of UniqueValueRenderer.");
43 }
26 } 44 }
27 45
28 46 /**
29 //Methods 47 * Setter for the parent XML element.
30 public boolean read() throws IOException{ 48 *
31 logger.debug("read()"); 49 * @param parent The XML parent node.
32 if(renderer instanceof UniqueValueRenderer){ 50 */
33 UniqueValueRenderer sr = (UniqueValueRenderer)renderer; 51 public void setParent(Element parent) {
34 System.out.println("--------------------"); 52 this.layer = parent;
35 System.out.println("Renderer inforamtion:");
36 System.out.println("Value count\t\t = " + sr.getValueCount());
37 for(int i = 0; i < sr.getValueCount(); i++){
38 String val = sr.getValue(i);
39 System.out.println("Value\t\t = " + val);
40 System.out.println("Label\t\t = " + sr.getLabel(val));
41 System.out.println("Description\t\t = " + sr.getDescription(val));
42 }
43 System.out.println("");
44 symbol = sr.getDefaultSymbol();
45 try{
46 ISymbolReader isr= new SimpleMarkerSymbolReader(symbol);
47 isr.read();
48 return true;
49 }
50 catch(Exception e){
51 e.printStackTrace();
52 }
53 }
54 return false;
55 } 53 }
56 54
57 public void getRenderer() throws IOException{ 55 /**
58 logger.debug("getRenderer() -> not implemented jet."); 56 * Setter for XML document helper.
57 *
58 * @param util The helper class for storing map information.
59 */
60 public void setUtil(MapToXMLUtils util) {
61 this.util = util;
62 }
63
64 /**
65 * Reads the renderer attributes.
66 *
67 * @return The parent XML node.
68 */
69 public Element read()
70 throws IOException {
71 logger.debug("read()");
72 for(int i = 0; i < renderer.getClassCount() - 1; i++) {
73 Element rendererElement;
74 try {
75 rendererElement = util.addRenderer(layer);
76 }
77 catch(Exception e) {
78 e.printStackTrace();
79 return null;
80 }
81 String value = renderer.getValue(i);
82 rendererElement.setAttribute("name", renderer.esri_getClass(i));
83 rendererElement.setAttribute("description",
84 renderer.getDescription(value));
85 rendererElement.setAttribute("value", value);
86 rendererElement.setAttribute("label", renderer.getLabel(value));
87
88 ISymbol symbol = renderer.getSymbol(value);
89 ISymbolReader symbolReader;
90 try {
91 symbolReader = new SimpleMarkerSymbolReader(symbol);
92 }
93 catch(Exception e) {
94 e.printStackTrace();
95 return null;
96 }
97 symbolReader.setUtil(util);
98 symbolReader.setParent(rendererElement);
99 symbolReader.read ();
100
101 }
102 return layer;
59 } 103 }
60 } 104 }
61 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 105 // 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)