changeset 58:4e0464c620f0

Introduced the picture symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 20 May 2011 15:34:35 +0200
parents 8da6555f1c12
children ef1ee8e752b2
files ChangeLog src/java/de/intevation/mxd/reader/FeatureLayerReader.java src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java
diffstat 4 files changed, 131 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue May 17 13:00:10 2011 +0200
+++ b/ChangeLog	Fri May 20 15:34:35 2011 +0200
@@ -1,3 +1,14 @@
+2011-05-20  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/reader/FeatureLayerReader.java:
+	  Read the workspace path.
+
+	* src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java:
+	  Added reader for picture marker symbols.
+
+	* src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java:
+	  New. Read picture symbols from mxd-file.
+
 2011-05-17  Raimund Renkert  <raimund.renkert@intevation.de>
 
 	* src/java/de/intevation/mxd/reader/MapReader.java,
--- a/src/java/de/intevation/mxd/reader/FeatureLayerReader.java	Tue May 17 13:00:10 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/FeatureLayerReader.java	Fri May 20 15:34:35 2011 +0200
@@ -7,6 +7,8 @@
 import com.esri.arcgis.carto.ILayer;
 import com.esri.arcgis.carto.FeatureLayer;
 import com.esri.arcgis.geodatabase.FeatureClassName;
+import com.esri.arcgis.geodatabase.IDataset;
+import com.esri.arcgis.geodatabase.IFeatureClass;
 import com.esri.arcgis.system.IName;
 
 import org.w3c.dom.Element;
@@ -97,6 +99,9 @@
             layerElement.setAttribute("data_source", name.getName());
         }
 
+        layerElement.setAttribute(
+            "workspace",
+            layer.getWorkspace().getPathName());
         return layerElement;
     }
 }
--- a/src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java	Tue May 17 13:00:10 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MultiLayerMarkerSymbolReader.java	Fri May 20 15:34:35 2011 +0200
@@ -11,6 +11,8 @@
 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;
 
@@ -85,13 +87,21 @@
                     sreader.setUtil(util);
                     sreader.read();
                 }
-                if(sym instanceof CharacterMarkerSymbol) {
+                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());
                 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java	Fri May 20 15:34:35 2011 +0200
@@ -0,0 +1,104 @@
+package de.intevation.mxd.reader;
+
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+
+import com.esri.arcgis.display.ISymbol;
+import com.esri.arcgis.display.PictureMarkerSymbol;
+import com.esri.arcgis.display.IColor;
+import com.esri.arcgis.carto.PictureElement;
+
+import org.w3c.dom.Element;
+import de.intevation.mxd.utils.MapToXMLUtils;
+
+/**
+ * Reads picture marker symbol information.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class PictureMarkerSymbolReader implements ISymbolReader{
+
+    /**
+     * The logger.
+     */
+    private static final Logger logger =
+        Logger.getLogger(PictureMarkerSymbolReader.class);
+
+    /**
+     * Private member.
+     */
+    private Element renderer;
+    private PictureMarkerSymbol symbol;
+    private MapToXMLUtils util;
+
+
+    public PictureMarkerSymbolReader(ISymbol symbol)
+    throws Exception {
+        logger.debug("contructor()");
+        if(symbol instanceof PictureMarkerSymbol) {
+            this.symbol = (PictureMarkerSymbol)symbol;
+        }
+        else {
+            throw new Exception("Not a PictureMarkerSymbol!");
+        }
+    }
+
+    /**
+     * 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.
+     */
+    public Element read()
+    throws IOException {
+        logger.debug("read()");
+        Element symbolElement;
+        try {
+            symbolElement = util.addSymbol(renderer);
+        }
+        catch(Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+
+        symbolElement.setAttribute(
+            "angle",
+            String.valueOf(symbol.getAngle()));
+        symbolElement.setAttribute(
+            "size",
+            String.valueOf(symbol.getSize()));
+        symbolElement.setAttribute(
+            "x_offset",
+            String.valueOf(symbol.getXOffset()));
+        symbolElement.setAttribute(
+            "y_offset",
+            String.valueOf(symbol.getYOffset()));
+        symbolElement.setAttribute(
+            "name",
+            symbol.getNameString());
+        PictureElement pElem = new PictureElement();
+        pElem.importPicture(symbol.getPicture());
+        System.out.println("Path:" + pElem.getPath());
+        symbolElement.setAttribute("style", "picture");
+        return symbolElement;
+    }
+}
+// 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)