1 Clazz.declarePackage ("java.awt.geom");
2 Clazz.load (["java.awt.Shape", "java.awt.geom.PathIterator", "java.util.Vector"], ["java.awt.geom.Area", "$.AreaIterator"], ["java.lang.NullPointerException", "java.util.NoSuchElementException", "java.awt.geom.FlatteningPathIterator", "$.Rectangle2D", "jssun.awt.geom.AreaOp", "$.Crossings", "$.Curve"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.cachedBounds = null;
6 Clazz.instantialize (this, arguments);
7 }, java.awt.geom, "Area", null, [java.awt.Shape, Cloneable]);
8 Clazz.makeConstructor (c$,
10 this.curves = java.awt.geom.Area.EmptyCurves;
12 Clazz.makeConstructor (c$,
14 if (Clazz.instanceOf (s, java.awt.geom.Area)) {
15 this.curves = (s).curves;
17 this.curves = java.awt.geom.Area.pathToCurves (s.getPathIterator (null));
18 }}, "java.awt.Shape");
19 c$.pathToCurves = Clazz.defineMethod (c$, "pathToCurves",
21 var curves = new java.util.Vector ();
22 var windingRule = pi.getWindingRule ();
23 var coords = Clazz.newDoubleArray (23, 0);
30 while (!pi.isDone ()) {
31 switch (pi.currentSegment (coords)) {
33 jssun.awt.geom.Curve.insertLine (curves, curx, cury, movx, movy);
34 curx = movx = coords[0];
35 cury = movy = coords[1];
36 jssun.awt.geom.Curve.insertMove (curves, movx, movy);
41 jssun.awt.geom.Curve.insertLine (curves, curx, cury, newx, newy);
48 jssun.awt.geom.Curve.insertQuad (curves, curx, cury, coords);
55 jssun.awt.geom.Curve.insertCubic (curves, curx, cury, coords);
60 jssun.awt.geom.Curve.insertLine (curves, curx, cury, movx, movy);
67 jssun.awt.geom.Curve.insertLine (curves, curx, cury, movx, movy);
69 if (windingRule == 0) {
70 operator = new jssun.awt.geom.AreaOp.EOWindOp ();
72 operator = new jssun.awt.geom.AreaOp.NZWindOp ();
73 }return operator.calculate (curves, java.awt.geom.Area.EmptyCurves);
74 }, "java.awt.geom.PathIterator");
75 Clazz.defineMethod (c$, "add",
77 this.curves = new jssun.awt.geom.AreaOp.AddOp ().calculate (this.curves, rhs.curves);
78 this.invalidateBounds ();
79 }, "java.awt.geom.Area");
80 Clazz.defineMethod (c$, "subtract",
82 this.curves = new jssun.awt.geom.AreaOp.SubOp ().calculate (this.curves, rhs.curves);
83 this.invalidateBounds ();
84 }, "java.awt.geom.Area");
85 Clazz.defineMethod (c$, "intersect",
87 this.curves = new jssun.awt.geom.AreaOp.IntOp ().calculate (this.curves, rhs.curves);
88 this.invalidateBounds ();
89 }, "java.awt.geom.Area");
90 Clazz.defineMethod (c$, "exclusiveOr",
92 this.curves = new jssun.awt.geom.AreaOp.XorOp ().calculate (this.curves, rhs.curves);
93 this.invalidateBounds ();
94 }, "java.awt.geom.Area");
95 Clazz.defineMethod (c$, "reset",
97 this.curves = new java.util.Vector ();
98 this.invalidateBounds ();
100 Clazz.defineMethod (c$, "isEmpty",
102 return (this.curves.size () == 0);
104 Clazz.defineMethod (c$, "isPolygonal",
106 var enum_ = this.curves.elements ();
107 while (enum_.hasMoreElements ()) {
108 if ((enum_.nextElement ()).getOrder () > 1) {
113 Clazz.defineMethod (c$, "isRectangular",
115 var size = this.curves.size ();
120 }var c1 = this.curves.get (1);
121 var c2 = this.curves.get (2);
122 if (c1.getOrder () != 1 || c2.getOrder () != 1) {
124 }if (c1.getXTop () != c1.getXBot () || c2.getXTop () != c2.getXBot ()) {
126 }if (c1.getYTop () != c2.getYTop () || c1.getYBot () != c2.getYBot ()) {
130 Clazz.defineMethod (c$, "isSingular",
132 if (this.curves.size () < 3) {
134 }var enum_ = this.curves.elements ();
135 enum_.nextElement ();
136 while (enum_.hasMoreElements ()) {
137 if ((enum_.nextElement ()).getOrder () == 0) {
142 Clazz.defineMethod (c$, "invalidateBounds",
144 this.cachedBounds = null;
146 Clazz.defineMethod (c$, "getCachedBounds",
148 if (this.cachedBounds != null) {
149 return this.cachedBounds;
150 }var r = new java.awt.geom.Rectangle2D.Double ();
151 if (this.curves.size () > 0) {
152 var c = this.curves.get (0);
153 r.setRect (c.getX0 (), c.getY0 (), 0, 0);
154 for (var i = 1; i < this.curves.size (); i++) {
155 (this.curves.get (i)).enlarge (r);
157 }return (this.cachedBounds = r);
159 Clazz.overrideMethod (c$, "getBounds2D",
161 return this.getCachedBounds ().getBounds2D ();
163 Clazz.overrideMethod (c$, "getBounds",
165 return this.getCachedBounds ().getBounds ();
167 Clazz.overrideMethod (c$, "clone",
169 return new java.awt.geom.Area (this);
171 Clazz.defineMethod (c$, "equals",
173 if (other === this) {
175 }if (other == null) {
177 }var c = new jssun.awt.geom.AreaOp.XorOp ().calculate (this.curves, other.curves);
179 }, "java.awt.geom.Area");
180 Clazz.defineMethod (c$, "transform",
183 throw new NullPointerException ("transform must not be null");
184 }this.curves = java.awt.geom.Area.pathToCurves (this.getPathIterator (t));
185 this.invalidateBounds ();
186 }, "java.awt.geom.AffineTransform");
187 Clazz.defineMethod (c$, "createTransformedArea",
189 var a = new java.awt.geom.Area (this);
192 }, "java.awt.geom.AffineTransform");
193 Clazz.defineMethod (c$, "contains",
195 if (!this.getCachedBounds ().contains (x, y)) {
197 }var enum_ = this.curves.elements ();
199 while (enum_.hasMoreElements ()) {
200 var c = enum_.nextElement ();
201 crossings += c.crossingsFor (x, y);
203 return ((crossings & 1) == 1);
205 Clazz.defineMethod (c$, "contains",
207 return this.contains (p.getX (), p.getY ());
208 }, "java.awt.geom.Point2D");
209 Clazz.defineMethod (c$, "contains",
210 function (x, y, w, h) {
211 if (w < 0 || h < 0) {
213 }if (!this.getCachedBounds ().contains (x, y, w, h)) {
215 }var c = jssun.awt.geom.Crossings.findCrossings (this.curves, x, y, x + w, y + h);
216 return (c != null && c.covers (y, y + h));
218 Clazz.defineMethod (c$, "contains",
220 return this.contains (r.getX (), r.getY (), r.getWidth (), r.getHeight ());
221 }, "java.awt.geom.Rectangle2D");
222 Clazz.defineMethod (c$, "intersects",
223 function (x, y, w, h) {
224 if (w < 0 || h < 0) {
226 }if (!this.getCachedBounds ().intersects (x, y, w, h)) {
228 }var c = jssun.awt.geom.Crossings.findCrossings (this.curves, x, y, x + w, y + h);
229 return (c == null || !c.isEmpty ());
231 Clazz.defineMethod (c$, "intersects",
233 return this.intersects (r.getX (), r.getY (), r.getWidth (), r.getHeight ());
234 }, "java.awt.geom.Rectangle2D");
235 Clazz.defineMethod (c$, "getPathIterator",
237 return new java.awt.geom.AreaIterator (this.curves, at);
238 }, "java.awt.geom.AffineTransform");
239 Clazz.defineMethod (c$, "getPathIterator",
240 function (at, flatness) {
241 return new java.awt.geom.FlatteningPathIterator (this.getPathIterator (at), flatness);
242 }, "java.awt.geom.AffineTransform,~N");
243 c$.EmptyCurves = c$.prototype.EmptyCurves = new java.util.Vector ();
244 c$ = Clazz.decorateAsClass (function () {
245 this.transform = null;
248 this.prevcurve = null;
249 this.thiscurve = null;
250 Clazz.instantialize (this, arguments);
251 }, java.awt.geom, "AreaIterator", null, java.awt.geom.PathIterator);
252 Clazz.makeConstructor (c$,
253 function (curves, at) {
254 this.curves = curves;
256 if (curves.size () >= 1) {
257 this.thiscurve = curves.get (0);
258 }}, "java.util.Vector,java.awt.geom.AffineTransform");
259 Clazz.overrideMethod (c$, "getWindingRule",
263 Clazz.overrideMethod (c$, "isDone",
265 return (this.prevcurve == null && this.thiscurve == null);
267 Clazz.overrideMethod (c$, "next",
269 if (this.prevcurve != null) {
270 this.prevcurve = null;
272 this.prevcurve = this.thiscurve;
274 if (this.index < this.curves.size ()) {
275 this.thiscurve = this.curves.get (this.index);
276 if (this.thiscurve.getOrder () != 0 && this.prevcurve.getX1 () == this.thiscurve.getX0 () && this.prevcurve.getY1 () == this.thiscurve.getY0 ()) {
277 this.prevcurve = null;
279 this.thiscurve = null;
281 Clazz.defineMethod (c$, "currentSegment",
283 var dcoords = Clazz.newDoubleArray (6, 0);
284 var segtype = this.currentSegment (dcoords);
285 var numpoints = (segtype == 4 ? 0 : (segtype == 2 ? 2 : (segtype == 3 ? 3 : 1)));
286 for (var i = 0; i < numpoints * 2; i++) {
287 coords[i] = dcoords[i];
291 Clazz.defineMethod (c$, "currentSegment",
295 if (this.prevcurve != null) {
296 if (this.thiscurve == null || this.thiscurve.getOrder () == 0) {
298 }coords[0] = this.thiscurve.getX0 ();
299 coords[1] = this.thiscurve.getY0 ();
302 } else if (this.thiscurve == null) {
303 throw new java.util.NoSuchElementException ("area iterator out of bounds");
305 segtype = this.thiscurve.getSegment (coords);
306 numpoints = this.thiscurve.getOrder ();
307 if (numpoints == 0) {
309 }}if (this.transform != null) {
310 this.transform.transform (coords, 0, coords, 0, numpoints);