Hi all,

   The easiest way to do this is with
'SVGSVGElement.getIntersectionList'.  Which lets you provide
a rectangle and it will return all the elements that intersect
that rect.

Andres Toussaint wrote:
b.) Programatically generate a DOM MouseEvent with your centroid coordinates, to trigger the MouseEvent on the desired Element. I have done no research on how to do this second approach, but it makes a lot of sense to me, to tell the DOM to trigger a mouse event with specific coordinates, so the underlying routines select the receiver target and trigger the event.
Thomas: Can this be done?

Yes it can... Sort of. You use dom.events.DocumentEvent.createEvent (on the Document object) to create an event instance. Then you can
dispatch it with dispatchEvent the problem is that you already have to
know what element you want to dispatch it to (i.e. what element is under
the point). So you really want to use getIntersectionList.


Whatever the approach, you need to make sure the coordinates indicated in your centroid are in SVG coordinate space, as indicated in the Drag tutorial.

Yes, you must have a clear idea what coordinate system you are working in. getIntersectionList can also be nice in this regard as it takes care of much of the coordinate system work you just have to get it to the root SVG element's coordinate system.

On Apr 30, 2005, at 3:34 PM, Archie Cobbs wrote:

Brian Johnson wrote:

I'm new to Batik and naive in Java, though experienced in older languages and graphics environments. I have a student who is working to combine various technologies into a Java application--including SVG files and sketch recognition. The basic strategy is to load an externally generated SVG file which has associated style ID's with <g> elements, display this graphpic, allow the user to sketch marks on top of the SVG, categorize the sketch gesture, identify what was "under" the sketch, and then produce a folllow-up action. We're now at the point where we need to identify the element. We know where (in terms of the overlayed Java Graphics world) the centroid of the sketch was and want to query the SVG for the ID of the nearest element "under" this sketch.


You can use the org.w3c.dom.events.EventTarget and
org.w3c.dom.events.MouseEvent classes to detect mouse over,
mouse click, etc. events by registering the appropriate
listener(s). Pretty much any SVGElement in the DOM can be
cast to an EventTarget.

-Archie

_______________________________________________________________________ ___
Archie Cobbs * CTO, Awarix * http://www.awarix.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:  [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to