JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / java / awt / Insets.js
1 Clazz.declarePackage ("java.awt");\r
2 Clazz.load (null, "java.awt.Insets", ["java.lang.InternalError"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.top = 0;\r
5 this.left = 0;\r
6 this.bottom = 0;\r
7 this.right = 0;\r
8 Clazz.instantialize (this, arguments);\r
9 }, java.awt, "Insets", null, [Cloneable, java.io.Serializable]);\r
10 Clazz.makeConstructor (c$, \r
11 function (top, left, bottom, right) {\r
12 this.top = top;\r
13 this.left = left;\r
14 this.bottom = bottom;\r
15 this.right = right;\r
16 }, "~N,~N,~N,~N");\r
17 Clazz.defineMethod (c$, "set", \r
18 function (top, left, bottom, right) {\r
19 this.top = top;\r
20 this.left = left;\r
21 this.bottom = bottom;\r
22 this.right = right;\r
23 }, "~N,~N,~N,~N");\r
24 Clazz.overrideMethod (c$, "equals", \r
25 function (obj) {\r
26 if (Clazz.instanceOf (obj, java.awt.Insets)) {\r
27 var insets = obj;\r
28 return ((this.top == insets.top) && (this.left == insets.left) && (this.bottom == insets.bottom) && (this.right == insets.right));\r
29 }return false;\r
30 }, "~O");\r
31 Clazz.overrideMethod (c$, "hashCode", \r
32 function () {\r
33 var sum1 = this.left + this.bottom;\r
34 var sum2 = this.right + this.top;\r
35 var val1 = Clazz.doubleToInt (sum1 * (sum1 + 1) / 2) + this.left;\r
36 var val2 = Clazz.doubleToInt (sum2 * (sum2 + 1) / 2) + this.top;\r
37 var sum3 = val1 + val2;\r
38 return Clazz.doubleToInt (sum3 * (sum3 + 1) / 2) + val2;\r
39 });\r
40 Clazz.overrideMethod (c$, "toString", \r
41 function () {\r
42 return this.getClass ().getName () + "[top=" + this.top + ",left=" + this.left + ",bottom=" + this.bottom + ",right=" + this.right + "]";\r
43 });\r
44 Clazz.defineMethod (c$, "clone", \r
45 function () {\r
46 try {\r
47 return Clazz.superCall (this, java.awt.Insets, "clone", []);\r
48 } catch (e) {\r
49 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {\r
50 throw  new InternalError ();\r
51 } else {\r
52 throw e;\r
53 }\r
54 }\r
55 });\r
56 });\r