changeset 78:df17d4c2f9eb

Merged in Raimunds changes
author Stephan Holl <stephan.holl@intevation.de>
date Thu, 26 May 2011 16:13:50 +0200
parents 04b6162c95df (current diff) 260748e3d08f (diff)
children 5becdfe6ebae
files
diffstat 6 files changed, 202 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 26 16:12:38 2011 +0200
+++ b/ChangeLog	Thu May 26 16:13:50 2011 +0200
@@ -1,3 +1,16 @@
+2011-05-26  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	Added wrapper for line symbol reader.
+
+	* src/java/de/intevation/mxd/reader/ISymbolReader.java,
+	  src/java/de/intevation/mxd/reader/MarkerSymbolReader.java,
+	  src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java,
+	  src/java/de/intevation/mxd/reader/SimpleRendererReader.java:
+	  Use the new wrapper to read line symbols.
+
+	* src/java/de/intevation/mxd/reader/LineSymbolReader.java:
+	  New.
+
 2011-05-26  Raimund Renkert  <raimund.renkert@intevation.de>
 
 	Added wrapper for marker symbol reader and extracted methods from symbol
--- a/src/java/de/intevation/mxd/reader/ISymbolReader.java	Thu May 26 16:12:38 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/ISymbolReader.java	Thu May 26 16:13:50 2011 +0200
@@ -4,6 +4,8 @@
 
 import org.w3c.dom.Element;
 
