I have checked the interface Area, and there is no method to compute the
geometrical center of the area such as:
Point2D center()

The point is if the area interface is extended to incluse the center
method, expandShape method should be very simple and direct to implement
by using AffineTransform.

Yinhe Cao

Jim Graham wrote On 07/17/06 14:39

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

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