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