diff src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 49:0fecdcc28b1b

Created one method for each symbol type in the writer.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 20 Apr 2011 11:56:35 +0200
parents 34a93dad7604
children 691864097eb1
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Apr 20 11:48:46 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/MapScriptWriter.java	Wed Apr 20 11:56:35 2011 +0200
@@ -272,30 +272,67 @@
 
             String symType = symbolElement.getAttribute("style");
             if(symType.equals("point")) {
-                lineObj points = new lineObj();
-                points.add(new pointObj(1,1,0));
-                sym.setType(MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue());
-                sym.setPoints(points);
-                sym.setFilled(1);
+                writePointSymbol(sym, symbolElement);
             }
             else if (symType.equals("arrow")) {
-                double len = Double.parseDouble(symbolElement.getAttribute("length"));
-                double width = Double.parseDouble(symbolElement.getAttribute("width"));
-                double ratio = len/width;
-                lineObj points = new lineObj();
-
-                points.add(new pointObj(0, 0, 0));
-                points.add(new pointObj((1*ratio), 0.5, 0));
-                points.add(new pointObj(0, 1, 0));
-                points.add(new pointObj(0, 0, 0));
-                sym.setType(MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue());
-                sym.setPoints(points);
-                sym.setFilled(1);
+                writeArrowSymbol(sym, symbolElement);
+            }
+            else if (symType.equals("char")) {
+                writeCharSymbol(sym, symbolElement);
             }
         }
         saveSymbolSet(symbolSet);
     }
 
+
+    /**
+     * Write point symbols to the map.
+     * @param symbol The symbol object.
+     * @param symbolElement The DOM object containing the attributes.
+     */
+    private void writePointSymbol(symbolObj symbol, Element symbolElement) {
+        lineObj points = new lineObj();
+        points.add(new pointObj(1,1,0));
+        symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_ELLIPSE.swigValue());
+        symbol.setPoints(points);
+        symbol.setFilled(1);
+    }
+
+
+    /**
+     * Write arrow symbol to the map.
+     * @param symbol The symbol object.
+     * @param symbolElement The DOM object containig the attributes.
+     */
+    private void writeArrowSymbol(symbolObj symbol, Element symbolElement) {
+        double len = Double.parseDouble(symbolElement.getAttribute("length"));
+        double width = Double.parseDouble(symbolElement.getAttribute("width"));
+        double ratio = len/width;
+        lineObj points = new lineObj();
+
+        points.add(new pointObj(0, 0, 0));
+        points.add(new pointObj((1*ratio), 0.5, 0));
+        points.add(new pointObj(0, 1, 0));
+        points.add(new pointObj(0, 0, 0));
+        symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_VECTOR.swigValue());
+        symbol.setPoints(points);
+        symbol.setFilled(1);
+    }
+
+
+    /**
+     * Write font symbols to the map.
+     * @param symbol The symbol object.
+     * @param symbolElement The DOM object containing the attributes.
+     */
+    private void writeCharSymbol(symbolObj symbol, Element symbolElement) {
+        symbol.setFont(symbolElement.getAttribute("font"));
+        symbol.setType(MS_SYMBOL_TYPE.MS_SYMBOL_TRUETYPE.swigValue());
+        symbol.setAntialias(1);
+        symbol.setCharacter("#&" + symbolElement.getAttribute("char") + ";");
+    }
+
+
     /**
      * Save the symbol set.
      * @param symbols The symbol set.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)