changeset 184:c79c3c6fc99a

Always save a symbol set, use the mapfile name as prefix for the symbol set and use the mapfile path to save the symbol set.
author raimund renkert <raimund.renkert@intevation.de>
date Wed, 20 Jul 2011 12:23:57 +0200
parents fe6dbfc86144
children 415101ff1ac2
files ChangeLog src/java/de/intevation/mxd/writer/FillStyleWriter.java src/java/de/intevation/mxd/writer/LineStyleWriter.java src/java/de/intevation/mxd/writer/SymbolWriter.java
diffstat 4 files changed, 55 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jul 18 17:17:04 2011 +0200
+++ b/ChangeLog	Wed Jul 20 12:23:57 2011 +0200
@@ -1,3 +1,13 @@
+2011-07-20  Raimund Renkert  <raimund.renkert@intevation.de>
+
+	* src/java/de/intevation/mxd/writer/FillStyleWriter.java,
+	  src/java/de/intevation/mxd/writer/LineStyleWriter.java:
+	  Always save a symbol set.
+
+	* src/java/de/intevation/mxd/writer/SymbolWriter.java:
+	  Made the saveSymbolSet method public to be able to save an empty
+	  symbol set and changed the path and name for the symbol set. 
+
 2011-07-18  Raimund Renkert  <raimund.renkert@intevation.de>
 
 	* doku/source/functionality.txt,
--- a/src/java/de/intevation/mxd/writer/FillStyleWriter.java	Mon Jul 18 17:17:04 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/FillStyleWriter.java	Wed Jul 20 12:23:57 2011 +0200
@@ -84,6 +84,13 @@
                     if (symbols.getLength() == 1) {
                         writeSimple(symbolElement);
                     }
+                    try {
+                        SymbolWriter sw = new SymbolWriter(this.map, this.cl);
+                        sw.saveSymbolSet(symbolSet);
+                    }
+                    catch(Exception e) {
+                        logger.warn("Could not save symbol set.");
+                    }
                 }
                 else if(nextSym.getTagName().equals("symbol") &&
                    !symbolElement.hasAttribute("hatch") ||
@@ -121,6 +128,13 @@
                 }
                 else {
                     writeSimple(symbolElement);
+                    try {
+                        SymbolWriter sw = new SymbolWriter(this.map, this.cl);
+                        sw.saveSymbolSet(symbolSet);
+                    }
+                    catch(Exception e) {
+                        logger.warn("Could not save symbol set.");
+                    }
                 }
             }
         }
@@ -144,8 +158,14 @@
                     style.setOutlinewidth(0.0);
                 }
             }
+            try {
+                SymbolWriter sw = new SymbolWriter(this.map, this.cl);
+                sw.saveSymbolSet(symbolSet);
+            }
+            catch(Exception e) {
+                logger.warn("Could not save symbol set.");
+            }
         }
-
         return true;
     }
 
--- a/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Mon Jul 18 17:17:04 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Wed Jul 20 12:23:57 2011 +0200
@@ -129,14 +129,7 @@
             }
         }
 
-        String type = symbolElement.getAttribute("type");
-        if(type.equals("marker")) {
-            SymbolWriter sw = new SymbolWriter(this.map, this.cl);
-            sw.write(symbolElement);
-            String name = symbolElement.getAttribute("name");
-            style.setSymbolByName(map, name);
-            symbolObj sym = symbolSet.getSymbolByName(name);
-        }
+
 
         //The following lines are for dashed and/or dotted lines.
         if(symbolElement.hasAttribute("linestyle")) {
@@ -202,6 +195,24 @@
                 logger.warn("Could not write PATTERN.");
             }
         }
+        String type = symbolElement.getAttribute("type");
+        if(type.equals("marker")) {
+            SymbolWriter sw = new SymbolWriter(this.map, this.cl);
+            sw.write(symbolElement);
+            String name = symbolElement.getAttribute("name");
+            style.setSymbolByName(map, name);
+            symbolObj sym = symbolSet.getSymbolByName(name);
+        }
+        else {
+            try {
+                SymbolWriter sw = new SymbolWriter (this.map, this.cl);
+                sw.saveSymbolSet (symbolSet);
+            }
+            catch (Exception e) {
+                logger.warn("Could not write symbol set.");
+            }
+        }
+
         return false;
     }
 }
--- a/src/java/de/intevation/mxd/writer/SymbolWriter.java	Mon Jul 18 17:17:04 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/SymbolWriter.java	Wed Jul 20 12:23:57 2011 +0200
@@ -193,21 +193,15 @@
      *
      * @param symbols The symbol set object.
      */
-    private void saveSymbolSet(symbolSetObj symbols)
+    public void saveSymbolSet(symbolSetObj symbols)
     throws Exception {
         String path = this.map.getMappath();
-        String symbolPath = symbols.getFilename();
+        String filename = path.substring(path.lastIndexOf(File.separator) + 1,
+                                         path.lastIndexOf("."));
+        String symbolPath = filename + "-symbols.sym";
         if(path.equals("")) {
             return;
         }
-        if(symbolPath == null || symbolPath.equals("")) {
-            symbolPath = "symbols.sym";
-            symbols.setFilename(symbolPath);
-            path = path.replaceAll("\\\\", "/");
-            symbols.save(path);
-            this.map.setSymbolSet(path);
-            return;
-        }
 
         if (path.endsWith(".map")) {
             path = path.substring(0, path.lastIndexOf(File.separator) + 1);
@@ -218,7 +212,7 @@
         }
         path = path.replaceAll("\\\\", "/");
         symbols.save(path);
-        this.map.setSymbolSet(symbolPath);
+        this.map.setSymbolSet(path);
     }
 
     /**
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)