Changeset 1789
- Timestamp:
- 11/09/06 09:07:09 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/bertil/lib/OpenLayers/Feature/Geometry/Aggregate.js
r1775 r1789 1 /* Copyright (c) 2006 CampToCamp SA, Bertil Chapuis, published under the BSD license. */ 1 /* Copyright (c) 2006 CampToCamp SA, Bertil Chapuis, Pierre Giraud, 2 * published under the BSD license. */ 2 3 4 /** 5 * @class 6 */ 3 7 OpenLayers.Feature.Geometry.Aggregate = function() {} 4 8 OpenLayers.Feature.Geometry.Aggregate.prototype = { 5 9 10 /** 11 * @returns the components of the geometry 12 */ 6 13 getComponents: function(){ 7 return this.components ?this.components:null;14 return this.components ? this.components : null; 8 15 }, 9 16 10 17 addComponents: function(components){ 11 if(!(components instanceof Array)) {12 components = [components];13 }18 if(!(components instanceof Array)) { 19 components = [components]; 20 } 14 21 15 if(this.components) {16 this.components = this.components.concat(components);17 } else {18 this.components = [].concat(components);19 }22 if(this.components) { 23 this.components = this.components.concat(components); 24 } else { 25 this.components = [].concat(components); 26 } 20 27 }, 21 28 22 removeComponents: function(components){ 23 if(!(components instanceof Array)) 24 components = [components]; 25 26 for (var i = 0; i < components.length; i++) { 27 this.components = this.components.without(components[i]); 28 } 29 removeComponents: function(components) { 30 if(!(components instanceof Array)) { 31 components = [components]; 32 } 33 34 for (var i = 0; i < components.length; i++) { 35 this.components = this.components.without(components[i]); 36 } 29 37 }, 30 38 31 addSupportedComponents: function(classes){ 32 if(!(classes instanceof Array)) 33 classes = [classes]; 34 35 if(this.SupportedComponents) 36 this.SupportedComponents = this.SupportedComponents.concat(classes); 37 else 38 this.SupportedComponents = [].concat(classes); 39 addSupportedComponents: function(classes) { 40 if(!(classes instanceof Array)) { 41 classes = [classes]; 42 } 43 44 if(this.SupportedComponents) { 45 this.SupportedComponents = this.SupportedComponents.concat(classes); 46 } else { 47 this.SupportedComponents = [].concat(classes); 39 48 }, 40 49 41 removeSupportedComponents: function(classes) {42 if(!(classes instanceof Array)) 43 classes = [classes];44 45 for (var i = 0; i < classes.length; i++) {46 this.SupportedComponents = this.SupportedComponents.without(classes[i]);47 }50 removeSupportedComponents: function(classes) { 51 if(!(classes instanceof Array)) { 52 classes = [classes]; 53 } 54 for (var i = 0; i < classes.length; i++) { 55 this.SupportedComponents = this.SupportedComponents.without(classes[i]); 56 } 48 57 }, 49 58 sandbox/bertil/lib/OpenLayers/Feature/Geometry/Curve.js
r1777 r1789 1 /* Copyright (c) 2006 CampToCamp SA, Bertil Chapuis, published under the BSD license. */ 1 /* Copyright (c) 2006 CampToCamp SA, Bertil Chapuis, Pierre Giraud, 2 * published under the BSD license. */ 3 4 // @requires OpenLayers/Feature/Geometry.js 5 /** 6 * @class 7 */ 8 OpenLayers.Feature.Geometry.Curve = OpenLayers.Class.create(); 9 OpenLayers.Feature.Geometry.Curve.prototype = 10 OpenLayers.Util.extend(OpenLayers.Feature.Geometry.Curve.prototype, 11 OpenLayers.Feature.Geometry.prototype); 12 OpenLayers.Feature.Geometry.Curve.prototype = 13 OpenLayers.Util.extend(OpenLayers.Feature.Geometry.Curve.prototype, { 2 14 3 OpenLayers.Feature.Geometry.Curve = OpenLayers.Class.create();4 OpenLayers.Feature.Geometry.Curve.prototype = OpenLayers.Util.extend(OpenLayers.Feature.Geometry.Curve.prototype, OpenLayers.Feature.Geometry.prototype);5 OpenLayers.Feature.Geometry.Curve.prototype = OpenLayers.Util.extend(OpenLayers.Feature.Geometry.Curve.prototype, {6 15 16 /** 17 * @constructor 18 * 19 * @param {array} points 20 */ 7 21 initialize: function(points) { 8 22 OpenLayers.Feature.Geometry.prototype.initialize.apply(this, arguments); … … 19 33 }, 20 34 35 /** 36 * @returns the extent of the geometry 37 * @type OpenLayers.Bounds 38 */ 21 39 getBoundingBox: function(){ 22 40 if (this.path.length > 0) { 23 // compute the extent of the geometry24 41 var xmin, ymin, xmax, ymax = null; 25 42 this.path.each(function(point) { … … 43 60 } 44 61 }, 45 62 63 /** 64 * Adds a point to geometry path at the given index (optional) 65 * or a the end of the path 66 * 67 * @param {OpenLayers.Feature.Geometry.Point} point 68 * @param {int} index 69 */ 46 70 addPoint: function(point, index) { 47 71 if(point && point.CLASS_NAME == "OpenLayers.Feature.Geometry.Point"){ … … 54 78 }, 55 79 80 /** 81 * @param Point 82 */ 56 83 removePoint: function(point){ 57 84 this.path = this.path.without(point);
