Drawing arrows in JavaFX

Some time in the past, I was wondering what’s the easiest solution for drawing arrowconnections between shapes. The problem boils down to computing boundary point for given shape, which intersects with connecting line. The solution is not so difficult …Some time in the past, I was wondering what’s the easiest solution for drawing arrowconnections between shapes. The problem boils down to computing boundary point for given shape, which intersects with connecting line. The solution is not so difficult …

Some time in the past, I was wondering what’s the easiest solution for drawing arrowconnections between shapes. The problem boils down to computing boundary point for given shape, which intersects with connecting line.
The solution is not so difficult when we consider polygon shapes. But it becomes more difficult considering curves and far more difficult for generic SVG shapes.
In this article, I show a simple way to find such boundary points for generic SVG shapes, utilizing JavaFX “contains” method and simple bisection algorithm.
Following application does the job: Launch JNLP,Browse on GitHub.
Application allows to drag shapes to track shape boundaries.

So, “contains” method in JavaFX allows us to poll any 2D point for intersection with SVG shape. Next, we need to assume, that we know a point inside a shape, from which every ray has exactly one intersection. This includes star-like shapes and ellipses. Next, we can use simple bisection algorithm to find such boundary point. We cut off once length between two points is too small. Following snippet does the job:

Next, we need to draw arrows on the ends. In order to do that, we can use JavaFX Affine Transform, which is matrix transformation for SVG path. We need to compute transformation vectors for the matrix. This sounds scarry, but in fact is relatively easy. First vector in matrix is (targetPoint – sourcePoint) / length. Second one is perpendicular to it. Following code applies transformation:

Indeksy na kolumnach z wartościami nullowymi cz. 2

Jest jeszcze jeden sposób indeksowania, który pozwala nam na bardzo wygodne korzystanie z indeksów i wyszukiwanie wartości nullowych.…

Test Driven Traps, part 2

The Story of a Unit in Unit Tests In the previous part of this article, you could see…

EhCache config with BeanUtils

BeanUtils allows you to set Bean properties.If you have configuration stored in a Map it's tempting to use BeanUtils to automagically setup EhCache configuration.Sadly this class has mixed types in setters and getter and thus BeanUtils that use Introsp...