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