Using an AffineTransform to include a Shape's Stroke when clipping

If I have a Shape with a border of width defined by some Stroke width, am I able to include the Stroke border by using a clip defined by a Shape produced from myAffineTransform.createTransformedShape(myShape) ?

I'm not sure that it's possible, since if I scale the x and y values using the matrix represented by myAffineTransform, the growth of the clip boundary would not be consistent. Some regions would be expanded more than others.

Does anyone know whether it's possible to achieve this growth of a clip area by n pixels, and if so, how?

[564 byte] By [KomodoDavea] at [2007-11-26 16:51:20]
# 1

You can do it this way:

public Shape createMask(Shape shape, Stroke stroke)

{

Area a = new Area(shape);

a.add(new Area(stroke.createStrokedShape(shape)));

return a;

}

The only problem with that is that, as I recall, it's pretty slow, so it might be suitable for a one-hit op but not within a paint cycle. Though my recollection may be wrong. Give it a go.

itchyscratchya at 2007-7-8 23:19:00 > top of Java-index,Desktop,Core GUI APIs...
# 2
Legend, thanks a lot itchyscratchy :) I appreciate it.
KomodoDavea at 2007-7-8 23:19:00 > top of Java-index,Desktop,Core GUI APIs...