changeset 70:6d181c02efce

Added wrapper for marker symbol reader and extracted methods from symbol readers.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 26 May 2011 14:28:52 +0200
parents b41fcf268827
children 260748e3d08f 04b6162c95df
files ChangeLog src/java/de/intevation/mxd/reader/AbstractSymbolReader.java src/java/de/intevation/mxd/reader/ISymbolReader.java src/java/de/intevation/mxd/reader/MarkerSymbolReader.java src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java
diffstat 7 files changed, 136 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 26 12:44:59 2011 +0200
+++ b/ChangeLog	Thu May 26 14:28:52 2011 +0200
@@ -1,4 +1,19 @@
-2011-05-26  raimund renkert  <raimund.renkert@intevation.de>
+2011-05-26  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	Added wrapper for marker symbol reader and extracted methods from symbol
+	readers.
+
+	* src/java/de/intevation/mxd/reader/AbstractSymbolReader.java,
+	  src/java/de/intevation/mxd/reader/MarkerSymbolReader.java:
+	  New.
+
+	* src/java/de/intevation/mxd/reader/ISymbolReader.java,
+	  src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java,
+	  src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java,
+	  src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java:
+	  Removed obsolete code fragments.
+
+2011-05-26  Raimund Renkert  <raimund.renkert@intevation.de>
 
 	* src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java,
 	  src/java/de/intevation/mxd/reader/HashLineSymbolReader.java,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/intevation/mxd/reader/AbstractSymbolReader.java	Thu May 26 14:28:52 2011 +0200
@@ -0,0 +1,47 @@
+package de.intevation.mxd.reader;
+
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Element;
+import de.intevation.mxd.utils.MapToXMLUtils;
+
+/**
+ * Reads multi layer marker symbol information.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public abstract class AbstractSymbolReader implements ISymbolReader{
+
+    /**
+     * The logger.
+     */
+    private static final Logger logger =
+        Logger.getLogger(AbstractReaderTool.class);
+
+    /**
+     * Private member.
+     */
+    protected Element parent;
+    protected MapToXMLUtils util;
+
+
+    /**
+     * Setter for the parent XML element.
+     *
+     * @param parent The XML parent node.
+     */
+    public void setParent(Element p) {
+        this.parent = p;
+    }
+
+    /**
+     * Setter for XML document helper.
+     *
+     * @param util The helper class for storing map information.
+     */
+    public void setUtil(MapToXMLUtils u) {
+        this.util = u;
+    }
+}
--- a/src/java/de/intevation/mxd/reader/ISymbolReader.java	Thu May 26 12:44:59 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/ISymbolReader.java	Thu May 26 14:28:52 2011 +0200
@@ -1,6 +1,6 @@
 package de.intevation.mxd.reader;
 
-import java.io.IOException;
+import java.lang.Exception;
 
 import org.w3c.dom.Element;
 
@@ -13,7 +13,7 @@
  */
 public interface ISymbolReader{
 
-    Element read() throws IOException;
+    Element read() throws Exception;
 
     void setParent(Element parent);
     void setUtil(MapToXMLUtils util);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java	Thu May 26 14:28:52 2011 +0200
@@ -0,0 +1,62 @@
+package de.intevation.mxd.reader;
+
+import java.lang.Exception;
+
+import org.w3c.dom.Element;
+
+import org.apache.log4j.Logger;
+
+import com.esri.arcgis.display.ISymbol;
+import com.esri.arcgis.display.ArrowMarkerSymbol;
+import com.esri.arcgis.display.CharacterMarkerSymbol;
+import com.esri.arcgis.display.PictureMarkerSymbol;
+import com.esri.arcgis.display.MultiLayerMarkerSymbol;
+
+/**
+ * Wrapper for marker symbol reader.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class MarkerSymbolReader
+extends AbstractSymbolReader {
+
+    /**
+     * The logger.
+     */
+    private static final Logger logger =
+        Logger.getLogger(SimpleFillSymbolReader.class);
+
+    private ISymbol symbol;
+
+    public MarkerSymbolReader(ISymbol symbol) throws Exception{
+        logger.debug("contructor()");
+        this.symbol = symbol;
+    }
+
+    public Element read() throws Exception {
+        ISymbolReader sreader = null;
+        if(symbol instanceof ArrowMarkerSymbol) {
+            sreader = new ArrowMarkerSymbolReader(symbol);
+        }
+        else if(symbol instanceof CharacterMarkerSymbol) {
+            sreader = new CharacterMarkerSymbolReader(symbol);
+        }
+        else if(symbol instanceof PictureMarkerSymbol) {
+            sreader = new PictureMarkerSymbolReader(symbol);
+        }
+        else if(symbol instanceof MultiLayerMarkerSymbol) {
+            sreader = new MultiLayerMarkerSymbolReader(symbol);
+        }
+        else {
+            logger.debug("The reader for type " + symbol.getClass().toString() +
+                         " is not implemented!");
+            return parent;
+        }
+        if (sreader != null) {
+            sreader.setParent(parent);
+            sreader.setUtil(util);
+            return sreader.read();
+        }
+        return parent;
+    }
+}
--- a/src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java	Thu May 26 12:44:59 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java	Thu May 26 14:28:52 2011 +0200
@@ -2,19 +2,11 @@
 
 import java.io.IOException;
 
