Re: Draw a scaled arrow
- From: "John B. Matthews" <nospam@xxxxxxxxxx>
- Date: Tue, 20 May 2008 20:48:55 -0400
In article <KPKdnTr204LhpK7VnZ2dnUVZ8j6dnZ2d@xxxxxx>,
RichT <someone@xxxxxxxxxxxxx> wrote:
[...]
Thanks for this, I can play with this example but I cant get it to
behave like the example code I provided when dragging a line and
rotating the arrow head with the mouse cursor, I still also get the
problem of xy coords not aligning when going from a > 100% zoom down to
a 100% zoom, the arrow does not get drawn at the correct place when
scaling to 100%;
I tried your second example, ArrowPanel. I hope you're not doing org
charts:-)
You are right to get the view working at 1:1. Separate the scaling, line
drawing, and arrowhead rotating. Do your scaling on the view, as
suggested in ViewZoom.java in a related thread, "Zoom relative to mouse
position."
As you drag, use a Polygon (or Path) that's easy to translate to and
rotate about the line's endpoint; rotate it by an angle related to the
atan2 of your line's endpoint, and translate it there:
/** Create an east pointing arrow with the notch at the origin. */
private static Polygon initPoly()
{
Polygon poly = new Polygon();
poly.addPoint( 0, 0);
poly.addPoint(-1, -1);
poly.addPoint( 2, 0);
poly.addPoint(-1, 1);
return poly;
}
You may want to scale it statically by eight or ten at startup. Or do it
by hand: (0, 0), (-1 * 10, -1 * 10), etc.
John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
.
- Follow-Ups:
- Re: Draw a scaled arrow
- From: RichT
- Re: Draw a scaled arrow
- References:
- Draw a scaled arrow
- From: RichT
- Re: Draw a scaled arrow
- From: Roedy Green
- Re: Draw a scaled arrow
- From: RichT
- Re: Draw a scaled arrow
- From: John B. Matthews
- Re: Draw a scaled arrow
- From: RichT
- Draw a scaled arrow
- Prev by Date: Re: which OutputStreams are buffered?
- Next by Date: Re: Hash Code
- Previous by thread: Re: Draw a scaled arrow
- Next by thread: Re: Draw a scaled arrow
- Index(es):
Relevant Pages
|