Ted and Ram�n,

Using the Area and BasicStroke classes, you can achieve any of the effects
that you two have been asking for.  Assuming a source Shape object "S", and
wanting to outsideline, insideline, expand or contract it by N pixels...

First get all your variables set up:

        BasicStroke bs = new BasicStroke(N*2);
        Shape outline = bs.createStrokedShape(S);
        Area a1 = new Area(outline);
        Area a2 = new Area(S);

Then plug in the appropriate Area operation depending on what you want to do:

- Outline N pixels outside of a shape (S):

        Area result = a1.subtract(a2);

- Outline N pixels inside of a shape (S):

        Area result = a1.intersect(a2);

- Expand a shape (S) by N pixels:

        Area result = a1.union(a2);

- Contract a shape (S) by N pixels:

        Area result = a2.subtract(a1);

I've left out the various attributes on constructing the BasicStroke above
since it depends on the "look" that you are going for.  I would imagine that
the expand/contract operations would want to specify a MITER join so that
it doesn't cause the corners to get rounded or chopped off, but the inside
and outside outlines could probably use all sorts of variations depending
on personal taste...

                                ...jim

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