changeset 72:2cbe423b1fda

Added wrapper for fill symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 26 May 2011 16:49:03 +0200
parents 260748e3d08f
children acbe36fb45e0
files ChangeLog src/java/de/intevation/mxd/reader/FillSymbolReader.java src/java/de/intevation/mxd/reader/LineSymbolReader.java src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java src/java/de/intevation/mxd/reader/SimpleRendererReader.java
diffstat 5 files changed, 179 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 26 16:01:29 2011 +0200
+++ b/ChangeLog	Thu May 26 16:49:03 2011 +0200
@@ -1,3 +1,17 @@
+2011-05-26  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	Added wrapper for fill symbol reader.
+
+	* src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java,
+	  src/java/de/intevation/mxd/reader/SimpleRendererReader.java:
+	  Use the wrapper to read the fill symbols.
+
+	* src/java/de/intevation/mxd/reader/FillSymbolReader.java:
+	  New.
+
+	* src/java/de/intevation/mxd/reader/LineSymbolReader.java:
+	  Added methods for the ILineSymbol interface.
+
 2011-05-26  Raimund Renkert  <raimund.renkert@intevation.de>
 
 	Added wrapper for line symbol reader.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/intevation/mxd/reader/FillSymbolReader.java	Thu May 26 16:49:03 2011 +0200
