X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjava%2Fawt%2Fgeom%2FArcIterator.js;fp=site%2Fj2s%2Fjava%2Fawt%2Fgeom%2FArcIterator.js;h=05fa96e3b1100f3cb51f1c3abf0a59c7891ab8bc;hp=e0b6ab580de8f175562ddd58262223114a8f2fd2;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/java/awt/geom/ArcIterator.js b/site/j2s/java/awt/geom/ArcIterator.js index e0b6ab5..05fa96e 100644 --- a/site/j2s/java/awt/geom/ArcIterator.js +++ b/site/j2s/java/awt/geom/ArcIterator.js @@ -1,140 +1,140 @@ -Clazz.declarePackage ("java.awt.geom"); -Clazz.load (["java.awt.geom.PathIterator"], "java.awt.geom.ArcIterator", ["java.util.NoSuchElementException"], function () { -c$ = Clazz.decorateAsClass (function () { -this.x = 0; -this.y = 0; -this.w = 0; -this.h = 0; -this.angStRad = 0; -this.increment = 0; -this.cv = 0; -this.affine = null; -this.index = 0; -this.arcSegs = 0; -this.lineSegs = 0; -Clazz.instantialize (this, arguments); -}, java.awt.geom, "ArcIterator", null, java.awt.geom.PathIterator); -Clazz.makeConstructor (c$, -function (a, at) { -this.w = a.getWidth () / 2; -this.h = a.getHeight () / 2; -this.x = a.getX () + this.w; -this.y = a.getY () + this.h; -this.angStRad = -Math.toRadians (a.getAngleStart ()); -this.affine = at; -var ext = -a.getAngleExtent (); -if (ext >= 360.0 || ext <= -360) { -this.arcSegs = 4; -this.increment = 1.5707963267948966; -this.cv = 0.5522847498307933; -if (ext < 0) { -this.increment = -this.increment; -this.cv = -this.cv; -}} else { -this.arcSegs = Clazz.doubleToInt (Math.ceil (Math.abs (ext) / 90.0)); -this.increment = Math.toRadians (ext / this.arcSegs); -this.cv = java.awt.geom.ArcIterator.btan (this.increment); -if (this.cv == 0) { -this.arcSegs = 0; -}}switch (a.getArcType ()) { -case 0: -this.lineSegs = 0; -break; -case 1: -this.lineSegs = 1; -break; -case 2: -this.lineSegs = 2; -break; -} -if (this.w < 0 || this.h < 0) { -this.arcSegs = this.lineSegs = -1; -}}, "java.awt.geom.Arc2D,java.awt.geom.AffineTransform"); -Clazz.overrideMethod (c$, "getWindingRule", -function () { -return 1; -}); -Clazz.overrideMethod (c$, "isDone", -function () { -return this.index > this.arcSegs + this.lineSegs; -}); -Clazz.overrideMethod (c$, "next", -function () { -this.index++; -}); -c$.btan = Clazz.defineMethod (c$, "btan", - function (increment) { -increment /= 2.0; -return 1.3333333333333333 * Math.sin (increment) / (1.0 + Math.cos (increment)); -}, "~N"); -Clazz.defineMethod (c$, "currentSegment", -function (coords) { -if (this.isDone ()) { -throw new java.util.NoSuchElementException ("arc iterator out of bounds"); -}var angle = this.angStRad; -if (this.index == 0) { -coords[0] = (this.x + Math.cos (angle) * this.w); -coords[1] = (this.y + Math.sin (angle) * this.h); -if (this.affine != null) { -this.affine.transform (coords, 0, coords, 0, 1); -}return 0; -}if (this.index > this.arcSegs) { -if (this.index == this.arcSegs + this.lineSegs) { -return 4; -}coords[0] = this.x; -coords[1] = this.y; -if (this.affine != null) { -this.affine.transform (coords, 0, coords, 0, 1); -}return 1; -}angle += this.increment * (this.index - 1); -var relx = Math.cos (angle); -var rely = Math.sin (angle); -coords[0] = (this.x + (relx - this.cv * rely) * this.w); -coords[1] = (this.y + (rely + this.cv * relx) * this.h); -angle += this.increment; -relx = Math.cos (angle); -rely = Math.sin (angle); -coords[2] = (this.x + (relx + this.cv * rely) * this.w); -coords[3] = (this.y + (rely - this.cv * relx) * this.h); -coords[4] = (this.x + relx * this.w); -coords[5] = (this.y + rely * this.h); -if (this.affine != null) { -this.affine.transform (coords, 0, coords, 0, 3); -}return 3; -}, "~A"); -Clazz.defineMethod (c$, "currentSegment", -function (coords) { -if (this.isDone ()) { -throw new java.util.NoSuchElementException ("arc iterator out of bounds"); -}var angle = this.angStRad; -if (this.index == 0) { -coords[0] = this.x + Math.cos (angle) * this.w; -coords[1] = this.y + Math.sin (angle) * this.h; -if (this.affine != null) { -this.affine.transform (coords, 0, coords, 0, 1); -}return 0; -}if (this.index > this.arcSegs) { -if (this.index == this.arcSegs + this.lineSegs) { -return 4; -}coords[0] = this.x; -coords[1] = this.y; -if (this.affine != null) { -this.affine.transform (coords, 0, coords, 0, 1); -}return 1; -}angle += this.increment * (this.index - 1); -var relx = Math.cos (angle); -var rely = Math.sin (angle); -coords[0] = this.x + (relx - this.cv * rely) * this.w; -coords[1] = this.y + (rely + this.cv * relx) * this.h; -angle += this.increment; -relx = Math.cos (angle); -rely = Math.sin (angle); -coords[2] = this.x + (relx + this.cv * rely) * this.w; -coords[3] = this.y + (rely - this.cv * relx) * this.h; -coords[4] = this.x + relx * this.w; -coords[5] = this.y + rely * this.h; -if (this.affine != null) { -this.affine.transform (coords, 0, coords, 0, 3); -}return 3; -}, "~A"); -}); +Clazz.declarePackage ("java.awt.geom"); +Clazz.load (["java.awt.geom.PathIterator"], "java.awt.geom.ArcIterator", ["java.util.NoSuchElementException"], function () { +c$ = Clazz.decorateAsClass (function () { +this.x = 0; +this.y = 0; +this.w = 0; +this.h = 0; +this.angStRad = 0; +this.increment = 0; +this.cv = 0; +this.affine = null; +this.index = 0; +this.arcSegs = 0; +this.lineSegs = 0; +Clazz.instantialize (this, arguments); +}, java.awt.geom, "ArcIterator", null, java.awt.geom.PathIterator); +Clazz.makeConstructor (c$, +function (a, at) { +this.w = a.getWidth () / 2; +this.h = a.getHeight () / 2; +this.x = a.getX () + this.w; +this.y = a.getY () + this.h; +this.angStRad = -Math.toRadians (a.getAngleStart ()); +this.affine = at; +var ext = -a.getAngleExtent (); +if (ext >= 360.0 || ext <= -360) { +this.arcSegs = 4; +this.increment = 1.5707963267948966; +this.cv = 0.5522847498307933; +if (ext < 0) { +this.increment = -this.increment; +this.cv = -this.cv; +}} else { +this.arcSegs = Clazz.doubleToInt (Math.ceil (Math.abs (ext) / 90.0)); +this.increment = Math.toRadians (ext / this.arcSegs); +this.cv = java.awt.geom.ArcIterator.btan (this.increment); +if (this.cv == 0) { +this.arcSegs = 0; +}}switch (a.getArcType ()) { +case 0: +this.lineSegs = 0; +break; +case 1: +this.lineSegs = 1; +break; +case 2: +this.lineSegs = 2; +break; +} +if (this.w < 0 || this.h < 0) { +this.arcSegs = this.lineSegs = -1; +}}, "java.awt.geom.Arc2D,java.awt.geom.AffineTransform"); +Clazz.overrideMethod (c$, "getWindingRule", +function () { +return 1; +}); +Clazz.overrideMethod (c$, "isDone", +function () { +return this.index > this.arcSegs + this.lineSegs; +}); +Clazz.overrideMethod (c$, "next", +function () { +this.index++; +}); +c$.btan = Clazz.defineMethod (c$, "btan", + function (increment) { +increment /= 2.0; +return 1.3333333333333333 * Math.sin (increment) / (1.0 + Math.cos (increment)); +}, "~N"); +Clazz.defineMethod (c$, "currentSegment", +function (coords) { +if (this.isDone ()) { +throw new java.util.NoSuchElementException ("arc iterator out of bounds"); +}var angle = this.angStRad; +if (this.index == 0) { +coords[0] = (this.x + Math.cos (angle) * this.w); +coords[1] = (this.y + Math.sin (angle) * this.h); +if (this.affine != null) { +this.affine.transform (coords, 0, coords, 0, 1); +}return 0; +}if (this.index > this.arcSegs) { +if (this.index == this.arcSegs + this.lineSegs) { +return 4; +}coords[0] = this.x; +coords[1] = this.y; +if (this.affine != null) { +this.affine.transform (coords, 0, coords, 0, 1); +}return 1; +}angle += this.increment * (this.index - 1); +var relx = Math.cos (angle); +var rely = Math.sin (angle); +coords[0] = (this.x + (relx - this.cv * rely) * this.w); +coords[1] = (this.y + (rely + this.cv * relx) * this.h); +angle += this.increment; +relx = Math.cos (angle); +rely = Math.sin (angle); +coords[2] = (this.x + (relx + this.cv * rely) * this.w); +coords[3] = (this.y + (rely - this.cv * relx) * this.h); +coords[4] = (this.x + relx * this.w); +coords[5] = (this.y + rely * this.h); +if (this.affine != null) { +this.affine.transform (coords, 0, coords, 0, 3); +}return 3; +}, "~A"); +Clazz.defineMethod (c$, "currentSegment", +function (coords) { +if (this.isDone ()) { +throw new java.util.NoSuchElementException ("arc iterator out of bounds"); +}var angle = this.angStRad; +if (this.index == 0) { +coords[0] = this.x + Math.cos (angle) * this.w; +coords[1] = this.y + Math.sin (angle) * this.h; +if (this.affine != null) { +this.affine.transform (coords, 0, coords, 0, 1); +}return 0; +}if (this.index > this.arcSegs) { +if (this.index == this.arcSegs + this.lineSegs) { +return 4; +}coords[0] = this.x; +coords[1] = this.y; +if (this.affine != null) { +this.affine.transform (coords, 0, coords, 0, 1); +}return 1; +}angle += this.increment * (this.index - 1); +var relx = Math.cos (angle); +var rely = Math.sin (angle); +coords[0] = this.x + (relx - this.cv * rely) * this.w; +coords[1] = this.y + (rely + this.cv * relx) * this.h; +angle += this.increment; +relx = Math.cos (angle); +rely = Math.sin (angle); +coords[2] = this.x + (relx + this.cv * rely) * this.w; +coords[3] = this.y + (rely - this.cv * relx) * this.h; +coords[4] = this.x + relx * this.w; +coords[5] = this.y + rely * this.h; +if (this.affine != null) { +this.affine.transform (coords, 0, coords, 0, 3); +}return 3; +}, "~A"); +});