diff 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
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java	Fri Apr 08 17:58:37 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java	Mon Apr 11 16:04:03 2011 +0200
@@ -7,21 +7,35 @@
 import com.esri.arcgis.carto.IFeatureRenderer;
 import com.esri.arcgis.carto.ClassBreaksRenderer;
 
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.Attr;
+
 /**
  * Reads the ClassBreaksRender Object Attributes.
  *
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
-public class ClassBreakRendererReader implements IRendererReader{
+public class ClassBreakRendererReader
+implements IRendererReader {
 
-    //Member
+    /**
+     * The logger.
+     */
     private static final Logger logger =
         Logger.getLogger(ClassBreakRendererReader.class);
 
+    /**
+     * Private member.
+     */
     private ClassBreaksRenderer renderer;
+    private Element layer;
+    private MapToXMLUtils util;
 
-    //Constructor
-    public ClassBreakRendererReader(IFeatureRenderer renderer) throws Exception{
+
+    public ClassBreakRendererReader(IFeatureRenderer renderer)
+    throws Exception {
         logger.debug("contructor()");
         if(renderer instanceof ClassBreaksRenderer)
             this.renderer = (ClassBreaksRenderer)renderer;
@@ -29,28 +43,57 @@
             throw new Exception("Not a ClassBreaksRenderer!");
     }
 
-
-    //Methods
-    public boolean read() throws IOException{
-        logger.debug("read()");
-        System.out.println("--------------------");
-        System.out.println("Renderer information:");
-        System.out.println("Ramp\t\t = " + renderer.getColorRamp());
-        System.out.println("Class count\t\t = " + renderer.getClassCount());
-
-        for(int i = 0; i < renderer.getClassCount(); i++){
-            System.out.println("Class " + i + "\t\t = " + renderer.esri_getClass(i));
-        }
-        System.out.println("Break count\t\t = " + renderer.getBreakCount());
-        for(int i = 0; i < renderer.getBreakCount(); i++){
-            System.out.println("Break " + i + "\t\t = " + renderer.getBreak(i));
-        }
-        System.out.println("");
-        return true;
+    /**
+     * Setter for the parent XML element.
+     *
+     * @param parent The XML parent node.
+     */
+    public void setParent(Element parent) {
+        this.layer = parent;
     }
 
-    public void getRenderer() throws IOException{
-        logger.debug("getRenderer() -> not implemented jet.");
+    /**
+     * Setter for XML document helper.
+     *
+     * @param util The helper class for storing map information.
+     */
+    public void setUtil(MapToXMLUtils util) {
+        this.util = util;
+    }
+
+    /**
+     * Reads the Renderer attributes.
+     *
+     * @return The XML node.
+     */
+    public Element read()
+    throws IOException {
+        logger.debug("read()");
+        Element rendererElement;
+        try {
+            rendererElement = util.addRenderer(layer);
+        }
+        catch(Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+
+        rendererElement.setAttribute("class_count",
+                String.valueOf(renderer.getClassCount()));
+        for(int i = 0; i < renderer.getClassCount(); i++){
+            rendererElement.setAttribute("class_" + i,
+                renderer.esri_getClass(i));
+        }
+
+        rendererElement.setAttribute("break_count",
+            String.valueOf(renderer.getBreakCount()));
+        for(int i = 0; i < renderer.getBreakCount(); i++){
+            rendererElement.setAttribute("break_" + i,
+                String.valueOf(renderer.getBreak(i)));
+        }
+
+        rendererElement.setAttribute("color_ramp", renderer.getColorRamp());
+        return rendererElement;
     }
 }
 // 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)