diff 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
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Fri Apr 08 17:58:37 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Mon Apr 11 16:04:03 2011 +0200
@@ -9,49 +9,91 @@
 import com.esri.arcgis.carto.SimpleRenderer;
 import com.esri.arcgis.display.SimpleMarkerSymbol;
 
+import org.w3c.dom.Element;
+
 /**
  * Reads simple renderer information.
  *
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
-public class SimpleRendererReader implements IRendererReader{
+public class SimpleRendererReader
+implements IRendererReader {
 
-    //Member
+    /**
+     * The logger.
+     */
+    private static final Logger logger =
+        Logger.getLogger(FeatureLayerReader.class);
+
+    /**
+     * Private member.
+     */
     private ISymbol symbol;
-    private IFeatureRenderer renderer;
-    private static final Logger logger = Logger.getLogger(FeatureLayerReader.class);
-
-    //Constructor
-    public SimpleRendererReader(IFeatureRenderer renderer){
-        this.renderer = renderer;
-    }
+    private SimpleRenderer renderer;
+    private Element layer;
+    private MapToXMLUtils util;
 
 
-    //Methods
-    public boolean read() throws IOException{
-        logger.debug("read()");
-        if(renderer instanceof SimpleRenderer){
-            SimpleRenderer sr = (SimpleRenderer)renderer;
-            System.out.println("--------------------");
-            System.out.println("Renderer inforamtion:");
-            System.out.println("Label\t\t = " + sr.getLabel());
-            System.out.println("Description\t\t = " + sr.getDescription());
-            System.out.println("");
-            symbol = sr.getSymbol();
-            try{
-                ISymbolReader isr= new SimpleMarkerSymbolReader(symbol);
-                isr.read();
-                return true;
-            }
-            catch(Exception e){
-                e.printStackTrace();
-            }
+    public SimpleRendererReader(IFeatureRenderer renderer)
+    throws Exception {
+        logger.debug("constructor()");
+        if(renderer instanceof SimpleRenderer) {
+            this.renderer = (SimpleRenderer)renderer;
         }
-        return false;
+        else{
+            throw new Exception ("Not an instance of SimpleRenderer!");
+        }
     }
 
-    public void getRenderer() throws IOException{
-        logger.debug("getRenderer() -> not implemented jet.");
+    /**
+     * Setter for the parent XML element.
+     *
+     * @param parent The XML parent node.
+     */
+    public void setParent(Element parent) {
+        this.layer = parent;
+    }
+
+    /**
+     * Setter for the 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("label", renderer.getLabel());
+        rendererElement.setAttribute("description", renderer.getDescription());
+        symbol = renderer.getSymbol();
+        try{
+            ISymbolReader isr= new SimpleMarkerSymbolReader(symbol);
+            isr.setParent(rendererElement);
+            isr.setUtil(util);
+            isr.read();
+            return rendererElement;
+        }
+        catch(Exception e){
+            e.printStackTrace();
+        }
+        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)