You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Omar Abdala <ot...@MIT.EDU> on 2003/12/17 19:19:18 UTC

Batik Question

Hi,
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?
Thanks,
Omar


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by Thomas DeWeese <Th...@Kodak.com>.
don undeen wrote:

> wow, thanks for your swift reply, Thomas.
> 
> I read your pdf presentation (I can tell I'll be
> referring to that document quite a bit in the future,
> thank you!), particularly the part with the code
> snippet:
> document = canvas.getSVGDocument();
> elem = document.getElementById("foo");
> elem.addEventListener([event-type],[listener],[use-capture]);
> 
> That makes sense to me, but my difficulty is that elem
> doesn't seem to have a method named addEventListener.
> The interface for org.w3c.dom.Element doesn't describe
> any such method, and I get compile errors saying
> there's no such method.
> 
> am I using the wrong version of something?

Hi Don,

    Sorry, you need to down cast to an EventTarget.
    So the code snippet should be:

    ((EventTarget)elem).addEventListener(....);

    The example came from JavaScript where this isn't needed.

> 
> yours,
> Don
> 
> --- Thomas DeWeese <Th...@Kodak.com> wrote:
> 
>>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 <Th...@Kodak.com>
>>
>>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" <Th...@Kodak.com>
>>>>>To: "Batik Users" <ba...@xml.apache.org>
>>>>>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:
>>>>
>>>>batik-users-unsubscribe@xml.apache.org
>>>>
>>>>
>>>>>>For additional commands, e-mail:
>>>>
>>>>batik-users-help@xml.apache.org
>>>>
>>>>
>>>>>
> === message truncated ===
> 
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by don undeen <do...@yahoo.com>.
wow, thanks for your swift reply, Thomas.

I read your pdf presentation (I can tell I'll be
referring to that document quite a bit in the future,
thank you!), particularly the part with the code
snippet:
document = canvas.getSVGDocument();
elem = document.getElementById("foo");
elem.addEventListener([event-type],[listener],[use-capture]);

That makes sense to me, but my difficulty is that elem
doesn't seem to have a method named addEventListener.
The interface for org.w3c.dom.Element doesn't describe
any such method, and I get compile errors saying
there's no such method.

am I using the wrong version of something?

yours,
Don

--- Thomas DeWeese <Th...@Kodak.com> wrote:
> 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 <Th...@Kodak.com>
> 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" <Th...@Kodak.com>
> >>>To: "Batik Users" <ba...@xml.apache.org>
> >>>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:
> >>
> >>batik-users-unsubscribe@xml.apache.org
> >>
> >>>>For additional commands, e-mail:
> >>
> >>batik-users-help@xml.apache.org
> >>
> >>>>
> >>>
> >>>
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by Thomas DeWeese <Th...@Kodak.com>.
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 <Th...@Kodak.com> 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" <Th...@Kodak.com>
>>>To: "Batik Users" <ba...@xml.apache.org>
>>>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:
>>
>>batik-users-unsubscribe@xml.apache.org
>>
>>>>For additional commands, e-mail:
>>
>>batik-users-help@xml.apache.org
>>
>>>>
>>>
>>>
>>>
> ---------------------------------------------------------------------
> 
>>>To unsubscribe, e-mail:
>>
>>batik-users-unsubscribe@xml.apache.org
>>
>>>For additional commands, e-mail:
>>
>>batik-users-help@xml.apache.org
>>
>>
>>
>>
>>
> 
> ---------------------------------------------------------------------
> 
>>To unsubscribe, e-mail:
>>batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail:
>>batik-users-help@xml.apache.org
>>
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by don undeen <do...@yahoo.com>.
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 <Th...@Kodak.com> 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" <Th...@Kodak.com>
> > To: "Batik Users" <ba...@xml.apache.org>
> > 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:
> batik-users-unsubscribe@xml.apache.org
> >>For additional commands, e-mail:
> batik-users-help@xml.apache.org
> >>
> >>
> > 
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> batik-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> batik-users-help@xml.apache.org
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> batik-users-help@xml.apache.org
> 


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by Thomas DeWeese <Th...@Kodak.com>.
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" <Th...@Kodak.com>
> To: "Batik Users" <ba...@xml.apache.org>
> 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: batik-users-unsubscribe@xml.apache.org
>>For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by Jamie <ja...@exponent.co.uk>.
Specifically then Thomas, would the call be:

documentX = SVGElement.getScreenCTM(DOMEvent.getClientX());
documentY = SVGElement.getScreenCTM(DOMEvent.getClientY());

??

----- Original Message -----
From: "Thomas DeWeese" <Th...@Kodak.com>
To: "Batik Users" <ba...@xml.apache.org>
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: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Batik Question

Posted by Thomas DeWeese <Th...@Kodak.com>.
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: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org