On 8/22/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
After that, I found this thread.  I tried the suggested code snippet (using 
CAP_ROUND
and JOIN_ROUND), and it almost works.  However, the area I get when I create the
stroked shape has holes in it other than the original shape.  Can you explain 
this?

The holes should be smaller than the original shape--by half the
stroke width. You have to union the stroked shape with the original
shape to eliminate the holes:

Area expanded = new Area(stroke.createStrokedShape(shape));
expanded.add(new Area(shape));

I've attached a demo that will write out "expand.png" (sorry, went overboard).

Also, how would you go about finding the outermost shape in the region?  I 
don't think
you can rely on comparing the results of the getBounds() functions; I thought 
that there
was no guarantee on how closely the bounds will fit.

FWIW getBounds2D would probably be a better method to use. In practice
I think the bounds are calculated by determining the bounds of all
control points, so shape with some crazy beziers could potentially
exceed the bounds. However presumably the two "contour" paths in a
stroked shape would act similarly, so it probably isn't a big deal. I
agree it's not foolproof though.

My solution was to calculate the area of the different subshapes and choose the 
one
with the largest area.

Seems like that should work too. There is a pretty simple algorithm
for calculating the area of a polygon, and you can use a flattening
path iterator on an arbitrary shape.

Chris

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Attachment: ExpandShape.java
Description: Binary data

Reply via email to