From 7f0ccb69f04c5619bb4674e363b252404ef4134b Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Mon, 2 Apr 2007 16:46:34 +0000 Subject: [PATCH] propset svn:eol-style native recursively throughout trunk. enjoy\! git-svn-id: http://svn.openlayers.org/trunk/openlayers@2978 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- examples/draw-feature.html | 192 ++++----- examples/fullScreen.html | 80 ++-- examples/georss-serialize.html | 100 ++--- examples/gml-serialize.html | 172 ++++---- examples/gml/owls.xml | 312 +++++++------- examples/kml/lines.kml | 534 +++++++++++------------ examples/webcam.html | 88 ++-- lib/OpenLayers/Renderer/Elements.js | 538 ++++++++++++------------ tests/Layer/test_MapServer.html | 483 ++++++++++----------- tests/Layer/test_MapServer_Untiled.html | 326 +++++++------- tests/Layer/test_Vector.html | 148 +++---- tests/test_Format.html | 42 +- tests/test_Geometry.html | 424 +++++++++---------- tests/test_Renderer.html | 332 +++++++-------- 14 files changed, 1893 insertions(+), 1878 deletions(-) diff --git a/examples/draw-feature.html b/examples/draw-feature.html index 6d6cc2d61b..760fef8e71 100644 --- a/examples/draw-feature.html +++ b/examples/draw-feature.html @@ -1,96 +1,96 @@ - - - - - - - -

OpenLayers Draw Feature Example

-
- -

Feature digitizing is in freehand mode by default. In freehand mode, the mouse is treated as a pen. - Drawing begins on mouse down, continues with every mouse move, and ends with mouse up.

-

To turn freehand mode off, hold down the shift key while digitizing. With freehand mode off, one - vertex is added with each click and double-clicks finish drawing. Freehand mode can be toggled on and off - at any time while drawing.

- - - + + + + + + + +

OpenLayers Draw Feature Example

+
+ +

Feature digitizing is in freehand mode by default. In freehand mode, the mouse is treated as a pen. + Drawing begins on mouse down, continues with every mouse move, and ends with mouse up.

+

To turn freehand mode off, hold down the shift key while digitizing. With freehand mode off, one + vertex is added with each click and double-clicks finish drawing. Freehand mode can be toggled on and off + at any time while drawing.

+ + + diff --git a/examples/fullScreen.html b/examples/fullScreen.html index 450980936b..681199d910 100644 --- a/examples/fullScreen.html +++ b/examples/fullScreen.html @@ -1,40 +1,40 @@ - - - - - - - -
- - + + + + + + + +
+ + diff --git a/examples/georss-serialize.html b/examples/georss-serialize.html index 24a0c2970f..90e51c58ac 100644 --- a/examples/georss-serialize.html +++ b/examples/georss-serialize.html @@ -1,50 +1,50 @@ - - - - - - - -

OpenLayers Draw Point Example

-
- -
-
- - + + + + + + + +

OpenLayers Draw Point Example

+
+ +
+
+ + diff --git a/examples/gml-serialize.html b/examples/gml-serialize.html index 52e23b46dd..69383b0b21 100644 --- a/examples/gml-serialize.html +++ b/examples/gml-serialize.html @@ -1,86 +1,86 @@ - - - - - - - -

OpenLayers Draw Point Example

-
- -

Check the box to draw points. Uncheck to navigate normally.

- -
-
- - + + + + + + + +

OpenLayers Draw Point Example

+
+ +

Check the box to draw points. Uncheck to navigate normally.

