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