RoundRectIteratorpublic class RoundRectIterator extends Object implements PathIteratorA utility class to iterate over the path segments of an rounded rectangle
through the PathIterator interface. |
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 int | currentSegment(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.
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 int | currentSegment(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.
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 int | getWindingRule()Return the winding rule for determining the insideness of the
path.
return WIND_NON_ZERO;
| public boolean | isDone()Tests if there are more points to read.
return index >= ctrlpts.length;
| public void | next()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++;
|
|