Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / Dimension.js
1 Clazz.declarePackage ("java.awt");
2 Clazz.load (["java.awt.geom.Dimension2D"], "java.awt.Dimension", null, function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.width = 0;
5 this.height = 0;
6 Clazz.instantialize (this, arguments);
7 }, java.awt, "Dimension", java.awt.geom.Dimension2D);
8 Clazz.makeConstructor (c$, 
9 function () {
10 this.construct (0, 0);
11 });
12 Clazz.makeConstructor (c$, 
13 function (d) {
14 this.construct (d.width, d.height);
15 }, "java.awt.Dimension");
16 Clazz.makeConstructor (c$, 
17 function (width, height) {
18 Clazz.superConstructor (this, java.awt.Dimension, []);
19 this.width = width;
20 this.height = height;
21 }, "~N,~N");
22 Clazz.overrideMethod (c$, "getWidth", 
23 function () {
24 return this.width;
25 });
26 Clazz.overrideMethod (c$, "getHeight", 
27 function () {
28 return this.height;
29 });
30 Clazz.defineMethod (c$, "setSize", 
31 function (width, height) {
32 this.width = Clazz.doubleToInt (Math.ceil (width));
33 this.height = Clazz.doubleToInt (Math.ceil (height));
34 }, "~N,~N");
35 Clazz.defineMethod (c$, "getSize", 
36 function () {
37 return  new java.awt.Dimension (this.width, this.height);
38 });
39 Clazz.defineMethod (c$, "setSize", 
40 function (d) {
41 this.setSize (d.width, d.height);
42 }, "java.awt.Dimension");
43 Clazz.defineMethod (c$, "setSize", 
44 function (width, height) {
45 this.width = width;
46 this.height = height;
47 }, "~N,~N");
48 Clazz.overrideMethod (c$, "equals", 
49 function (obj) {
50 if (Clazz.instanceOf (obj, java.awt.Dimension)) {
51 var d = obj;
52 return (this.width == d.width) && (this.height == d.height);
53 }return false;
54 }, "~O");
55 Clazz.overrideMethod (c$, "hashCode", 
56 function () {
57 var sum = this.width + this.height;
58 return Clazz.doubleToInt (sum * (sum + 1) / 2) + this.width;
59 });
60 Clazz.overrideMethod (c$, "toString", 
61 function () {
62 return this.getClass ().getName () + "[width=" + this.width + ",height=" + this.height + "]";
63 });
64 });