xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Van Uffelen <stefan.vanuffe...@uzleuven.be>
Subject Clicking on SVG elements in the JSVGCanvas
Date Wed, 09 Nov 2011 12:25:19 GMT

I'm making an application that opens SVG files in a JSVGCanvas. The application loads SVG-files
from an external source and
Displays the JSVGCanvas wrapped in a JScrollPane which, in his turn, is wrapped in a Jframe.
My JSVGCanvas is set to ALWAYS_STATIC:


I do this to prevent a memoryleak from occuring. Now i wanted to add mouselistener that can
give me the SVG element you clicked
On. My SVG consists of only <rect> and <circle> elements. Also text elements excist
within the SVG. But those don't need to be clickable.
First I made a list of all the <rect> and <circle> elements  with:


Now i can get the X and Y position of each of the elements in the lists returned by the method
calls above. The problem now is that the
Mouseclick X and Y values are very different from the X and Y from the nearest element. The
problem gets even worse when u rescale
The SVG.

Does batik provide an easy way to know which element is nearest to the point the user clicked
on? Or is there anyway to convert the
SVG coördinates to screen coördinates?

The application is running on windows 7 with JDK 1.6 using the latest version of batik.


View raw message