Arrowheads for link lines?

15 views
Skip to first unread message

jles...@gmx.de

unread,
Apr 17, 2014, 5:35:49 AM4/17/14
to piccolo...@googlegroups.com
Hello everybody
I am planning to build something like a graph editor supporting directed links between square-shaped nodes. I started with the nice little GraphEditorExample from the Piccolo distribution, but know I'd like to introduce arrorheads for the link lines. The heads should be placed at the point where the line crosses a node border (see attached figure). From my first design steps, it seems to become a pretty complecated mathematical challenge to calculate the coordinates of these points. Is there any kind of support for these kinds of calculations?

Regards,
Jan

arrowhead.png

Martin Klussmann

unread,
Apr 18, 2014, 1:54:20 AM4/18/14
to piccolo...@googlegroups.com
Hi Jan.

> Is there any kind of support for these kinds of calculations?

As far as I know, in Piccolo2D there is not.

If you are restricted to square-shaped nodes, you should accept the
mathematical challenge (think of atan2). For arbitrary shapes the
intersection can become a tough task. For example, see:
http://stackoverflow.com/questions/15545496/get-intersection-points-of-line-and-shape

Martin

jles...@gmx.de

unread,
Apr 18, 2014, 1:38:14 PM4/18/14
to piccolo...@googlegroups.com
Hi Martin
Thanks for your answer. Yes, I only have to care for sqares. Funny that AWT's Rectangle2D.Double class, which PBounds derives from, has functions to find out, *if* a line intersects with a rectangle, but not *where* they intersect ;-)

Anyway. I copied some code from the net which does the job.

Regards,
Jan
Reply all
Reply to author
Forward
0 new messages