Merge all changes from the naturaldocs sandbox. This brings all the work that
has been done in the NaturalDocs branch back to trunk. Thanks to everyone who helped out in making this happen. (I could list people, but the list would be long, and I'm already mentally on vacation.) git-svn-id: http://svn.openlayers.org/trunk/openlayers@3545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+148
-95
@@ -3,31 +3,43 @@
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Renderer/Elements.js
|
||||
*
|
||||
* Class: OpenLayers.Renderer.SVG
|
||||
*
|
||||
* Inherits:
|
||||
* - <Openlayers.Renderer.Elements>
|
||||
*/
|
||||
OpenLayers.Renderer.SVG = OpenLayers.Class.create();
|
||||
OpenLayers.Renderer.SVG.prototype =
|
||||
OpenLayers.Class.inherit(OpenLayers.Renderer.Elements, {
|
||||
|
||||
/** @type String */
|
||||
/**
|
||||
* Property: xmlns
|
||||
* {String}
|
||||
*/
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
|
||||
// Firefox has a limitation where values larger or smaller than about
|
||||
// 15000 in an SVG document lock the browser up. This works around it.
|
||||
/** @type Integer */
|
||||
/**
|
||||
* Property: maxPixel
|
||||
* {Integer} Firefox has a limitation where values larger or smaller than
|
||||
* about 15000 in an SVG document lock the browser up. This
|
||||
* works around it.
|
||||
*/
|
||||
maxPixel: 15000,
|
||||
|
||||
|
||||
/** @type Float
|
||||
@private */
|
||||
/**
|
||||
* Property: localResolution
|
||||
* {Float}
|
||||
*/
|
||||
localResolution: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* Constructor: OpenLayers.Renderer.SVN
|
||||
*
|
||||
* @param {String} containerID
|
||||
* Parameters:
|
||||
* containerID - {String}
|
||||
*/
|
||||
initialize: function(containerID) {
|
||||
if (!this.supported()) {
|
||||
@@ -38,15 +50,17 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
OpenLayers.Renderer.Elements.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns Whether or not the browser supports the SVG renderer
|
||||
* @type Boolean
|
||||
* APIMethod: supported
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the browser supports the SVG renderer
|
||||
*/
|
||||
supported: function() {
|
||||
var svgFeature = "http://www.w3.org/TR/SVG11/feature#SVG";
|
||||
@@ -57,8 +71,10 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} extent
|
||||
* @private
|
||||
* Method: setExtent
|
||||
*
|
||||
* Parameters:
|
||||
* extent - {<OpenLayers.Bounds>}
|
||||
*/
|
||||
setExtent: function(extent) {
|
||||
OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,
|
||||
@@ -97,12 +113,11 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* function
|
||||
*
|
||||
* sets the size of the drawing surface
|
||||
*
|
||||
* @param size {OpenLayers.Size} the size of the drawing surface
|
||||
* @private
|
||||
* Method: setSize
|
||||
* Sets the size of the drawing surface.
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>} The size of the drawing surface
|
||||
*/
|
||||
setSize: function(size) {
|
||||
OpenLayers.Renderer.prototype.setSize.apply(this, arguments);
|
||||
@@ -115,11 +130,13 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
|
||||
|
||||
/**
|
||||
* @param geometry {OpenLayers.Geometry}
|
||||
* Method: getNodeType
|
||||
*
|
||||
* @returns The corresponding node type for the specified geometry
|
||||
* @type String
|
||||
* @private
|
||||
* Parameters:
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*
|
||||
* Return:
|
||||
* {String} The corresponding node type for the specified geometry
|
||||
*/
|
||||
getNodeType: function(geometry) {
|
||||
var nodeType = null;
|
||||
@@ -148,17 +165,18 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setStyle
|
||||
* Use to set all the style attributes to a SVG node.
|
||||
*
|
||||
* Note: takes care to adjust stroke width and point radius
|
||||
* to be resolution-relative
|
||||
* Takes care to adjust stroke width and point radius to be
|
||||
* resolution-relative
|
||||
*
|
||||
* @param node {SVGDomElement} an SVG element to decorate
|
||||
* @param {Object} style
|
||||
* @param {Object} options
|
||||
* @option isFilled {boolean}
|
||||
* @option isStroked {boolean}
|
||||
* @private
|
||||
* Parameters:
|
||||
* node - {SVGDomElement} An SVG element to decorate
|
||||
* style - {Object}
|
||||
* options - {Object} Currently supported options include
|
||||
* 'isFilled' {Boolean} and
|
||||
* 'isStroked' {Boolean}
|
||||
*/
|
||||
setStyle: function(node, style, options) {
|
||||
style = style || node._style;
|
||||
@@ -194,13 +212,14 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {String} type Kind of node to draw
|
||||
* @param {String} id Id for node
|
||||
* Method: createNode
|
||||
*
|
||||
* @returns A new node of the given type and id
|
||||
* @type DOMElement
|
||||
* Parameters:
|
||||
* type - {String} Kind of node to draw
|
||||
* id - {String} Id for node
|
||||
*
|
||||
* Return:
|
||||
* {DOMElement} A new node of the given type and id
|
||||
*/
|
||||
createNode: function(type, id) {
|
||||
var node = document.createElementNS(this.xmlns, type);
|
||||
@@ -211,22 +230,24 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {String} type Kind of node to draw
|
||||
* @param {String} id Id for node
|
||||
* Method: nodeTypeCompare
|
||||
*
|
||||
* @returns Whether or not the specified node is of the specified type
|
||||
* @type Boolean
|
||||
* Parameters:
|
||||
* node - {SVGDomElement} An SVG element
|
||||
* type - {String} Kind of node
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the specified node is of the specified type
|
||||
*/
|
||||
nodeTypeCompare: function(node, type) {
|
||||
return (type == node.nodeName);
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The specific render engine's root element
|
||||
* @type DOMElement
|
||||
* @private
|
||||
* Method: createRenderRoot
|
||||
*
|
||||
* Return:
|
||||
* {DOMElement} The specific render engine's root element
|
||||
*/
|
||||
createRenderRoot: function() {
|
||||
var id = this.container.id + "_svgRoot";
|
||||
@@ -235,9 +256,10 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The main root element to which we'll add vectors
|
||||
* @type DOMElement
|
||||
* @private
|
||||
* Method: createRoot
|
||||
*
|
||||
* Return:
|
||||
* {DOMElement} The main root element to which we'll add vectors
|
||||
*/
|
||||
createRoot: function() {
|
||||
var id = this.container.id + "_root";
|
||||
@@ -257,20 +279,26 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
* *
|
||||
**************************************/
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Method: drawPoint
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawPoint: function(node, geometry) {
|
||||
this.drawCircle(node, geometry, 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @param {float} radius
|
||||
* @private
|
||||
/**
|
||||
* Method: drawCircle
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
* radius - {Float}
|
||||
*/
|
||||
drawCircle: function(node, geometry, radius) {
|
||||
var resolution = this.getResolution();
|
||||
@@ -290,29 +318,38 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Method: drawLineString
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawLineString: function(node, geometry) {
|
||||
node.setAttributeNS(null, "points", this.getComponentsString(geometry.components));
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**v
|
||||
* Method: drawLinearRing
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawLinearRing: function(node, geometry) {
|
||||
node.setAttributeNS(null, "points", this.getComponentsString(geometry.components));
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Method: drawPolygon
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawPolygon: function(node, geometry) {
|
||||
var d = "";
|
||||
var draw = true;
|
||||
@@ -337,11 +374,14 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Method: drawRectangle
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawRectangle: function(node, geometry) {
|
||||
// This needs to be reworked
|
||||
var x = (geometry.x / resolution + this.left);
|
||||
@@ -364,11 +404,14 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Method: drawCurve
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawCurve: function(node, geometry) {
|
||||
var d = null;
|
||||
var draw = true;
|
||||
@@ -394,11 +437,14 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @param {OpenLayers.Geometry} geometry
|
||||
* @private
|
||||
*/
|
||||
/**
|
||||
* Method: drawSurface
|
||||
* This method is only called by the renderer itself.
|
||||
*
|
||||
* Parameters:
|
||||
* node - {DOMElement}
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
drawSurface: function(node, geometry) {
|
||||
|
||||
// create the svg path string representation
|
||||
@@ -428,8 +474,10 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Array} components array of points
|
||||
* @private
|
||||
* Method: getComponentString
|
||||
*
|
||||
* Parameters:
|
||||
* components - {Array} Array of points
|
||||
*/
|
||||
getComponentsString: function(components) {
|
||||
var strings = [];
|
||||
@@ -444,8 +492,13 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Geometry.Point} point
|
||||
* @private
|
||||
* Method: getShortString
|
||||
*
|
||||
* Parameters:
|
||||
* point - {<OpenLayers.Geometry.Point>}
|
||||
*
|
||||
* Return:
|
||||
* {String}
|
||||
*/
|
||||
getShortString: function(point) {
|
||||
var resolution = this.getResolution();
|
||||
|
||||
Reference in New Issue
Block a user