diff src/java/de/intevation/mxd/reader/MarkerSymbolReader.java @ 75:9ea64427ac7e

Added marker fill symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 27 May 2011 12:04:19 +0200
parents 7eba97e8201b
children fb93f20478cc
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java	Thu May 26 18:11:29 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java	Fri May 27 12:04:19 2011 +0200
@@ -7,6 +7,7 @@
 import org.apache.log4j.Logger;
 
 import com.esri.arcgis.display.ISymbol;
+import com.esri.arcgis.display.IMarkerSymbol;
 import com.esri.arcgis.display.SimpleMarkerSymbol;
 import com.esri.arcgis.display.ArrowMarkerSymbol;
 import com.esri.arcgis.display.CharacterMarkerSymbol;
@@ -25,58 +26,96 @@
      * The logger.
      */
     private static final Logger logger =
-        Logger.getLogger(SimpleFillSymbolReader.class);
+        Logger.getLogger(MarkerSymbolReader.class);
 
     private ISymbol symbol;
+    private IMarkerSymbol markerSymbol;
 
     public MarkerSymbolReader(ISymbol symbol)
     throws Exception {
         logger.debug("contructor(ISymbol)");
         this.symbol = symbol;
+        this.markerSymbol = null;
+    }
+
+    public MarkerSymbolReader(IMarkerSymbol symbol)
+    throws Exception {
+        logger.debug("contructor(ISymbol)");
+        this.markerSymbol = symbol;
+        this.symbol = null;
     }
 
     public MarkerSymbolReader() {
         logger.debug("contructor()");
         this.symbol = null;
+        this.markerSymbol = null;
     }
 
     public Element read()
     throws Exception {
-        if(symbol == null) {
-            return parent;
-        }
-
+        logger.debug("read()");
         ISymbolReader sreader = null;
-        if(symbol instanceof SimpleMarkerSymbol) {
-            sreader = new SimpleMarkerSymbolReader(symbol);
-        }
-        else if(symbol instanceof ArrowMarkerSymbol) {
-            sreader = new ArrowMarkerSymbolReader(symbol);
+
+        if(symbol != null) {
+            if(symbol instanceof SimpleMarkerSymbol) {
+                sreader = new SimpleMarkerSymbolReader(symbol);
+            }
+            else 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;
+            }
         }
-        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;
+        else if(markerSymbol != null) {
+            if(markerSymbol instanceof SimpleMarkerSymbol) {
+                sreader = new SimpleMarkerSymbolReader(markerSymbol);
+            }
+            else if(markerSymbol instanceof ArrowMarkerSymbol) {
+                sreader = new ArrowMarkerSymbolReader(markerSymbol);
+            }
+            else if(markerSymbol instanceof CharacterMarkerSymbol) {
+                sreader = new CharacterMarkerSymbolReader(markerSymbol);
+            }
+            else if(markerSymbol instanceof PictureMarkerSymbol) {
+                sreader = new PictureMarkerSymbolReader(markerSymbol);
+            }
+            else if(markerSymbol instanceof MultiLayerMarkerSymbol) {
+                sreader = new MultiLayerMarkerSymbolReader(markerSymbol);
+            }
+            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();
+            sreader.read();
         }
         return parent;
     }
 
     public void setSymbol(ISymbol sym) {
         this.symbol = sym;
+        this.markerSymbol = null;
+    }
+
+    public void setSymbol(IMarkerSymbol sym) {
+        this.markerSymbol = sym;
+        this.symbol = null;
     }
 
     public boolean canRead(ISymbol sym) {
@@ -92,4 +131,17 @@
         }
     }
 
+    public boolean canRead(IMarkerSymbol sym) {
+        if(sym instanceof SimpleMarkerSymbol ||
+           sym instanceof ArrowMarkerSymbol ||
+           sym instanceof PictureMarkerSymbol ||
+           sym instanceof CharacterMarkerSymbol ||
+           sym instanceof MultiLayerMarkerSymbol) {
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)