1 Clazz.declarePackage ("java.awt.geom");
2 Clazz.load (["java.awt.Shape"], "java.awt.geom.Line2D", ["java.lang.InternalError", "java.awt.geom.LineIterator", "$.Point2D", "$.Rectangle2D"], function () {
3 c$ = Clazz.declareType (java.awt.geom, "Line2D", null, [java.awt.Shape, Cloneable]);
4 Clazz.makeConstructor (c$,
7 Clazz.defineMethod (c$, "setLine",
9 this.setLine (p1.getX (), p1.getY (), p2.getX (), p2.getY ());
10 }, "java.awt.geom.Point2D,java.awt.geom.Point2D");
11 Clazz.defineMethod (c$, "setLine",
13 this.setLine (l.getX1 (), l.getY1 (), l.getX2 (), l.getY2 ());
14 }, "java.awt.geom.Line2D");
15 c$.relativeCCW = Clazz.defineMethod (c$, "relativeCCW",
16 function (x1, y1, x2, y2, px, py) {
21 var ccw = px * y2 - py * x2;
23 ccw = px * x2 + py * y2;
27 ccw = px * x2 + py * y2;
30 }}}return (ccw < 0.0) ? -1 : ((ccw > 0.0) ? 1 : 0);
31 }, "~N,~N,~N,~N,~N,~N");
32 Clazz.defineMethod (c$, "relativeCCW",
34 return java.awt.geom.Line2D.relativeCCW (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), px, py);
36 Clazz.defineMethod (c$, "relativeCCW",
38 return java.awt.geom.Line2D.relativeCCW (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), p.getX (), p.getY ());
39 }, "java.awt.geom.Point2D");
40 c$.linesIntersect = Clazz.defineMethod (c$, "linesIntersect",
41 function (x1, y1, x2, y2, x3, y3, x4, y4) {
42 return ((java.awt.geom.Line2D.relativeCCW (x1, y1, x2, y2, x3, y3) * java.awt.geom.Line2D.relativeCCW (x1, y1, x2, y2, x4, y4) <= 0) && (java.awt.geom.Line2D.relativeCCW (x3, y3, x4, y4, x1, y1) * java.awt.geom.Line2D.relativeCCW (x3, y3, x4, y4, x2, y2) <= 0));
43 }, "~N,~N,~N,~N,~N,~N,~N,~N");
44 Clazz.defineMethod (c$, "intersectsLine",
45 function (x1, y1, x2, y2) {
46 return java.awt.geom.Line2D.linesIntersect (x1, y1, x2, y2, this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 ());
48 Clazz.defineMethod (c$, "intersectsLine",
50 return java.awt.geom.Line2D.linesIntersect (l.getX1 (), l.getY1 (), l.getX2 (), l.getY2 (), this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 ());
51 }, "java.awt.geom.Line2D");
52 c$.ptSegDistSq = Clazz.defineMethod (c$, "ptSegDistSq",
53 function (x1, y1, x2, y2, px, py) {
58 var dotprod = px * x2 + py * y2;
65 dotprod = px * x2 + py * y2;
69 projlenSq = dotprod * dotprod / (x2 * x2 + y2 * y2);
70 }}var lenSq = px * px + py * py - projlenSq;
74 }, "~N,~N,~N,~N,~N,~N");
75 c$.ptSegDist = Clazz.defineMethod (c$, "ptSegDist",
76 function (x1, y1, x2, y2, px, py) {
77 return Math.sqrt (java.awt.geom.Line2D.ptSegDistSq (x1, y1, x2, y2, px, py));
78 }, "~N,~N,~N,~N,~N,~N");
79 Clazz.defineMethod (c$, "ptSegDistSq",
81 return java.awt.geom.Line2D.ptSegDistSq (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), px, py);
83 Clazz.defineMethod (c$, "ptSegDistSq",
85 return java.awt.geom.Line2D.ptSegDistSq (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), pt.getX (), pt.getY ());
86 }, "java.awt.geom.Point2D");
87 Clazz.defineMethod (c$, "ptSegDist",
89 return java.awt.geom.Line2D.ptSegDist (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), px, py);
91 Clazz.defineMethod (c$, "ptSegDist",
93 return java.awt.geom.Line2D.ptSegDist (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), pt.getX (), pt.getY ());
94 }, "java.awt.geom.Point2D");
95 c$.ptLineDistSq = Clazz.defineMethod (c$, "ptLineDistSq",
96 function (x1, y1, x2, y2, px, py) {
101 var dotprod = px * x2 + py * y2;
102 var projlenSq = dotprod * dotprod / (x2 * x2 + y2 * y2);
103 var lenSq = px * px + py * py - projlenSq;
107 }, "~N,~N,~N,~N,~N,~N");
108 c$.ptLineDist = Clazz.defineMethod (c$, "ptLineDist",
109 function (x1, y1, x2, y2, px, py) {
110 return Math.sqrt (java.awt.geom.Line2D.ptLineDistSq (x1, y1, x2, y2, px, py));
111 }, "~N,~N,~N,~N,~N,~N");
112 Clazz.defineMethod (c$, "ptLineDistSq",
114 return java.awt.geom.Line2D.ptLineDistSq (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), px, py);
116 Clazz.defineMethod (c$, "ptLineDistSq",
118 return java.awt.geom.Line2D.ptLineDistSq (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), pt.getX (), pt.getY ());
119 }, "java.awt.geom.Point2D");
120 Clazz.defineMethod (c$, "ptLineDist",
122 return java.awt.geom.Line2D.ptLineDist (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), px, py);
124 Clazz.defineMethod (c$, "ptLineDist",
126 return java.awt.geom.Line2D.ptLineDist (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 (), pt.getX (), pt.getY ());
127 }, "java.awt.geom.Point2D");
128 Clazz.defineMethod (c$, "contains",
132 Clazz.defineMethod (c$, "contains",
135 }, "java.awt.geom.Point2D");
136 Clazz.defineMethod (c$, "intersects",
137 function (x, y, w, h) {
138 return this.intersects ( new java.awt.geom.Rectangle2D.Double (x, y, w, h));
140 Clazz.defineMethod (c$, "intersects",
142 return r.intersectsLine (this.getX1 (), this.getY1 (), this.getX2 (), this.getY2 ());
143 }, "java.awt.geom.Rectangle2D");
144 Clazz.defineMethod (c$, "contains",
145 function (x, y, w, h) {
148 Clazz.defineMethod (c$, "contains",
151 }, "java.awt.geom.Rectangle2D");
152 Clazz.overrideMethod (c$, "getBounds",
154 return this.getBounds2D ().getBounds ();
156 Clazz.defineMethod (c$, "getPathIterator",
158 return new java.awt.geom.LineIterator (this, at);
159 }, "java.awt.geom.AffineTransform");
160 Clazz.defineMethod (c$, "getPathIterator",
161 function (at, flatness) {
162 return new java.awt.geom.LineIterator (this, at);
163 }, "java.awt.geom.AffineTransform,~N");
164 Clazz.defineMethod (c$, "clone",
167 return Clazz.superCall (this, java.awt.geom.Line2D, "clone", []);
169 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
170 throw new InternalError ();
177 c$ = Clazz.decorateAsClass (function () {
182 Clazz.instantialize (this, arguments);
183 }, java.awt.geom.Line2D, "Float", java.awt.geom.Line2D);
184 Clazz.makeConstructor (c$,
186 Clazz.superConstructor (this, java.awt.geom.Line2D.Float, []);
188 Clazz.makeConstructor (c$,
189 function (a, b, c, d) {
190 Clazz.superConstructor (this, java.awt.geom.Line2D.Float, []);
191 this.setLine (a, b, c, d);
193 Clazz.makeConstructor (c$,
195 Clazz.superConstructor (this, java.awt.geom.Line2D.Float, []);
197 }, "java.awt.geom.Point2D,java.awt.geom.Point2D");
198 Clazz.overrideMethod (c$, "getX1",
202 Clazz.overrideMethod (c$, "getY1",
206 Clazz.overrideMethod (c$, "getP1",
208 return new java.awt.geom.Point2D.Float (this.x1, this.y1);
210 Clazz.overrideMethod (c$, "getX2",
214 Clazz.overrideMethod (c$, "getY2",
218 Clazz.overrideMethod (c$, "getP2",
220 return new java.awt.geom.Point2D.Float (this.x2, this.y2);
222 Clazz.defineMethod (c$, "setLine",
223 function (a, b, c, d) {
229 Clazz.defineMethod (c$, "setLine",
230 function (a, b, c, d) {
236 Clazz.overrideMethod (c$, "getBounds2D",
242 if (this.x1 < this.x2) {
244 c = this.x2 - this.x1;
247 c = this.x1 - this.x2;
248 }if (this.y1 < this.y2) {
250 d = this.y2 - this.y1;
253 d = this.y1 - this.y2;
254 }return new java.awt.geom.Rectangle2D.Float (a, b, c, d);
258 c$ = Clazz.decorateAsClass (function () {
263 Clazz.instantialize (this, arguments);
264 }, java.awt.geom.Line2D, "Double", java.awt.geom.Line2D);
265 Clazz.makeConstructor (c$,
267 Clazz.superConstructor (this, java.awt.geom.Line2D.Double, []);
269 Clazz.makeConstructor (c$,
270 function (a, b, c, d) {
271 Clazz.superConstructor (this, java.awt.geom.Line2D.Double, []);
272 this.setLine (a, b, c, d);
274 Clazz.makeConstructor (c$,
276 Clazz.superConstructor (this, java.awt.geom.Line2D.Double, []);
278 }, "java.awt.geom.Point2D,java.awt.geom.Point2D");
279 Clazz.overrideMethod (c$, "getX1",
283 Clazz.overrideMethod (c$, "getY1",
287 Clazz.overrideMethod (c$, "getP1",
289 return new java.awt.geom.Point2D.Double (this.x1, this.y1);
291 Clazz.overrideMethod (c$, "getX2",
295 Clazz.overrideMethod (c$, "getY2",
299 Clazz.overrideMethod (c$, "getP2",
301 return new java.awt.geom.Point2D.Double (this.x2, this.y2);
303 Clazz.defineMethod (c$, "setLine",
304 function (a, b, c, d) {
310 Clazz.overrideMethod (c$, "getBounds2D",
316 if (this.x1 < this.x2) {
318 c = this.x2 - this.x1;
321 c = this.x1 - this.x2;
322 }if (this.y1 < this.y2) {
324 d = this.y2 - this.y1;
327 d = this.y1 - this.y2;
328 }return new java.awt.geom.Rectangle2D.Double (a, b, c, d);