1
|
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
2
|
* full list of contributors). Published under the 2-clause BSD license.
|
3
|
* See license.txt in the OpenLayers distribution or repository for the
|
4
|
* full text of the license. */
|
5
|
|
6
|
/**
|
7
|
* @requires OpenLayers/BaseTypes/Class.js
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Class: OpenLayers.Size
|
12
|
* Instances of this class represent a width/height pair
|
13
|
*/
|
14
|
OpenLayers.Size = OpenLayers.Class({
|
15
|
|
16
|
/**
|
17
|
* APIProperty: w
|
18
|
* {Number} width
|
19
|
*/
|
20
|
w: 0.0,
|
21
|
|
22
|
/**
|
23
|
* APIProperty: h
|
24
|
* {Number} height
|
25
|
*/
|
26
|
h: 0.0,
|
27
|
|
28
|
|
29
|
/**
|
30
|
* Constructor: OpenLayers.Size
|
31
|
* Create an instance of OpenLayers.Size
|
32
|
*
|
33
|
* Parameters:
|
34
|
* w - {Number} width
|
35
|
* h - {Number} height
|
36
|
*/
|
37
|
initialize: function(w, h) {
|
38
|
this.w = parseFloat(w);
|
39
|
this.h = parseFloat(h);
|
40
|
},
|
41
|
|
42
|
/**
|
43
|
* Method: toString
|
44
|
* Return the string representation of a size object
|
45
|
*
|
46
|
* Returns:
|
47
|
* {String} The string representation of OpenLayers.Size object.
|
48
|
* (e.g. <i>"w=55,h=66"</i>)
|
49
|
*/
|
50
|
toString:function() {
|
51
|
return ("w=" + this.w + ",h=" + this.h);
|
52
|
},
|
53
|
|
54
|
/**
|
55
|
* APIMethod: clone
|
56
|
* Create a clone of this size object
|
57
|
*
|
58
|
* Returns:
|
59
|
* {<OpenLayers.Size>} A new OpenLayers.Size object with the same w and h
|
60
|
* values
|
61
|
*/
|
62
|
clone:function() {
|
63
|
return new OpenLayers.Size(this.w, this.h);
|
64
|
},
|
65
|
|
66
|
/**
|
67
|
*
|
68
|
* APIMethod: equals
|
69
|
* Determine where this size is equal to another
|
70
|
*
|
71
|
* Parameters:
|
72
|
* sz - {<OpenLayers.Size>|Object} An OpenLayers.Size or an object with
|
73
|
* a 'w' and 'h' properties.
|
74
|
*
|
75
|
* Returns:
|
76
|
* {Boolean} The passed in size has the same h and w properties as this one.
|
77
|
* Note that if sz passed in is null, returns false.
|
78
|
*/
|
79
|
equals:function(sz) {
|
80
|
var equals = false;
|
81
|
if (sz != null) {
|
82
|
equals = ((this.w == sz.w && this.h == sz.h) ||
|
83
|
(isNaN(this.w) && isNaN(this.h) && isNaN(sz.w) && isNaN(sz.h)));
|
84
|
}
|
85
|
return equals;
|
86
|
},
|
87
|
|
88
|
CLASS_NAME: "OpenLayers.Size"
|
89
|
});
|