--- George Armhold <[EMAIL PROTECTED]> wrote:
> What is the proper way to launch an external web browser when a web
> link is clicked inside the JSVGComponent/JSVGCanvas?  Is there direct
> support for this, or must I listen for mouse clicks and do it by hand?
> I notice that when I hover over a link such as "http://xml.apache.org";
> the cursor changes to a hand; when I click it seems to try and load
> the URL as an SVG document in the canvas.  Is there a way to direct it
> to load a web page (externally) instead?  I'm using Java Web Start,
> which provides a means for launching an external browser; I just need
> to get the event/url.
> 
> Thanks
> 
> 
> -- 
> George Armhold
> Rutgers University
> eLearning Grant, DCIS

Well, here's one way:

1. Create a new class which implements
org.apache.batik.swing.svg.LinkActionListener .

2. In your new LinkActionListener, open your new browser (or whatever else you
need to do) within the "linkActivated()" method. 

3. Add your LinkActionListener to the JSVGCanvas:
    svgCanvas.addLinkActionListener( myLinkActionListener );

And really it's as simple as that ... or well it should be.

The problem is with #2.  The LinkActionListener.linkActivated() method is
passed a LinkActionEvent.  From the LinkActionEvent you can retrieve a
referenced URI (as a string), but you cannot retrieve the "link" element itself
(as an SVGElement).  A while ago I had this problem, but for some reason I
needed information from the link element itself, not just the URI.  My solution
was to change the batik LinkActionEvent source code so as to save the link
element so I could access it in the LinkActionListener.  I just checked the
latest sources and the problem still exists.  I still don't understand why the
LinkActionEvent doesn't have a getter for the link SVGElement object since that
object _is_ passed to it in its constructor.  If it's not being used or saved,
then why even pass it?

My original email about this can be found at
http://koala.ilog.fr/batik/mlists/batik-users/archives/msg01922.html.

If you only need the URI then this solution works very well and is fairly
simple.  If anyone has some better solutions I would love to know about them.

Thanks.
jaaron

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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

Reply via email to