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]