Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/ClassBreakRendererReader.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 |
---|---|
5 import org.apache.log4j.Logger; | 5 import org.apache.log4j.Logger; |
6 | 6 |
7 import com.esri.arcgis.carto.IFeatureRenderer; | 7 import com.esri.arcgis.carto.IFeatureRenderer; |
8 import com.esri.arcgis.carto.ClassBreaksRenderer; | 8 import com.esri.arcgis.carto.ClassBreaksRenderer; |
9 | 9 |
10 import org.w3c.dom.Node; | |
11 import org.w3c.dom.Element; | |
12 import org.w3c.dom.Document; | |
13 import org.w3c.dom.Attr; | |
14 | |
10 /** | 15 /** |
11 * Reads the ClassBreaksRender Object Attributes. | 16 * Reads the ClassBreaksRender Object Attributes. |
12 * | 17 * |
13 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
14 */ | 19 */ |
15 public class ClassBreakRendererReader implements IRendererReader{ | 20 public class ClassBreakRendererReader |
21 implements IRendererReader { | |
16 | 22 |
17 //Member | 23 /** |
24 * The logger. | |
25 */ | |
18 private static final Logger logger = | 26 private static final Logger logger = |
19 Logger.getLogger(ClassBreakRendererReader.class); | 27 Logger.getLogger(ClassBreakRendererReader.class); |
20 | 28 |
29 /** | |
30 * Private member. | |
31 */ | |
21 private ClassBreaksRenderer renderer; | 32 private ClassBreaksRenderer renderer; |
33 private Element layer; | |
34 private MapToXMLUtils util; | |
22 | 35 |
23 //Constructor | 36 |
24 public ClassBreakRendererReader(IFeatureRenderer renderer) throws Exception{ | 37 public ClassBreakRendererReader(IFeatureRenderer renderer) |
38 throws Exception { | |
25 logger.debug("contructor()"); | 39 logger.debug("contructor()"); |
26 if(renderer instanceof ClassBreaksRenderer) | 40 if(renderer instanceof ClassBreaksRenderer) |
27 this.renderer = (ClassBreaksRenderer)renderer; | 41 this.renderer = (ClassBreaksRenderer)renderer; |
28 else | 42 else |
29 throw new Exception("Not a ClassBreaksRenderer!"); | 43 throw new Exception("Not a ClassBreaksRenderer!"); |
30 } | 44 } |
31 | 45 |
32 | 46 /** |
33 //Methods | 47 * Setter for the parent XML element. |
34 public boolean read() throws IOException{ | 48 * |
35 logger.debug("read()"); | 49 * @param parent The XML parent node. |
36 System.out.println("--------------------"); | 50 */ |
37 System.out.println("Renderer information:"); | 51 public void setParent(Element parent) { |
38 System.out.println("Ramp\t\t = " + renderer.getColorRamp()); | 52 this.layer = parent; |
39 System.out.println("Class count\t\t = " + renderer.getClassCount()); | |
40 | |
41 for(int i = 0; i < renderer.getClassCount(); i++){ | |
42 System.out.println("Class " + i + "\t\t = " + renderer.esri_getClass(i)); | |
43 } | |
44 System.out.println("Break count\t\t = " + renderer.getBreakCount()); | |
45 for(int i = 0; i < renderer.getBreakCount(); i++){ | |
46 System.out.println("Break " + i + "\t\t = " + renderer.getBreak(i)); | |
47 } | |
48 System.out.println(""); | |
49 return true; | |
50 } | 53 } |
51 | 54 |
52 public void getRenderer() throws IOException{ | 55 /** |
53 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 XML node. | |
68 */ | |
69 public Element read() | |
70 throws IOException { | |
71 logger.debug("read()"); | |
72 Element rendererElement; | |
73 try { | |
74 rendererElement = util.addRenderer(layer); | |
75 } | |
76 catch(Exception e) { | |
77 e.printStackTrace(); | |
78 return null; | |
79 } | |
80 | |
81 rendererElement.setAttribute("class_count", | |
82 String.valueOf(renderer.getClassCount())); | |
83 for(int i = 0; i < renderer.getClassCount(); i++){ | |
84 rendererElement.setAttribute("class_" + i, | |
85 renderer.esri_getClass(i)); | |
86 } | |
87 | |
88 rendererElement.setAttribute("break_count", | |
89 String.valueOf(renderer.getBreakCount())); | |
90 for(int i = 0; i < renderer.getBreakCount(); i++){ | |
91 rendererElement.setAttribute("break_" + i, | |
92 String.valueOf(renderer.getBreak(i))); | |
93 } | |
94 | |
95 rendererElement.setAttribute("color_ramp", renderer.getColorRamp()); | |
96 return rendererElement; | |
54 } | 97 } |
55 } | 98 } |
56 // 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 : |