You can use the Area class to add in the original Shape:

       public Shape expandShape(Shape s, float d) {
               BasicStroke bs = new BasicStroke(d);
               // or new BasicStroke(d, CAP_ROUND, JOIN_ROUND);
               Area a = new Area(bs.createStrokedShape(s));
               a.add(new Area(s);
               return a;
       }

Note that the JOIN setting by default is MITER which may not match your
expectations for what it means to "expand the boundary of a Shape".
ROUND would result in a smoother resulting outline...

                       ...jim

Chris Nokleberg wrote:
I'd like to expand the boundary of an arbitrary Shape. If I use a
BasicStroke createTransformedShape, the result is perfect except for
the resulting hole. I currently get rid of the hole by iterating over
the path, splitting the shape into multiple subshapes, and then
comparing the bounds of each subshape to find the outermost one. This
is bunch of work just to undo the unnecessary work BasicStroke has
already done, though. Any suggestions on a cleaner solution?

Thanks,
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".

===========================================================================
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".

Reply via email to