1 Clazz.declarePackage ("java.awt.geom");
2 Clazz.load (["java.awt.geom.PathIterator"], "java.awt.geom.FlatteningPathIterator", ["java.lang.IllegalArgumentException", "java.util.NoSuchElementException", "java.awt.geom.CubicCurve2D", "$.QuadCurve2D"], function () {
3 c$ = Clazz.decorateAsClass (function () {
18 Clazz.instantialize (this, arguments);
19 }, java.awt.geom, "FlatteningPathIterator", null, java.awt.geom.PathIterator);
20 Clazz.prepareFields (c$, function () {
21 this.hold = Clazz.newDoubleArray (14, 0);
23 Clazz.makeConstructor (c$,
24 function (src, flatness) {
25 this.construct (src, flatness, 10);
26 }, "java.awt.geom.PathIterator,~N");
27 Clazz.makeConstructor (c$,
28 function (src, flatness, limit) {
30 throw new IllegalArgumentException ("flatness must be >= 0");
32 throw new IllegalArgumentException ("limit must be >= 0");
34 this.squareflat = flatness * flatness;
36 this.levels = Clazz.newIntArray (limit + 1, 0);
38 }, "java.awt.geom.PathIterator,~N,~N");
39 Clazz.defineMethod (c$, "getFlatness",
41 return Math.sqrt (this.squareflat);
43 Clazz.defineMethod (c$, "getRecursionLimit",
47 Clazz.defineMethod (c$, "getWindingRule",
49 return this.src.getWindingRule ();
51 Clazz.defineMethod (c$, "isDone",
55 Clazz.defineMethod (c$, "ensureHoldCapacity",
57 if (this.holdIndex - want < 0) {
58 var have = this.hold.length - this.holdIndex;
59 var newsize = this.hold.length + 24;
60 var newhold = Clazz.newDoubleArray (newsize, 0);
61 System.arraycopy (this.hold, this.holdIndex, newhold, this.holdIndex + 24, have);
66 Clazz.defineMethod (c$, "next",
70 Clazz.defineMethod (c$, "next",
73 if (this.holdIndex >= this.holdEnd) {
76 }if (this.src.isDone ()) {
79 }this.holdType = this.src.currentSegment (this.hold);
82 }switch (this.holdType) {
85 this.curx = this.hold[0];
86 this.cury = this.hold[1];
87 if (this.holdType == 0) {
88 this.movx = this.curx;
89 this.movy = this.cury;
94 this.curx = this.movx;
95 this.cury = this.movy;
100 if (this.holdIndex >= this.holdEnd) {
101 this.holdIndex = this.hold.length - 6;
102 this.holdEnd = this.hold.length - 2;
103 this.hold[this.holdIndex + 0] = this.curx;
104 this.hold[this.holdIndex + 1] = this.cury;
105 this.hold[this.holdIndex + 2] = this.hold[0];
106 this.hold[this.holdIndex + 3] = this.hold[1];
107 this.hold[this.holdIndex + 4] = this.curx = this.hold[2];
108 this.hold[this.holdIndex + 5] = this.cury = this.hold[3];
109 }level = this.levels[this.levelIndex];
110 while (level < this.limit) {
111 if (java.awt.geom.QuadCurve2D.getFlatnessSq (this.hold, this.holdIndex) < this.squareflat) {
113 }this.ensureHoldCapacity (4);
114 java.awt.geom.QuadCurve2D.subdivide (this.hold, this.holdIndex, this.hold, this.holdIndex - 4, this.hold, this.holdIndex);
117 this.levels[this.levelIndex] = level;
119 this.levels[this.levelIndex] = level;
125 if (this.holdIndex >= this.holdEnd) {
126 this.holdIndex = this.hold.length - 8;
127 this.holdEnd = this.hold.length - 2;
128 this.hold[this.holdIndex + 0] = this.curx;
129 this.hold[this.holdIndex + 1] = this.cury;
130 this.hold[this.holdIndex + 2] = this.hold[0];
131 this.hold[this.holdIndex + 3] = this.hold[1];
132 this.hold[this.holdIndex + 4] = this.hold[2];
133 this.hold[this.holdIndex + 5] = this.hold[3];
134 this.hold[this.holdIndex + 6] = this.curx = this.hold[4];
135 this.hold[this.holdIndex + 7] = this.cury = this.hold[5];
136 }level = this.levels[this.levelIndex];
137 while (level < this.limit) {
138 if (java.awt.geom.CubicCurve2D.getFlatnessSq (this.hold, this.holdIndex) < this.squareflat) {
140 }this.ensureHoldCapacity (6);
141 java.awt.geom.CubicCurve2D.subdivide (this.hold, this.holdIndex, this.hold, this.holdIndex - 6, this.hold, this.holdIndex);
144 this.levels[this.levelIndex] = level;
146 this.levels[this.levelIndex] = level;
153 Clazz.defineMethod (c$, "currentSegment",
155 if (this.isDone ()) {
156 throw new java.util.NoSuchElementException ("flattening iterator out of bounds");
157 }var type = this.holdType;
159 coords[0] = this.hold[this.holdIndex + 0];
160 coords[1] = this.hold[this.holdIndex + 1];
165 Clazz.defineMethod (c$, "currentSegment",
167 if (this.isDone ()) {
168 throw new java.util.NoSuchElementException ("flattening iterator out of bounds");
169 }var type = this.holdType;
171 coords[0] = this.hold[this.holdIndex + 0];
172 coords[1] = this.hold[this.holdIndex + 1];
177 Clazz.defineStatics (c$,