Changeset 1929
- Timestamp:
- 11/19/06 17:01:51 (2 years ago)
- Files:
-
- sandbox/vector/examples/vector.html (modified) (3 diffs)
- sandbox/vector/lib/OpenLayers.js (modified) (1 diff)
- sandbox/vector/lib/OpenLayers/Control.js (modified) (1 diff)
- sandbox/vector/lib/OpenLayers/Control/EditingTool/Selection.js (modified) (5 diffs)
- sandbox/vector/lib/OpenLayers/Geometry/Curve.js (modified) (3 diffs)
- sandbox/vector/lib/OpenLayers/Renderer/Svg.js (modified) (2 diffs)
- sandbox/vector/lib/OpenLayers/Style.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/vector/examples/vector.html
r1892 r1929 17 17 function init() { 18 18 //console.log(OpenLayers.Event); 19 19 var info = new OpenLayers.Control.EditingAttributes(); 20 20 21 var toolbar = new OpenLayers.Control.EditingToolbar(); 21 22 var navigation = new OpenLayers.Control.MouseDefaults(); 22 var selection = new OpenLayers.Control.EditingTool.Selection(); 23 24 // the info is an option of the selection. 25 var selection = new OpenLayers.Control.EditingTool.Selection({attributesControl: info}); 26 23 27 var drawPoint = new OpenLayers.Control.EditingTool.DrawPoint(); 24 28 var drawLineString = new OpenLayers.Control.EditingTool.DrawLineString(); … … 30 34 var map = new OpenLayers.Map('map', {controls: [ 31 35 toolbar, 36 info, 32 37 new OpenLayers.Control.LayerSwitcher(), 33 38 new OpenLayers.Control.PanZoom() … … 52 57 53 58 var feature = new OpenLayers.Feature(); 59 feature.addAttributes([{label: "test1", value: "essais réussi"}, {label: "test2", value: "encore mieux"}]); 60 61 54 62 feature.setGeometry(linearRing); 55 63 vector.addFeatures(feature); sandbox/vector/lib/OpenLayers.js
r1895 r1929 122 122 "OpenLayers/Geometry/Surface.js", 123 123 "OpenLayers/Geometry/Polygon.js", 124 "OpenLayers/Geometry/Rectangle.js", 124 125 "OpenLayers/Geometry/Aggregate.js", 125 126 "OpenLayers/Renderer.js", sandbox/vector/lib/OpenLayers/Control.js
r1889 r1929 33 33 initialize: function (options) { 34 34 OpenLayers.Util.extend(this, options); 35 36 35 this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 37 36 }, sandbox/vector/lib/OpenLayers/Control/EditingTool/Selection.js
r1916 r1929 18 18 size: new OpenLayers.Size(22,40), 19 19 20 /** @type OpenLayers.Control.EditingAttributes */ 21 attributesControl: null, 22 20 23 /** 21 24 * @constructor … … 26 29 OpenLayers.Control.EditingTool.prototype.initialize.apply(this, arguments); 27 30 this.style = OpenLayers.Style.DefaultRendererSelectionStyle; 31 28 32 }, 29 33 … … 80 84 OpenLayers.Control.EditingTool.prototype.defaultMouseDown.apply(this, arguments); 81 85 86 87 // Display Feature attributes 88 if(this.attributesControl && evt.targetGeometry.feature.attributes) { 89 this.attributesControl.setContent(evt.targetGeometry.feature.attributes); 90 } 91 82 92 this.eraseTmpElements(); 83 93 84 // Point & ControlPoint selection 85 if (evt.targetGeometry && evt.targetGeometry.CLASS_NAME == "OpenLayers.Geometry.Point"){ 86 87 // Add a point to the selection 88 if (this.shiftDown) { 89 90 // Verify if the point is selected 91 if (OpenLayers.Util.indexOf(this.points, evt.targetGeometry) < 0){ 92 this.points.push(evt.targetGeometry); 93 this.layer.renderer.drawGeometry(evt.targetGeometry, this.style); 94 95 // UnSelect the point 96 } else { 97 this.points = OpenLayers.Util.removeItem(this.points, evt.targetGeometry); 98 this.layer.renderer.drawGeometry(evt.targetGeometry, this.layer.style); 99 } 100 101 // Unselect the point 102 } else { 103 for(var i=0; i<this.points.length; i++) { 104 this.layer.renderer.drawGeometry(this.points[i], this.layer.style); 105 } 106 107 if(evt.targetGeometry != undefined) 108 this.points = [evt.targetGeometry]; 109 this.layer.renderer.drawGeometry(evt.targetGeometry, this.style); 110 } 111 112 // Geometry selection 113 } else if (evt.targetGeometry && !evt.targetGeometry.isSnappingSegment){ 94 // Geometry Selection 95 if (evt.targetGeometry && !evt.targetGeometry.isSnappingSegment){ 114 96 115 97 this.eraseTmpElements(); … … 121 103 if (OpenLayers.Util.indexOf(this.layer.selection, evt.targetGeometry.feature) < 0){ 122 104 this.layer.selection.push(evt.targetGeometry.feature); 123 124 105 // UnSelect the geometry 125 106 } else { … … 130 111 } else { 131 112 this.layer.selection = [evt.targetGeometry.feature]; 132 } 133 134 this.drawTmpElements(); 135 136 // initialize the point selection. useful to translate a geometry or a part of a geometry 137 this.points = []; 138 for(var iSelection = 0; iSelection < this.layer.selection.length; iSelection++) { 139 if (this.layer.selection.CLASS_NAME == "OpenLayers.Geometry.Point") { 140 this.points = this.points.push(this.layer.selection[iSelection].geometry); 141 } else { 142 this.points = this.points.concat(this.layer.selection[iSelection].geometry.path); 143 } 144 } 145 146 // Unselection 147 } else { 148 if (!this.shiftDown){ 149 this.layer.selection = []; 150 this.points = []; 113 this.layer.renderer.drawRectangle(evt.targetGeometry.getBoundingBox(), this.style); 151 114 } 152 115 } sandbox/vector/lib/OpenLayers/Geometry/Curve.js
r1918 r1929 29 29 } 30 30 31 this.getBoundingBox(); 31 this.bbox = new OpenLayers.Geometry.Rectangle(); 32 this.bbox.geometry = this; 32 33 }, 33 34 … … 36 37 * @type OpenLayers.Bounds 37 38 */ 39 38 40 getBoundingBox: function(){ 39 41 if (this.path.length > 0) { … … 55 57 } 56 58 57 this.extent = new OpenLayers.Bounds(xmin, ymin, xmax, ymax); 58 59 return this.extent; 60 } 59 this.bbox.x = xmin; 60 this.bbox.y = ymin; 61 this.bbox.width = xmax - xmin; 62 this.bbox.height = ymax - ymin; 63 return this.bbox; 64 } 61 65 }, 62 66 sandbox/vector/lib/OpenLayers/Renderer/Svg.js
r1899 r1929 191 191 */ 192 192 drawPolygon: function(geometry, style) { 193 var node = this._nodeFactory("polygon", id);193 var node = this._nodeFactory("polygon", geometry.id); 194 194 node.geometry = geometry; 195 195 node.setAttributeNS(null, "points", geometry.path); … … 206 206 * @param style {Style} a style to use when drawing 207 207 */ 208 drawRectangle: function(geometry, style) {}, 208 drawRectangle: function(geometry, style) { 209 var node = this._nodeFactory("rect", geometry.id); 210 node.geometry = geometry; 211 node.setAttributeNS(null, "x", geometry.x); 212 node.setAttributeNS(null, "y", geometry.y); 213 node.setAttributeNS(null, "width", geometry.width); 214 node.setAttributeNS(null, "height", geometry.height); 215 this._setStyle(node, style, true, true); 216 this.root.appendChild(node); 217 }, 209 218 210 219 /** sandbox/vector/lib/OpenLayers/Style.js
r1922 r1929 72 72 }); 73 73 OpenLayers.Style.DefaultRendererSelectionStyle = new OpenLayers.Style({ 74 fillColor: "green", 75 fillOpacity: 1, 76 strokeColor: "yellow", 74 fillOpacity: 0, 75 strokeColor: "grey", 77 76 strokeOpacity: 1, 78 strokeWidth: 0. 2,77 strokeWidth: 0.1, 79 78 strokeUnit: "%", 80 79 pointRadius: 1,