+ +
+
+ + diff --git a/examples/gml/owls.xml b/examples/gml/owls.xml index a06e633e88..4a001eca26 100644 --- a/examples/gml/owls.xml +++ b/examples/gml/owls.xml @@ -1,156 +1,156 @@ - - - - - -89.817223,45.005555 -74.755001,51.701388 - - - - - - -79.771668,45.891110 -79.771668,45.891110 - - - - - -79.771668,45.891110 - - - - - - - - - -83.755834,46.365277 -83.755834,46.365277 - - - owl - - - -83.755834,46.365277 - - - - - - - - - -83.808612,46.175277 -83.808612,46.175277 - - - - - -83.808612,46.175277 - - - - - - - - - -84.111112,46.309166 -84.111112,46.309166 - - - - - -84.111112,46.309166 - - - - - - - - - -83.678612,46.821110 -83.678612,46.821110 - - - - - -83.678612,46.821110 - - - - - - - - - -83.664445,46.518888 -83.664445,46.518888 - - - - - -83.664445,46.518888 - - - - - - - - - -80.613334,46.730277 -80.613334,46.730277 - - - - - -80.613334,46.730277 - - - - - - - - - -79.676946,45.428054 -79.676946,45.428054 - - - - - -79.676946,45.428054 - - - - - - - - - -83.853056,46.236944 -83.853056,46.236944 - - - - - -83.853056,46.236944 - - - - - - - - - -82.289167,45.896388 -82.289167,45.896388 - - - - - -82.289167,45.896388 - - - - - - + + + + + -89.817223,45.005555 -74.755001,51.701388 + + + + + + -79.771668,45.891110 -79.771668,45.891110 + + + + + -79.771668,45.891110 + + + + + + + + + -83.755834,46.365277 -83.755834,46.365277 + + + owl + + + -83.755834,46.365277 + + + + + + + + + -83.808612,46.175277 -83.808612,46.175277 + + + + + -83.808612,46.175277 + + + + + + + + + -84.111112,46.309166 -84.111112,46.309166 + + + + + -84.111112,46.309166 + + + + + + + + + -83.678612,46.821110 -83.678612,46.821110 + + + + + -83.678612,46.821110 + + + + + + + + + -83.664445,46.518888 -83.664445,46.518888 + + + + + -83.664445,46.518888 + + + + + + + + + -80.613334,46.730277 -80.613334,46.730277 + + + + + -80.613334,46.730277 + + + + + + + + + -79.676946,45.428054 -79.676946,45.428054 + + + + + -79.676946,45.428054 + + + + + + + + + -83.853056,46.236944 -83.853056,46.236944 + + + + + -83.853056,46.236944 + + + + + + + + + -82.289167,45.896388 -82.289167,45.896388 + + + + + -82.289167,45.896388 + + + + + + diff --git a/examples/kml/lines.kml b/examples/kml/lines.kml index 76cded7798..6dc09d7de6 100644 --- a/examples/kml/lines.kml +++ b/examples/kml/lines.kml @@ -1,267 +1,267 @@ - - - - KML Samples - 1 - Unleash your creativity with the help of these examples! - - - - - - - - - - - - - - Paths - 0 - Examples of paths. Note that the tessellate tag is by default - set to 0. If you want to create tessellated lines, they must be authored - (or edited) directly in KML. - - Tessellated - 0 - tag has a value of 1, the line will contour to the underlying terrain]]> - - -112.0822680013139 - 36.09825589333556 - 0 - 2889.145007690472 - 62.04855796276328 - 103.8120432044965 - - - 1 - -112.0814237830345,36.10677870477137,0 - -112.0870267752693,36.0905099328766,0 - - - - Untessellated - 0 - tag has a value of 0, the line follow a simple straight-line path from point to point]]> - - -112.0822680013139 - 36.09825589333556 - 0 - 2889.145007690472 - 62.04855796276328 - 103.8120432044965 - - - 0 - -112.080622229595,36.10673460007995,0 - -112.085242575315,36.09049598612422,0 - - - - Absolute - 0 - Transparent purple line - - -112.2719329043177 - 36.08890633450894 - 0 - 2569.386744398339 - 44.60763714063257 - -106.8161545998597 - - #transPurpleLineGreenPoly - - 1 - absolute - -112.265654928602,36.09447672602546,2357 - -112.2660384528238,36.09342608838671,2357 - -112.2668139013453,36.09251058776881,2357 - -112.2677826834445,36.09189827357996,2357 - -112.2688557510952,36.0913137941187,2357 - -112.2694810717219,36.0903677207521,2357 - -112.2695268555611,36.08932171487285,2357 - -112.2690144567276,36.08850916060472,2357 - -112.2681528815339,36.08753813597956,2357 - -112.2670588176031,36.08682685262568,2357 - -112.2657374587321,36.08646312301303,2357 - - - - Absolute Extruded - 0 - Transparent green wall with yellow outlines - - -112.2643334742529 - 36.08563154742419 - 0 - 4451.842204068102 - 44.61038665812578 - -125.7518698668815 - - #yellowLineGreenPoly - - 1 - 1 - absolute - -112.2550785337791,36.07954952145647,2357 - -112.2549277039738,36.08117083492122,2357 - -112.2552505069063,36.08260761307279,2357 - -112.2564540158376,36.08395660588506,2357 - -112.2580238976449,36.08511401044813,2357 - -112.2595218489022,36.08584355239394,2357 - -112.2608216347552,36.08612634548589,2357 - -112.262073428656,36.08626019085147,2357 - -112.2633204928495,36.08621519860091,2357 - -112.2644963846444,36.08627897945274,2357 - -112.2656969554589,36.08649599090644,2357 - - - - Relative - 0 - Black line (10 pixels wide), height tracks terrain - - -112.2580438551384 - 36.1072674824385 - 0 - 2927.61105910266 - 44.61324882043339 - 4.947421249553717 - - #thickBlackLine - - 1 - relativeToGround - -112.2532845153347,36.09886943729116,645 - -112.2540466121145,36.09919570465255,645 - -112.254734666947,36.09984998366178,645 - -112.255493345654,36.10051310621746,645 - -112.2563157098468,36.10108441943419,645 - -112.2568033076439,36.10159722088088,645 - -112.257494011321,36.10204323542867,645 - -112.2584106072308,36.10229131995655,645 - -112.2596588987972,36.10240001286358,645 - -112.2610581199487,36.10213176873407,645 - -112.2626285262793,36.10157011437219,645 - - - - Relative Extruded - 0 - Opaque blue walls with red outline, height tracks terrain - - -112.2683594333433 - 36.09884362144909 - 0 - 2184.193522571467 - 44.60855445139561 - -72.24271551768405 - - #redLineBluePoly - - 1 - 1 - relativeToGround - -112.2656634181359,36.09445214722695,630 - -112.2652238941097,36.09520916122063,630 - -112.2645079986395,36.09580763864907,630 - -112.2638827428817,36.09628572284063,630 - -112.2635746835406,36.09679275951239,630 - -112.2635711822407,36.09740038871899,630 - -112.2640296531825,36.09804913435539,630 - -112.264327720538,36.09880337400301,630 - -112.2642436562271,36.09963644790288,630 - -112.2639148687042,36.10055381117246,630 - -112.2626894973474,36.10149062823369,630 - - - - - + + + + KML Samples + 1 + Unleash your creativity with the help of these examples! + + + + + + + + + + + + + + Paths + 0 + Examples of paths. Note that the tessellate tag is by default + set to 0. If you want to create tessellated lines, they must be authored + (or edited) directly in KML. + + Tessellated + 0 + tag has a value of 1, the line will contour to the underlying terrain]]> + + -112.0822680013139 + 36.09825589333556 + 0 + 2889.145007690472 + 62.04855796276328 + 103.8120432044965 + + + 1 + -112.0814237830345,36.10677870477137,0 + -112.0870267752693,36.0905099328766,0 + + + + Untessellated + 0 + tag has a value of 0, the line follow a simple straight-line path from point to point]]> + + -112.0822680013139 + 36.09825589333556 + 0 + 2889.145007690472 + 62.04855796276328 + 103.8120432044965 + + + 0 + -112.080622229595,36.10673460007995,0 + -112.085242575315,36.09049598612422,0 + + + + Absolute + 0 + Transparent purple line + + -112.2719329043177 + 36.08890633450894 + 0 + 2569.386744398339 + 44.60763714063257 + -106.8161545998597 + + #transPurpleLineGreenPoly + + 1 + absolute + -112.265654928602,36.09447672602546,2357 + -112.2660384528238,36.09342608838671,2357 + -112.2668139013453,36.09251058776881,2357 + -112.2677826834445,36.09189827357996,2357 + -112.2688557510952,36.0913137941187,2357 + -112.2694810717219,36.0903677207521,2357 + -112.2695268555611,36.08932171487285,2357 + -112.2690144567276,36.08850916060472,2357 + -112.2681528815339,36.08753813597956,2357 + -112.2670588176031,36.08682685262568,2357 + -112.2657374587321,36.08646312301303,2357 + + + + Absolute Extruded + 0 + Transparent green wall with yellow outlines + + -112.2643334742529 + 36.08563154742419 + 0 + 4451.842204068102 + 44.61038665812578 + -125.7518698668815 + + #yellowLineGreenPoly + + 1 + 1 + absolute + -112.2550785337791,36.07954952145647,2357 + -112.2549277039738,36.08117083492122,2357 + -112.2552505069063,36.08260761307279,2357 + -112.2564540158376,36.08395660588506,2357 + -112.2580238976449,36.08511401044813,2357 + -112.2595218489022,36.08584355239394,2357 + -112.2608216347552,36.08612634548589,2357 + -112.262073428656,36.08626019085147,2357 + -112.2633204928495,36.08621519860091,2357 + -112.2644963846444,36.08627897945274,2357 + -112.2656969554589,36.08649599090644,2357 + + + + Relative + 0 + Black line (10 pixels wide), height tracks terrain + + -112.2580438551384 + 36.1072674824385 + 0 + 2927.61105910266 + 44.61324882043339 + 4.947421249553717 + + #thickBlackLine + + 1 + relativeToGround + -112.2532845153347,36.09886943729116,645 + -112.2540466121145,36.09919570465255,645 + -112.254734666947,36.09984998366178,645 + -112.255493345654,36.10051310621746,645 + -112.2563157098468,36.10108441943419,645 + -112.2568033076439,36.10159722088088,645 + -112.257494011321,36.10204323542867,645 + -112.2584106072308,36.10229131995655,645 + -112.2596588987972,36.10240001286358,645 + -112.2610581199487,36.10213176873407,645 + -112.2626285262793,36.10157011437219,645 + + + + Relative Extruded + 0 + Opaque blue walls with red outline, height tracks terrain + + -112.2683594333433 + 36.09884362144909 + 0 + 2184.193522571467 + 44.60855445139561 + -72.24271551768405 + + #redLineBluePoly + + 1 + 1 + relativeToGround + -112.2656634181359,36.09445214722695,630 + -112.2652238941097,36.09520916122063,630 + -112.2645079986395,36.09580763864907,630 + -112.2638827428817,36.09628572284063,630 + -112.2635746835406,36.09679275951239,630 + -112.2635711822407,36.09740038871899,630 + -112.2640296531825,36.09804913435539,630 + -112.264327720538,36.09880337400301,630 + -112.2642436562271,36.09963644790288,630 + -112.2639148687042,36.10055381117246,630 + -112.2626894973474,36.10149062823369,630 + + + + + diff --git a/examples/webcam.html b/examples/webcam.html index bf6cb3b1b2..5c5949a1a4 100644 --- a/examples/webcam.html +++ b/examples/webcam.html @@ -1,44 +1,44 @@ - - - - - - - -