+import com.esri.arcgis.display.ISymbol;
+
 import de.intevation.mxd.utils.MapToXMLUtils;
 
 /**
@@ -17,6 +19,5 @@
 
     void setParent(Element parent);
     void setUtil(MapToXMLUtils util);
-
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/intevation/mxd/reader/LineSymbolReader.java	Thu May 26 16:13:50 2011 +0200
@@ -0,0 +1,135 @@
+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.ILineSymbol;
+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;
+
+/**
+ * Wrapper for line symbol reader.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class LineSymbolReader
+extends AbstractSymbolReader {
+
+    /**
+     * The logger.
+     */
+    private static final Logger logger =
+        Logger.getLogger(LineSymbolReader.class);
+
+    private ISymbol symbol;
+    private ILineSymbol lineSymbol;
+
+    public LineSymbolReader() throws Exception{
+        logger.debug("contructor()");
+        this.symbol = null;
+        this.lineSymbol = null;
+    }
+
+    public LineSymbolReader(ISymbol symbol) throws Exception{
+        logger.debug("contructor(ISymbol)");
+        this.symbol = symbol;
+        this.lineSymbol = null;
+    }
+
+    public LineSymbolReader(ILineSymbol symbol) throws Exception{
+        logger.debug("contructor(ILineSymbol)");
+        this.lineSymbol = symbol;
+        this.symbol= null;
+    }
+
+    public Element read() throws Exception {
+        ISymbolReader sreader = null;
+        if(symbol != null) {
+            if(symbol instanceof SimpleLineSymbol) {
+                sreader = new SimpleLineSymbolReader(symbol);
+            }
+            else if(symbol instanceof MarkerLineSymbol) {
+                sreader = new MarkerLineSymbolReader(symbol);
+            }
+            else if(symbol instanceof PictureLineSymbol) {
+                sreader = new PictureLineSymbolReader(symbol);
+            }
+            else if(symbol instanceof MultiLayerLineSymbol) {
+                sreader = new MultiLayerLineSymbolReader(symbol);
+            }
+            else if(symbol instanceof CartographicLineSymbol) {
+                sreader = new CartoLineSymbolReader(symbol);
+            }
+            else if(symbol instanceof HashLineSymbol) {
+                sreader = new HashLineSymbolReader(symbol);
+            }
+            else {
+                logger.debug("The reader for type " + symbol.getClass().toString() +
+                             " is not implemented!");
+                return parent;
+            }
+        }
+        else if(lineSymbol != null) {
+            if(lineSymbol instanceof SimpleLineSymbol) {
+                sreader = new SimpleLineSymbolReader(lineSymbol);
+            }
+            else if(lineSymbol instanceof MarkerLineSymbol) {
+                sreader = new MarkerLineSymbolReader(lineSymbol);
+            }
+            else if(lineSymbol instanceof PictureLineSymbol) {
+                sreader = new PictureLineSymbolReader(lineSymbol);
+            }
+            else if(lineSymbol instanceof MultiLayerLineSymbol) {
+                sreader = new MultiLayerLineSymbolReader(lineSymbol);
+            }
+            else if(lineSymbol instanceof CartographicLineSymbol) {
+                sreader = new CartoLineSymbolReader(lineSymbol);
+            }
+            else if(lineSymbol instanceof HashLineSymbol) {
+                sreader = new HashLineSymbolReader(lineSymbol);
+            }
+            else {
+                logger.debug("The reader for type " +
+                             lineSymbol.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;
+    }
+
+    public boolean canRead(ISymbol 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/MarkerSymbolReader.java	Thu May 26 16:12:38 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java	Thu May 26 16:13:50 2011 +0200
@@ -7,6 +7,7 @@
 import org.apache.log4j.Logger;
 
 import com.esri.arcgis.display.ISymbol;
+import com.esri.arcgis.display.SimpleMarkerSymbol;
 import com.esri.arcgis.display.ArrowMarkerSymbol;
 import com.esri.arcgis.display.CharacterMarkerSymbol;
 import com.esri.arcgis.display.PictureMarkerSymbol;
@@ -28,14 +29,27 @@
 
     private ISymbol symbol;
 
-    public MarkerSymbolReader(ISymbol symbol) throws Exception{
-        logger.debug("contructor()");
+    public MarkerSymbolReader(ISymbol symbol)
+    throws Exception {
+        logger.debug("contructor(ISymbol)");
         this.symbol = symbol;
     }
 
+    public MarkerSymbolReader() {
+        logger.debug("contructor()");
+        this.symbol = null;
+    }
+
     public Element read() throws Exception {
+        if(symbol == null) {
+            return parent;
+        }
+
         ISymbolReader sreader = null;
-        if(symbol instanceof ArrowMarkerSymbol) {
+        if(symbol instanceof SimpleMarkerSymbol) {
+            sreader = new SimpleMarkerSymbolReader(symbol);
+        }
+        else if(symbol instanceof ArrowMarkerSymbol) {
             sreader = new ArrowMarkerSymbolReader(symbol);
         }
         else if(symbol instanceof CharacterMarkerSymbol) {
@@ -59,4 +73,22 @@
         }
         return parent;
     }
+
+    public void setSymbol(ISymbol sym) {
+        this.symbol = sym;
+    }
+
+    public boolean canRead(ISymbol sym) {
+        if(sym instanceof SimpleMarkerSymbol ||
+           sym instanceof ArrowMarkerSymbol ||
+           sym instanceof PictureMarkerSymbol ||
+           sym instanceof CharacterMarkerSymbol ||
+           sym instanceof MultiLayerMarkerSymbol) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
 }
--- a/src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java	Thu May 26 16:12:38 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java	Thu May 26 16:13:50 2011 +0200
@@ -94,41 +94,10 @@
         for(int i = 0; i < symbol.getLayerCount(); i++) {
             try {
                 ISymbol sym = (ISymbol)symbol.getLayer(i);
-
-                if(sym instanceof SimpleLineSymbol) {
-                    ISymbolReader sreader = new SimpleLineSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else if(sym instanceof MarkerLineSymbol) {
-                    ISymbolReader sreader = new MarkerLineSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else if(sym instanceof PictureLineSymbol) {
-                    ISymbolReader sreader = new PictureLineSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else if(sym instanceof CartographicLineSymbol) {
-                    ISymbolReader sreader = new CartoLineSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else if(sym instanceof HashLineSymbol) {
-                    ISymbolReader sreader = new HashLineSymbolReader(sym);
-                    sreader.setParent(renderer);
-                    sreader.setUtil(util);
-                    sreader.read();
-                }
-                else {
-                    logger.debug("The type of " + sym.getClass().toString() +
-                                 " is not implemented!");
-                }
+                ISymbolReader sreader = new LineSymbolReader(sym);
+                sreader.setParent(renderer);
+                sreader.setUtil(util);
+                sreader.read();
             }
             catch(Exception e) {
                 e.printStackTrace();
--- a/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Thu May 26 16:12:38 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/SimpleRendererReader.java	Thu May 26 16:13:50 2011 +0200
@@ -85,41 +85,22 @@
             rendererElement.setAttribute("description", renderer.getDescription());
             symbol = renderer.getSymbol();
 
-            //TODO This reader can also read simple line symbols. Just add
-            //another else if statement with the corresponding reader.
-            //In MXD-files simple- and marker  lines use the MultiLayerLineSymbol.
-            if(symbol instanceof SimpleMarkerSymbol){
-                ISymbolReader isr= new SimpleMarkerSymbolReader(symbol);
-                isr.setParent(rendererElement);
-                isr.setUtil(util);
-                isr.read();
-            }
-            else if(symbol instanceof SimpleFillSymbol){
-                ISymbolReader isr = new SimpleFillSymbolReader(symbol);
-                isr.setParent(rendererElement);
-                isr.setUtil(util);
-                isr.read();
+            MarkerSymbolReader markerReader = new MarkerSymbolReader();
+            LineSymbolReader lineReader = new LineSymbolReader();
+            if(markerReader.canRead(symbol)) {
+                markerReader.setSymbol(symbol);
+                markerReader.setUtil(util);
+                markerReader.setParent(rendererElement);
+                markerReader.read();
             }
-            else if(symbol instanceof MultiLayerMarkerSymbol) {
-                ISymbolReader isr = new MultiLayerMarkerSymbolReader(symbol);
-                isr.setParent(rendererElement);
-                isr.setUtil(util);
-                isr.read();
-            }
-            else if(symbol instanceof MultiLayerLineSymbol) {
-                ISymbolReader isr = new MultiLayerLineSymbolReader(symbol);
-                isr.setParent(rendererElement);
-                isr.setUtil(util);
-                isr.read();
-            }
-            else if(symbol instanceof MultiLayerFillSymbol) {
-                ISymbolReader isr = new MultiLayerFillSymbolReader (symbol);
-                isr.setParent(rendererElement);
-                isr.setUtil(util);
-                isr.read();
+            else if(lineReader.canRead(symbol)) {
+                lineReader.setSymbol(symbol);
+                lineReader.setUtil(util);
+                lineReader.setParent(rendererElement);
+                lineReader.read();
             }
             else {
-                System.out.println("No known Symbol type: " + symbol.getClass().toString());
+                logger.debug("No known Symbol type: " + symbol.getClass().toString());
             }
             return layer;
         }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)