diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 41edef870c..b60173f01c 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -41,9 +41,18 @@ OpenLayers.Pixel.prototype = { }, /** - * @type OpenLayers.Pixel - */ + * @deprecated + * + * @type OpenLayers.Pixel + */ copyOf:function() { + return this.clone(); + }, + + /** + * @type OpenLayers.Pixel + */ + clone:function() { return new OpenLayers.Pixel(this.x, this.y); }, @@ -124,10 +133,20 @@ OpenLayers.Size.prototype = { }, /** - * @return New OpenLayers.Size object with the same w and h values - * @type OpenLayers.Size - */ + * @deprecated + * + * @return New OpenLayers.Size object with the same w and h values + * @type OpenLayers.Size + */ copyOf:function() { + return this.clone(); + }, + + /** + * @return New OpenLayers.Size object with the same w and h values + * @type OpenLayers.Size + */ + clone:function() { return new OpenLayers.Size(this.w, this.h); }, @@ -193,10 +212,20 @@ OpenLayers.LonLat.prototype = { }, /** - * @return New OpenLayers.LonLat object with the same lon and lat values - * @type OpenLayers.LonLat - */ + * @deprecated + * + * @return New OpenLayers.LonLat object with the same lon and lat values + * @type OpenLayers.LonLat + */ copyOf:function() { + return this.clone(); + }, + + /** + * @return New OpenLayers.LonLat object with the same lon and lat values + * @type OpenLayers.LonLat + */ + clone:function() { return new OpenLayers.LonLat(this.lon, this.lat); }, @@ -288,10 +317,20 @@ OpenLayers.Bounds.prototype = { }, /** - * @returns A fresh copy of the bounds - * @type OpenLayers.Bounds - */ + * @deprecated + * + * @returns A fresh copy of the bounds + * @type OpenLayers.Bounds + */ copyOf:function() { + return this.clone(); + }, + + /** + * @returns A fresh copy of the bounds + * @type OpenLayers.Bounds + */ + clone:function() { return new OpenLayers.Bounds(this.left, this.bottom, this.right, this.top); }, @@ -609,16 +648,26 @@ Array.prototype.remove = function(item) { return this; } +/** + * @deprecated + * + * @returns A fresh copy of the array + * @type Array + */ +Array.prototype.copyOf = function() { + return this.clone(); +}; + /** * @returns A fresh copy of the array * @type Array */ -Array.prototype.copyOf = function() { - var copy = new Array(); +Array.prototype.clone = function() { + var clone = new Array(); for (var i = 0; i < this.length; i++) { - copy[i] = this[i]; + clone[i] = this[i]; } - return copy; + return clone; }; /**