OpenLayers Webcam

-
- - + + + + + + + +

OpenLayers Webcam

+
+ + diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index 47e7b749b9..c0f5fe48ea 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -1,269 +1,269 @@ -/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license. - * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt - * for the full text of the license. */ - -/** - * @class - * - * This is another virtual class in that it should never be instantiated by - * itself as a Renderer. It exists because there is *tons* of shared - * functionality between different vector libraries which use nodes/elements - * as a base for rendering vectors. - * - * The highlevel bits of code that are implemented here are the adding and - * removing of geometries, which is essentially the same for any - * element-based renderer. The details of creating each node and drawing the - * paths are of course different, but the machinery is the same. - * - * @requires OpenLayers/Renderer.js - */ -OpenLayers.Renderer.Elements = OpenLayers.Class.create(); -OpenLayers.Renderer.Elements.prototype = - OpenLayers.Class.inherit(OpenLayers.Renderer, { - - /** @type DOMElement */ - rendererRoot: null, - - /** @type DOMElement */ - root: null, - - /** @type String */ - xmlns: null, - - /** - * @constructor - * - * @param {String} containerID - */ - initialize: function(containerID) { - OpenLayers.Renderer.prototype.initialize.apply(this, arguments); - - this.rendererRoot = this.createRenderRoot(); - this.root = this.createRoot(); - - this.rendererRoot.appendChild(this.root); - this.container.appendChild(this.rendererRoot); - }, - - /** - * - */ - destroy: function() { - - this.clear(); - - this.rendererRoot = null; - this.root = null; - this.xmlns = null; - - OpenLayers.Renderer.prototype.destroy.apply(this, arguments); - }, - - /** - * Remove all the elements from the root - * - */ - clear: function() { - if (this.root) { - while (this.root.childNodes.length > 0) { - this.root.removeChild(this.root.firstChild); - } - } - }, - - /** - * Cycle through the rendered nodes and reproject them (this should be - * called when the extent or size has changed); - * - * @param {OpenLayers.Bounds} extent - */ - reproject: function(extent) { - - for (var i = 0; i < this.root.childNodes.length; i++) { - var node = this.root.childNodes[i]; - //reproject node - // for the moment, this only really happens so as to reset - // the heaviness of the line relative to the resolution and - // the size of the circle for the Point object - this.reprojectNode(node); - } - }, - - /** This function is in charge of asking the specific renderer which type - * of node to create for the given geometry. All geometries in an - * Elements-based renderer consist of one node and some attributes. We - * have the nodeFactory() function which creates a node for us, but it - * takes a 'type' as input, and that is precisely what this function - * tells us. - * - * @param geometry {OpenLayers.Geometry} - * - * @returns The corresponding node type for the specified geometry - * @type String - */ - getNodeType: function(geometry) { }, - - /** - * Draw the geometry on the specified layer, creating new nodes, - * setting paths, setting style. - * - * @param {OpenLayers.Geometry} geometry - * @param {Object} style - */ - drawGeometry: function(geometry, style) { - - if ((geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") || - (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString") || - (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon")) { - for (var i = 0; i < geometry.components.length; i++) { - this.drawGeometry(geometry.components[i], style); - } - return; - }; - - //first we create the basic node and add it to the root - var nodeType = this.getNodeType(geometry); - var node = this.nodeFactory(geometry.id, nodeType, geometry); - node.geometry = geometry; - node.olStyle = style; - this.root.appendChild(node); - - //now actually draw the node, and style it - this.drawGeometryNode(node); - }, - - /** - * Given a node, draw a geometry on the specified layer. - * - * @param {DOMElement} node - * @param {OpenLayers.Geometry} geometry - * @param {Object} style - */ - drawGeometryNode: function(node, geometry, style) { - geometry = geometry || node.geometry; - style = style || node.olStyle; - - var options = { - 'isFilled': true, - 'isStroked': true - }; - switch (geometry.CLASS_NAME) { - case "OpenLayers.Geometry.Point": - this.drawPoint(node, geometry); - break; - case "OpenLayers.Geometry.Curve": - options.isFilled = false; - this.drawCurve(node, geometry); - break; - case "OpenLayers.Geometry.LineString": - options.isFilled = false; - this.drawLineString(node, geometry); - break; - case "OpenLayers.Geometry.LinearRing": - this.drawLinearRing(node, geometry); - break; - case "OpenLayers.Geometry.Polygon": - this.drawPolygon(node, geometry); - break; - case "OpenLayers.Geometry.Surface": - this.drawSurface(node, geometry); - break; - case "OpenLayers.Geometry.Rectangle": - this.drawRectangle(node, geometry); - break; - default: - break; - } - - node.olStyle = style; - node.olOptions = options; - - //set style - this.setStyle(node); - }, - - /** - * virtual functions for drawing different Geometries. - * These should all be implemented by subclasses. - * - * @param {DOMElement} node - * @param {OpenLayers.Geometry} geometry - */ - drawPoint: function(node, geometry) {}, - drawLineString: function(node, geometry) {}, - drawLinearRing: function(node, geometry) {}, - drawPolygon: function(node, geometry) {}, - drawRectangle: function(node, geometry) {}, - drawCircle: function(node, geometry) {}, - drawCurve: function(node, geometry) {}, - drawSurface: function(node, geometry) {}, - - /** - * @param evt {Object} an OpenLayers.Event object - * - * @returns A geometry from an event that happened on a layer - * @type OpenLayers.Geometry - */ - getGeometryFromEvent: function(evt) { - var node = evt.target || evt.srcElement; - var geometry = node.geometry ? node.geometry : null - return geometry; - }, - - /** Erase a geometry from the renderer. In the case of a multi-geometry, - * we cycle through and recurse on ourselves. Otherwise, we look for a - * node with the geometry.id, destroy its geometry, and remove it from - * the DOM. - * - * @param {OpenLayers.Geometry} geometry - */ - eraseGeometry: function(geometry) { - if ((geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") || - (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString") || - (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon")) { - for (var i = 0; i < geometry.components.length; i++) { - this.eraseGeometry(geometry.components[i]); - } - } else { - var element = $(geometry.id); - if (element && element.parentNode) { - if (element.geometry) { - element.geometry.destroy(); - element.geometry = null; - } - element.parentNode.removeChild(element); - } - } - }, - - /** - * @private - * - * Create new node of the specified type, with the (optional) specified id. - * - * If node already exists with same ID and type, we remove it and then - * call ourselves again to recreate it. - * - * @param {String} id - * @param {String} type Kind of node to draw - * @param {OpenLayers.Geometry} geometry - * - * @returns A new node of the given type and id - * @type DOMElement - */ - nodeFactory: function(id, type, geometry) { - var node = $(id); - if (node) { - if (!this.nodeTypeCompare(node, type)) { - node.parentNode.removeChild(node); - node = this.nodeFactory(id, type, geometry); - } - } else { - node = this.createNode(type, id); - } - return node; - }, - - /** @final @type String */ - CLASS_NAME: "OpenLayers.Renderer.Elements" -}); +/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license. + * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt + * for the full text of the license. */ + +/** + * @class + * + * This is another virtual class in that it should never be instantiated by + * itself as a Renderer. It exists because there is *tons* of shared + * functionality between different vector libraries which use nodes/elements + * as a base for rendering vectors. + * + * The highlevel bits of code that are implemented here are the adding and + * removing of geometries, which is essentially the same for any + * element-based renderer. The details of creating each node and drawing the + * paths are of course different, but the machinery is the same. + * + * @requires OpenLayers/Renderer.js + */ +OpenLayers.Renderer.Elements = OpenLayers.Class.create(); +OpenLayers.Renderer.Elements.prototype = + OpenLayers.Class.inherit(OpenLayers.Renderer, { + + /** @type DOMElement */ + rendererRoot: null, + + /** @type DOMElement */ + root: null, + + /** @type String */ + xmlns: null, + + /** + * @constructor + * + * @param {String} containerID + */ + initialize: function(containerID) { + OpenLayers.Renderer.prototype.initialize.apply(this, arguments); + + this.rendererRoot = this.createRenderRoot(); + this.root = this.createRoot(); + + this.rendererRoot.appendChild(this.root); + this.container.appendChild(this.rendererRoot); + }, + + /** + * + */ + destroy: function() { + + this.clear(); + + this.rendererRoot = null; + this.root = null; + this.xmlns = null; + + OpenLayers.Renderer.prototype.destroy.apply(this, arguments); + }, + + /** + * Remove all the elements from the root + * + */ + clear: function() { + if (this.root) { + while (this.root.childNodes.length > 0) { + this.root.removeChild(this.root.firstChild); + } + } + }, + + /** + * Cycle through the rendered nodes and reproject them (this should be + * called when the extent or size has changed); + * + * @param {OpenLayers.Bounds} extent + */ + reproject: function(extent) { + + for (var i = 0; i < this.root.childNodes.length; i++) { + var node = this.root.childNodes[i]; + //reproject node + // for the moment, this only really happens so as to reset + // the heaviness of the line relative to the resolution and + // the size of the circle for the Point object + this.reprojectNode(node); + } + }, + + /** This function is in charge of asking the specific renderer which type + * of node to create for the given geometry. All geometries in an + * Elements-based renderer consist of one node and some attributes. We + * have the nodeFactory() function which creates a node for us, but it + * takes a 'type' as input, and that is precisely what this function + * tells us. + * + * @param geometry {OpenLayers.Geometry} + * + * @returns The corresponding node type for the specified geometry + * @type String + */ + getNodeType: function(geometry) { }, + + /** + * Draw the geometry on the specified layer, creating new nodes, + * setting paths, setting style. + * + * @param {OpenLayers.Geometry} geometry + * @param {Object} style + */ + drawGeometry: function(geometry, style) { + + if ((geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") || + (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString") || + (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon")) { + for (var i = 0; i < geometry.components.length; i++) { + this.drawGeometry(geometry.components[i], style); + } + return; + }; + + //first we create the basic node and add it to the root + var nodeType = this.getNodeType(geometry); + var node = this.nodeFactory(geometry.id, nodeType, geometry); + node.geometry = geometry; + node.olStyle = style; + this.root.appendChild(node); + + //now actually draw the node, and style it + this.drawGeometryNode(node); + }, + + /** + * Given a node, draw a geometry on the specified layer. + * + * @param {DOMElement} node + * @param {OpenLayers.Geometry} geometry + * @param {Object} style + */ + drawGeometryNode: function(node, geometry, style) { + geometry = geometry || node.geometry; + style = style || node.olStyle; + + var options = { + 'isFilled': true, + 'isStroked': true + }; + switch (geometry.CLASS_NAME) { + case "OpenLayers.Geometry.Point": + this.drawPoint(node, geometry); + break; + case "OpenLayers.Geometry.Curve": + options.isFilled = false; + this.drawCurve(node, geometry); + break; + case "OpenLayers.Geometry.LineString": + options.isFilled = false; + this.drawLineString(node, geometry); + break; + case "OpenLayers.Geometry.LinearRing": + this.drawLinearRing(node, geometry); + break; + case "OpenLayers.Geometry.Polygon": + this.drawPolygon(node, geometry); + break; + case "OpenLayers.Geometry.Surface": + this.drawSurface(node, geometry); + break; + case "OpenLayers.Geometry.Rectangle": + this.drawRectangle(node, geometry); + break; + default: + break; + } + + node.olStyle = style; + node.olOptions = options; + + //set style + this.setStyle(node); + }, + + /** + * virtual functions for drawing different Geometries. + * These should all be implemented by subclasses. + * + * @param {DOMElement} node + * @param {OpenLayers.Geometry} geometry + */ + drawPoint: function(node, geometry) {}, + drawLineString: function(node, geometry) {}, + drawLinearRing: function(node, geometry) {}, + drawPolygon: function(node, geometry) {}, + drawRectangle: function(node, geometry) {}, + drawCircle: function(node, geometry) {}, + drawCurve: function(node, geometry) {}, + drawSurface: function(node, geometry) {}, + + /** + * @param evt {Object} an OpenLayers.Event object + * + * @returns A geometry from an event that happened on a layer + * @type OpenLayers.Geometry + */ + getGeometryFromEvent: function(evt) { + var node = evt.target || evt.srcElement; + var geometry = node.geometry ? node.geometry : null + return geometry; + }, + + /** Erase a geometry from the renderer. In the case of a multi-geometry, + * we cycle through and recurse on ourselves. Otherwise, we look for a + * node with the geometry.id, destroy its geometry, and remove it from + * the DOM. + * + * @param {OpenLayers.Geometry} geometry + */ + eraseGeometry: function(geometry) { + if ((geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPoint") || + (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiLineString") || + (geometry.CLASS_NAME == "OpenLayers.Geometry.MultiPolygon")) { + for (var i = 0; i < geometry.components.length; i++) { + this.eraseGeometry(geometry.components[i]); + } + } else { + var element = $(geometry.id); + if (element && element.parentNode) { + if (element.geometry) { + element.geometry.destroy(); + element.geometry = null; + } + element.parentNode.removeChild(element); + } + } + }, + + /** + * @private + * + * Create new node of the specified type, with the (optional) specified id. + * + * If node already exists with same ID and type, we remove it and then + * call ourselves again to recreate it. + * + * @param {String} id + * @param {String} type Kind of node to draw + * @param {OpenLayers.Geometry} geometry + * + * @returns A new node of the given type and id + * @type DOMElement + */ + nodeFactory: function(id, type, geometry) { + var node = $(id); + if (node) { + if (!this.nodeTypeCompare(node, type)) { + node.parentNode.removeChild(node); + node = this.nodeFactory(id, type, geometry); + } + } else { + node = this.createNode(type, id); + } + return node; + }, + + /** @final @type String */ + CLASS_NAME: "OpenLayers.Renderer.Elements" +}); diff --git a/tests/Layer/test_MapServer.html b/tests/Layer/test_MapServer.html index 259961d83c..3dbd5de227 100644 --- a/tests/Layer/test_MapServer.html +++ b/tests/Layer/test_MapServer.html @@ -1,234 +1,249 @@ - - - Z - - - - - - -
- - + + + Z + + + + + + +
+ + diff --git a/tests/Layer/test_MapServer_Untiled.html b/tests/Layer/test_MapServer_Untiled.html index b9191c8c8e..148d3fd7d8 100644 --- a/tests/Layer/test_MapServer_Untiled.html +++ b/tests/Layer/test_MapServer_Untiled.html @@ -1,163 +1,163 @@ - -A - - - - - -
- - + +A + + + + + +
+ + diff --git a/tests/Layer/test_Vector.html b/tests/Layer/test_Vector.html index 32ebd938ff..97e50cf295 100644 --- a/tests/Layer/test_Vector.html +++ b/tests/Layer/test_Vector.html @@ -1,74 +1,74 @@ - - - - - - -
- - + + + + + + +
+ + diff --git a/tests/test_Format.html b/tests/test_Format.html index e81780cf48..8e42d956f4 100644 --- a/tests/test_Format.html +++ b/tests/test_Format.html @@ -1,21 +1,21 @@ - - - - - - - - + + + + + + + + diff --git a/tests/test_Geometry.html b/tests/test_Geometry.html index fa16b92258..443cb8d33c 100644 --- a/tests/test_Geometry.html +++ b/tests/test_Geometry.html @@ -1,212 +1,212 @@ - - - - - - -
- - + + + + + + +
+ + diff --git a/tests/test_Renderer.html b/tests/test_Renderer.html index aa490e4df9..8ee82425cc 100644 --- a/tests/test_Renderer.html +++ b/tests/test_Renderer.html @@ -1,166 +1,166 @@ - - - - - - -
- - + + + + + + +
+ +