2362N/A * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A utility class to iterate over the path segments of an arc 0N/A * through the PathIterator interface. 0N/A * @author Jim Graham 0N/A // btan(Math.PI / 2); 0N/A this.
cv =
0.5522847498307933;
0N/A if (w <
0 || h <
0) {
0N/A * Return the winding rule for determining the insideness of the 0N/A * @see #WIND_EVEN_ODD 0N/A * @see #WIND_NON_ZERO 0N/A * Tests if there are more points to read. 0N/A * @return true if there are more points to read 0N/A * Moves the iterator to the next segment of the path forwards 0N/A * along the primary direction of traversal as long as there are 0N/A * more points in that direction. 0N/A * btan computes the length (k) of the control segments at 0N/A * the beginning and end of a cubic bezier that approximates 0N/A * a segment of an arc with extent less than or equal to 0N/A * 90 degrees. This length (k) will be used to generate the 0N/A * 2 bezier control points for such a segment. 0N/A * a) arc is centered on 0,0 with radius of 1.0 0N/A * b) arc extent is less than 90 degrees 0N/A * c) control points should preserve tangent 0N/A * d) control segments should have equal length 0N/A * end angle: ang2 = ang1 + extent 0N/A * start point: P1 = (x1, y1) = (cos(ang1), sin(ang1)) 0N/A * end point: P4 = (x4, y4) = (cos(ang2), sin(ang2)) 0N/A * | x2 = x1 - k * sin(ang1) = cos(ang1) - k * sin(ang1) 0N/A * | y2 = y1 + k * cos(ang1) = sin(ang1) + k * cos(ang1) 0N/A * | x3 = x4 + k * sin(ang2) = cos(ang2) + k * sin(ang2) 0N/A * | y3 = y4 - k * cos(ang2) = sin(ang2) - k * cos(ang2) 0N/A * The formula for this length (k) can be found using the 0N/A * following derivations: 0N/A * a) bezier (t = 1/2) 0N/A * bPm = P1 * (1-t)^3 + 0N/A * 3 * P2 * t * (1-t)^2 + 0N/A * 3 * P3 * t^2 * (1-t) + 0N/A * = (P1 + 3P2 + 3P3 + P4)/8 0N/A * aPm = (cos((ang1 + ang2)/2), sin((ang1 + ang2)/2)) 0N/A * Let angb = (ang2 - ang1)/2; angb is half of the angle 0N/A * between ang1 and ang2. 0N/A * Solve the equation bPm == aPm 0N/A * x1 + 3*x2 + 3*x3 + x4 = 8*cos((ang1 + ang2)/2) 0N/A * cos(ang1) + 3*cos(ang1) - 3*k*sin(ang1) + 0N/A * 3*cos(ang2) + 3*k*sin(ang2) + cos(ang2) = 0N/A * = 8*cos((ang1 + ang2)/2) 0N/A * 4*cos(ang1) + 4*cos(ang2) + 3*k*(sin(ang2) - sin(ang1)) = 0N/A * = 8*cos((ang1 + ang2)/2) 0N/A * 8*cos((ang1 + ang2)/2)*cos((ang2 - ang1)/2) + 0N/A * 6*k*sin((ang2 - ang1)/2)*cos((ang1 + ang2)/2) = 0N/A * = 8*cos((ang1 + ang2)/2) 0N/A * 4*cos(angb) + 3*k*sin(angb) = 4 0N/A * k = 4 / 3 * (1 - cos(angb)) / sin(angb) 0N/A * b) For ym coord we derive the same formula. 0N/A * Since this formula can generate "NaN" values for small 0N/A * angles, we will derive a safer form that does not involve 0N/A * dividing by very small values: 0N/A * (1 - cos(angb)) / sin(angb) = 0N/A * = (1 - cos(angb))*(1 + cos(angb)) / sin(angb)*(1 + cos(angb)) = 0N/A * = (1 - cos(angb)^2) / sin(angb)*(1 + cos(angb)) = 0N/A * = sin(angb)^2 / sin(angb)*(1 + cos(angb)) = 0N/A * = sin(angb) / (1 + cos(angb)) 0N/A * Returns the coordinates and type of the current path segment in 0N/A * The return value is the path segment type: 0N/A * SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. 0N/A * A float array of length 6 must be passed in and may be used to 0N/A * store the coordinates of the point(s). 0N/A * Each point is stored as a pair of float x,y coordinates. 0N/A * SEG_MOVETO and SEG_LINETO types will return one point, 0N/A * SEG_QUADTO will return two points, 0N/A * SEG_CUBICTO will return 3 points 0N/A * and SEG_CLOSE will not return any points. 0N/A * Returns the coordinates and type of the current path segment in 0N/A * The return value is the path segment type: 0N/A * SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. 0N/A * A double array of length 6 must be passed in and may be used to 0N/A * store the coordinates of the point(s). 0N/A * Each point is stored as a pair of double x,y coordinates. 0N/A * SEG_MOVETO and SEG_LINETO types will return one point, 0N/A * SEG_QUADTO will return two points, 0N/A * SEG_CUBICTO will return 3 points 0N/A * and SEG_CLOSE will not return any points.