FileDocCategorySizeDatePackage
RoundRectIterator.javaAPI DocJava SE 5 API5186Fri Aug 26 14:56:52 BST 2005java.awt.geom

RoundRectIterator

public class RoundRectIterator extends Object implements PathIterator
A utility class to iterate over the path segments of an rounded rectangle through the PathIterator interface.
version
10 Feb 1997
author
Jim Graham

Fields Summary
double
x
double
y
double
w
double
h
double
aw
double
ah
AffineTransform
affine
int
index
private static final double
angle
private static final double
a
private static final double
b
private static final double
c
private static final double
cv
private static final double
acv
private static double[]
ctrlpts
private static int[]
types
Constructors Summary
RoundRectIterator(RoundRectangle2D rr, AffineTransform at)

	this.x = rr.getX();
	this.y = rr.getY();
	this.w = rr.getWidth();
	this.h = rr.getHeight();
	this.aw = Math.min(w, Math.abs(rr.getArcWidth()));
	this.ah = Math.min(h, Math.abs(rr.getArcHeight()));
	this.affine = at;
	if (aw < 0 || ah < 0) {
	    // Don't draw anything...
	    index = ctrlpts.length;
	}
    
Methods Summary
public intcurrentSegment(float[] coords)
Returns the coordinates and type of the current path segment in the iteration. The return value is the path segment type: SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A float array of length 6 must be passed in and may be used to store the coordinates of the point(s). Each point is stored as a pair of float x,y coordinates. SEG_MOVETO and SEG_LINETO types will return one point, SEG_QUADTO will return two points, SEG_CUBICTO will return 3 points and SEG_CLOSE will not return any points.

see
#SEG_MOVETO
see
#SEG_LINETO
see
#SEG_QUADTO
see
#SEG_CUBICTO
see
#SEG_CLOSE


                                                                                                       
        
	if (isDone()) {
	    throw new NoSuchElementException("roundrect iterator out of bounds");
	}
	double ctrls[] = ctrlpts[index];
	int nc = 0;
	for (int i = 0; i < ctrls.length; i += 4) {
	    coords[nc++] = (float) (x + ctrls[i + 0] * w + ctrls[i + 1] * aw);
	    coords[nc++] = (float) (y + ctrls[i + 2] * h + ctrls[i + 3] * ah);
	}
	if (affine != null) {
	    affine.transform(coords, 0, coords, 0, nc / 2);
	}
	return types[index];
    
public intcurrentSegment(double[] coords)
Returns the coordinates and type of the current path segment in the iteration. The return value is the path segment type: SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A double array of length 6 must be passed in and may be used to store the coordinates of the point(s). Each point is stored as a pair of double x,y coordinates. SEG_MOVETO and SEG_LINETO types will return one point, SEG_QUADTO will return two points, SEG_CUBICTO will return 3 points and SEG_CLOSE will not return any points.

see
#SEG_MOVETO
see
#SEG_LINETO
see
#SEG_QUADTO
see
#SEG_CUBICTO
see
#SEG_CLOSE

	if (isDone()) {
	    throw new NoSuchElementException("roundrect iterator out of bounds");
	}
	double ctrls[] = ctrlpts[index];
	int nc = 0;
	for (int i = 0; i < ctrls.length; i += 4) {
	    coords[nc++] = (x + ctrls[i + 0] * w + ctrls[i + 1] * aw);
	    coords[nc++] = (y + ctrls[i + 2] * h + ctrls[i + 3] * ah);
	}
	if (affine != null) {
	    affine.transform(coords, 0, coords, 0, nc / 2);
	}
	return types[index];
    
public intgetWindingRule()
Return the winding rule for determining the insideness of the path.

see
#WIND_EVEN_ODD
see
#WIND_NON_ZERO

	return WIND_NON_ZERO;
    
public booleanisDone()
Tests if there are more points to read.

return
true if there are more points to read

	return index >= ctrlpts.length;
    
public voidnext()
Moves the iterator to the next segment of the path forwards along the primary direction of traversal as long as there are more points in that direction.

	index++;