-import java.awt.Color;
-
 import org.apache.log4j.Logger;
 
 import com.esri.arcgis.display.ISymbol;
 import com.esri.arcgis.display.IMarkerSymbol;
 import com.esri.arcgis.display.MultiLayerMarkerSymbol;
-import com.esri.arcgis.display.ArrowMarkerSymbol;
-import com.esri.arcgis.display.CharacterMarkerSymbol;
-import com.esri.arcgis.display.PictureMarkerSymbol;
-
-import com.esri.arcgis.display.IColor;
-import com.esri.arcgis.display.RgbColor;
 
 import org.w3c.dom.Element;
 import de.intevation.mxd.utils.MapToXMLUtils;
@@ -92,31 +84,10 @@
         for(int i = 0; i < symbol.getLayerCount(); i++) {
             try {
                 ISymbol sym = (ISymbol)symbol.getLayer(i);
-
-                if(sym instanceof ArrowMarkerSymbol) {
-                    ISymbolReader sreader = new ArrowMarkerSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else if(sym instanceof CharacterMarkerSymbol) {
-                    ISymbolReader sreader = new CharacterMarkerSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else if(sym instanceof PictureMarkerSymbol) {
-                    ISymbolReader sreader = new PictureMarkerSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else {
-                    logger.debug("The type of " + sym.getClass().toString() +
-                                 " is not implemented!");
-                    System.out.println(
-                            "No known instance: " + sym.getClass().toString());
-                }
+                ISymbolReader sreader = new MarkerSymbolReader(sym);
+                sreader.setParent(renderer);
+                sreader.setUtil(util);
+                sreader.read();
             }
             catch(Exception e) {
                 e.printStackTrace();
--- a/src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java	Thu May 26 12:44:59 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleMarkerSymbolReader.java	Thu May 26 14:28:52 2011 +0200
@@ -20,7 +20,9 @@
  *
  * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
  */
-public class SimpleMarkerSymbolReader implements ISymbolReader{
+public class SimpleMarkerSymbolReader
+extends AbstractReaderTool
+implements ISymbolReader {
 
     /**
      * The logger.
@@ -31,9 +33,7 @@
     /**
      * Private member.
      */
-    private Element renderer;
     private SimpleMarkerSymbol symbol;
-    private MapToXMLUtils util;
 
 
     public SimpleMarkerSymbolReader(ISymbol symbol)
@@ -48,24 +48,6 @@
     }
 
     /**
-     * Setter for the parent XML element.
-     *
-     * @param parent The XML parent node.
-     */
-    public void setParent(Element parent) {
-        this.renderer = parent;
-    }
-
-    /**
-     * Setter for XML document helper.
-     *
-     * @param util The helper class for storing map information.
-     */
-    public void setUtil(MapToXMLUtils util) {
-        this.util = util;
-    }
-
-    /**
      * Reads the symbol attributes.
      *
      * @return The XML node.
@@ -75,7 +57,7 @@
         logger.debug("read()");
         Element symbolElement;
         try {
-            symbolElement = util.addSymbol(renderer);
+            symbolElement = util.addSymbol(parent);
         }
         catch(Exception e) {
             e.printStackTrace();
--- a/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java	Thu May 26 12:44:59 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java	Thu May 26 14:28:52 2011 +0200
@@ -92,7 +92,7 @@
                 }
                 rendererElement.setAttribute("expression_operator", "=");
                 ISymbol symbol = renderer.getSymbol(value);
-                ISymbolReader symbolReader = new SimpleMarkerSymbolReader(symbol);
+                ISymbolReader symbolReader = new MarkerSymbolReader(symbol);
                 symbolReader.setUtil(util);
                 symbolReader.setParent(rendererElement);
                 symbolReader.read ();
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)