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