[OpenLayers-Commits] r11700 - trunk/openlayers/lib/OpenLayers/Renderer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Mar 11 21:31:40 EST 2011


Author: ahocevar
Date: 2011-03-11 18:31:39 -0800 (Fri, 11 Mar 2011)
New Revision: 11700

Modified:
   trunk/openlayers/lib/OpenLayers/Renderer/SVG2.js
Log:
duplicating constants from Renderer.SVG and fixing API docs. Thanks jorix for the pointer. Non-functional change.

Modified: trunk/openlayers/lib/OpenLayers/Renderer/SVG2.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Renderer/SVG2.js	2011-03-11 22:08:31 UTC (rev 11699)
+++ trunk/openlayers/lib/OpenLayers/Renderer/SVG2.js	2011-03-12 02:31:39 UTC (rev 11700)
@@ -42,7 +42,7 @@
     labelNodeType: "g",
 
     /**
-     * Constructor: OpenLayers.Renderer.SVG
+     * Constructor: OpenLayers.Renderer.SVG2
      * 
      * Parameters:
      * containerID - {String}
@@ -615,14 +615,14 @@
         }
         var align = style.labelAlign || "cm";
         text.setAttributeNS(null, "text-anchor",
-            OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || "middle");
+            OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[0]] || "middle");
 
         if (OpenLayers.IS_GECKO === true) {
             text.setAttributeNS(null, "dominant-baseline",
-                OpenLayers.Renderer.SVG.LABEL_ALIGN[align[1]] || "central");
+                OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[1]] || "central");
         } else {
             tspan.setAttributeNS(null, "baseline-shift",
-                OpenLayers.Renderer.SVG.LABEL_VSHIFT[align[1]] || "-35%");
+                OpenLayers.Renderer.SVG2.LABEL_VSHIFT[align[1]] || "-35%");
         }
 
         tspan.textContent = style.label;
@@ -758,6 +758,31 @@
     CLASS_NAME: "OpenLayers.Renderer.SVG2"
 });
 
+/**
+ * Constant: OpenLayers.Renderer.SVG2.LABEL_ALIGN
+ * {Object}
+ */
+OpenLayers.Renderer.SVG2.LABEL_ALIGN = {
+    "l": "start",
+    "r": "end",
+    "b": "bottom",
+    "t": "hanging"
+};
+
+/**
+ * Constant: OpenLayers.Renderer.SVG2.LABEL_VSHIFT
+ * {Object}
+ */
+OpenLayers.Renderer.SVG2.LABEL_VSHIFT = {
+    // according to
+    // http://www.w3.org/Graphics/SVG/Test/20061213/htmlObjectHarness/full-text-align-02-b.html
+    // a baseline-shift of -70% shifts the text exactly from the
+    // bottom to the top of the baseline, so -35% moves the text to
+    // the center of the baseline.
+    "t": "-70%",
+    "b": "0"    
+};
+
 /** 
  * Function: OpenLayers.Renderer.SVG2.preventDefault 
  * Used to prevent default events (especially opening images in a new tab on 



More information about the Commits mailing list