Re: Draw a scaled arrow



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
.



Relevant Pages

  • Re: Creating a shape from a set of points
    ... I have a bunch of points ... Are you looking for the convex hull? ... Polygon is a particularly convenient ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.lang.java.programmer)
  • Re: Creating a shape from a set of points
    ... I have a bunch of points ... Polygon is a particularly convenient ... Todd should look at both and decide whether either is what ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.lang.java.programmer)
  • Re: Finding the "inside" of a polygon
    ... I will paint. ... to paint a dot in the center (the dot is much smaller that the polygon such ... Remember that the polygons are not true rectangles. ...
    (microsoft.public.dotnet.framework.drawing)
  • an string array problem
    ... const string commandSet[] = ...
    (microsoft.public.vc.language)