@@ -0,0 +1,120 @@
+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.IFillSymbol;
+import com.esri.arcgis.display.MultiLayerFillSymbol;
+import com.esri.arcgis.display.SimpleFillSymbol;
+
+/**
+ * Wrapper for fill symbol reader.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class FillSymbolReader
+extends AbstractSymbolReader {
+
+    /**
+     * The logger.
+     */
+    private static final Logger logger =
+        Logger.getLogger(FillSymbolReader.class);
+
+    private ISymbol symbol;
+    private IFillSymbol fillSymbol;
+
+    public FillSymbolReader() throws Exception{
+        logger.debug("contructor()");
+        this.symbol = null;
+        this.fillSymbol = null;
+    }
+
+    public FillSymbolReader(ISymbol symbol) throws Exception{
+        logger.debug("contructor(ISymbol)");
+        this.symbol = symbol;
+        this.fillSymbol = null;
+    }
+
+    public FillSymbolReader(IFillSymbol symbol) throws Exception{
+        logger.debug("contructor(ILineSymbol)");
+        this.fillSymbol = symbol;
+        this.symbol= null;
+    }
+
+    public Element read() throws Exception {
+        ISymbolReader sreader = null;
+        if(symbol != null) {
+            if(symbol instanceof SimpleFillSymbol) {
+                sreader = new SimpleFillSymbolReader(symbol);
+            }
+            else if(symbol instanceof MultiLayerFillSymbol) {
+                sreader = new MultiLayerFillSymbolReader(symbol);
+            }
+            else {
+                logger.debug("The reader for type " + symbol.getClass().toString() +
+                             " is not implemented!");
+                return parent;
+            }
+        }
+        else if(fillSymbol != null) {
+            if(fillSymbol instanceof SimpleFillSymbol) {
+                sreader = new SimpleFillSymbolReader(fillSymbol);
+            }
+            else if(fillSymbol instanceof MultiLayerFillSymbol) {
+                sreader = new MultiLayerFillSymbolReader(fillSymbol);
+            }
+            else {
+                logger.debug("The reader for type " +
+                             fillSymbol.getClass().toString() +
+                             " is not implemented!");
+                return parent;
+            }
+        }
+        else {
+            return parent;
+        }
+        if (sreader != null) {
+            sreader.setParent(parent);
+            sreader.setUtil(util);
+            sreader.read();
+        }
+        return parent;
+    }
+
+    public void setSymbol(ISymbol sym) {
+        this.symbol = sym;
+        this.fillSymbol = null;
+    }
+
+    public void setSymbol(IFillSymbol sym) {
+        this.symbol = null;
+        this.fillSymbol = sym;
+    }
+
+    public boolean canRead(ISymbol sym) {
+        if(sym instanceof SimpleFillSymbol ||
+           sym instanceof MultiLayerFillSymbol) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+    public boolean canRead(IFillSymbol sym) {
+        if(sym instanceof SimpleFillSymbol ||
+           sym instanceof MultiLayerFillSymbol) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/reader/LineSymbolReader.java	Thu May 26 16:01:29 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/LineSymbolReader.java	Thu May 26 16:49:03 2011 +0200
@@ -116,6 +116,12 @@
 
     public void setSymbol(ISymbol sym) {
         this.symbol = sym;
+        this.lineSymbol = null;
+    }
+
+    public void setSymbol(ILineSymbol sym) {
+        this.lineSymbol = sym;
+        this.symbol = null;
     }
 
     public boolean canRead(ISymbol sym) {
@@ -131,5 +137,19 @@
             return false;
         }
     }
+
+    public boolean canRead(ILineSymbol sym) {
+        if(sym instanceof SimpleLineSymbol ||
+           sym instanceof MarkerLineSymbol ||
+           sym instanceof PictureLineSymbol ||
+           sym instanceof MultiLayerLineSymbol ||
+           sym instanceof CartographicLineSymbol ||
+           sym instanceof HashLineSymbol) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java	Thu May 26 16:01:29 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java	Thu May 26 16:49:03 2011 +0200
@@ -7,13 +7,8 @@
 
 import com.esri.arcgis.display.ISymbol;
 import com.esri.arcgis.display.ILineSymbol;
+import com.esri.arcgis.display.IFillSymbol;
 import com.esri.arcgis.display.SimpleFillSymbol;
-import com.esri.arcgis.display.MultiLayerLineSymbol;
-import com.esri.arcgis.display.SimpleLineSymbol;
-import com.esri.arcgis.display.MarkerLineSymbol;
-import com.esri.arcgis.display.PictureLineSymbol;
-import com.esri.arcgis.display.CartographicLineSymbol;
-import com.esri.arcgis.display.HashLineSymbol;
 import com.esri.arcgis.display.MultiLayerFillSymbol;
 import com.esri.arcgis.display.esriSimpleFillStyle;
 import com.esri.arcgis.display.IRgbColor;
@@ -46,7 +41,17 @@
 
 
     public SimpleFillSymbolReader(ISymbol symbol) throws Exception{
-        logger.debug("contructor()");
+        logger.debug("contructor(ISymbol)");
+        if(symbol instanceof SimpleFillSymbol) {
+            this.symbol = (SimpleFillSymbol)symbol;
+        }
+        else {
+            throw new Exception("Not a SimpleFillSymbol!");
+        }
+    }
+
+    public SimpleFillSymbolReader(IFillSymbol symbol) throws Exception{
+        logger.debug("contructor(IFillSymbol)");
         if(symbol instanceof SimpleFillSymbol) {
             this.symbol = (SimpleFillSymbol)symbol;
         }
@@ -136,41 +141,12 @@
 
         try {
             ILineSymbol ls = symbol.getOutline();
-            if(ls instanceof MultiLayerLineSymbol) {
-                ISymbolReader sreader = new MultiLayerLineSymbolReader(ls);
-                sreader.setParent(symbolElement);
-                sreader.setUtil(util);
-                sreader.read();
-            }
-            else if(ls instanceof SimpleLineSymbol) {
-                ISymbolReader sreader = new SimpleLineSymbolReader(ls);
-                sreader.setParent(symbolElement);
-                sreader.setUtil(util);
-                sreader.read();
-            }
-            else if(ls instanceof MarkerLineSymbol) {
-                ISymbolReader sreader = new MarkerLineSymbolReader(ls);
-                sreader.setParent(symbolElement);
-                sreader.setUtil(util);
-                sreader.read();
-            }
-            else if(ls instanceof PictureLineSymbol) {
-                ISymbolReader sreader = new PictureLineSymbolReader(ls);
-                sreader.setParent(symbolElement);
-                sreader.setUtil(util);
-                sreader.read();
-            }
-            else if(ls instanceof CartographicLineSymbol) {
-                ISymbolReader sreader = new CartoLineSymbolReader(ls);
-                sreader.setParent(symbolElement);
-                sreader.setUtil(util);
-                sreader.read();
-            }
-            else if(ls instanceof HashLineSymbol) {
-                ISymbolReader sreader = new HashLineSymbolReader(ls);
-                sreader.setParent(symbolElement);
-                sreader.setUtil(util);
-                sreader.read();
+            LineSymbolReader lsr = new LineSymbolReader();
+            if(lsr.canRead(ls)) {
+                lsr.setSymbol(ls);
+                lsr.setUtil(util);
+                lsr.setParent(symbolElement);
+                lsr.read();
             }
             else {
                 logger.debug("The type of " + ls.getClass().toString() +
--- a/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Thu May 26 16:01:29 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Thu May 26 16:49:03 2011 +0200
@@ -87,6 +87,7 @@
 
             MarkerSymbolReader markerReader = new MarkerSymbolReader();
             LineSymbolReader lineReader = new LineSymbolReader();
+            FillSymbolReader fillReader = new FillSymbolReader();
             if(markerReader.canRead(symbol)) {
                 markerReader.setSymbol(symbol);
                 markerReader.setUtil(util);
@@ -99,6 +100,12 @@
                 lineReader.setParent(rendererElement);
                 lineReader.read();
             }
+            else if(fillReader.canRead(symbol)) {
+                fillReader.setSymbol(symbol);
+                fillReader.setUtil(util);
+                fillReader.setParent(rendererElement);
+                fillReader.read();
+            }
             else {
                 logger.debug("No known Symbol type: " + symbol.getClass().toString());
             }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)