Hi Ted,

Unfortunately the BasicStroke implementation only lets you specify a single
linewidth parameter for any direction and it works in "user space" insofar
as it does not take an AffineTransform parameter.

The easiest way to do this would be to transform the shape before the
stretch operation and then transform it back.  To get the effect of 2 units
in X and 3 units in Y you could stretch it by a factor of 2/3 in Y, apply
the Area/Stroke stretching code with a line width of 4 and then stretch it
back by a factor of 3/2 in Y.  I think that will achieve the effect you are
looking for...

                                ...jim

--On Monday, December 02, 2002 11:02:54 -0600 Ted Hill
<[EMAIL PROTECTED]> wrote:

> Hi Jim,
> 
> Thanks for your suggestion/insight to use a combination of Stroke and Area
> for expanding and contracting Shapes. It looks like this will work well.
> 
> A follow up question:
> 
> I will also occasionally need to expand/contract my simple closed polygons
> by a different amount in X and Y. For example, add 2 units in the x
> dimension and add 1 unit in the y dimension.
> 
> Is it possible to create a Stroke that is thicker in one dimension than in
> the other?
> 
> If so, it would seem that I could use Strokes and Areas to expand and
> contract by different amounts in x and y.
> 
> Thank you,
> 
> Ted Hill
> 
> 
> ----- Original Message -----
> From: "Jim Graham" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, November 26, 2002 4:37 PM
> Subject: [JAVA2D] Path fun (in Re: to both STROKE_CONTROL and GeneralPath
> expansion)
> 
> 
> > 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".

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