Hi Don,

Sounds like you need to do some reading over the holidays :)

   My Recommended reading list is, the SVG DOM:
        
http://xml.apache.org/batik/javadoc/org/w3c/dom/svg/package-summary.html

   It (and all other graphics elements in SVG) implements the
EventTarget interface:

http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/java-binding.html

   This has the add/remove methods.  You may also want to read the
rest of the DOM Events spec (it's really not that large) as it
describes exactly how the events are dispatched in the document tree
in particular the roles of 'target' and 'currentTarget'.

   Finally I'm sure the PDF of my presentation at ApacheCON will keep
you up late at night anxious to see how it turns out :)

http://cvs.apache.org/~deweese/ac2003/ApacheCON2003.pdf

   If you snoop there is also an SVG version of the presentation but
it lacks the commentary which is probably of the most interest to you.
You may want to start with this as it will give you a high level
overview of many of the things that can be done with Batik.

Enjoy!

don undeen wrote:

Hi There,
I've been reading this thred with interest, because
I'm trying to accomplish something similar.
I'm using batik to generate SVG output for display in
a Java application. I'm putting text and lines (with
unique "id" attributes)  in the SVG display, and I
want the java app to be notified when the mouse passes
over, or is clicked on, a text or line element.
You say:"The easiest thing to do is add a DOM 'click'
event listener on the root SVG element."
If by "root SVG Element" you mean the element you get
from:
 DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
    this.svgDoc =
(SVGDocument)impl.createDocument(svgNS, "svg", null);
    this.svgRoot = svgDoc.getDocumentElement();

Then I don't see how to add a listener to svgRoot, as
it doesn't have any addListener methods. Neither does
svgDoc.

However, the svgCanvas I get from
this.svgCanvas = new JSVGCanvas();
does have listener Methods. Is that where I should
register a listener? And if so, could you tell me
which listener, and how to find out the id of the
clicked element?


Where does the DOMEvent come from?

Thanks in advance for any advice you can give me. I'm
really stimied on this one.

Yours,
Don Undeen (New member of this newsgroup)



--- Thomas DeWeese <[EMAIL PROTECTED]> wrote:

Jamie wrote:


Specifically then Thomas, would the call be:

documentX =

SVGElement.getScreenCTM(DOMEvent.getClientX());


documentY =

SVGElement.getScreenCTM(DOMEvent.getClientY());


No, you can take a look at:



samples/tests/spec/scripting/currentScaleTranslate.svg


   It does all the right things in JavaScript (look
at 'mouseOver')
you will have to translate back to Java but it's
pretty straight
forward.



----- Original Message -----
From: "Thomas DeWeese" <[EMAIL PROTECTED]>
To: "Batik Users" <[EMAIL PROTECTED]>
Sent: Thursday, December 18, 2003 11:33 AM
Subject: Re: Batik Question




Omar Abdala wrote:



I have a question about using Java Batik. I have

a JSVGCanvas within


which


I'm displaying SVG files. I want to add a

listener to it that will


listen


for mouse clicks on the Canvas and calculate the

point that was clicked


in


terms of the SVG files' coordinates. Is there

some standard way of doing


this or is it an easy calculation?

The easiest thing to do is add a DOM 'click'

event listener on the


root SVG element. Then you can use

SVGElement.getScreenCTM to get


the transform from any SVG element's coordinate

system to the screen


coordinate system (the coordinate system for

DOMEvent.getClientX/Y).






---------------------------------------------------------------------

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]




__________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.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]



Reply via email to