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