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 J Aaron Farr <ja...@yahoo.com> on 2002/07/24 15:49:14 UTC

More on linking...

Hello again.

Yesterday I posted about some issues I had with xlinks in batik.  I'm still
having some troubles, and I don't quite understand how batik is handling links.
 So I started looking around in the batik source code and I have some
questions.  If anyone could enlighten me, I'd really appriciate it.

The LinkActionEvent code looks like this (if this is outdated, let me know, but
I think it's the latest):

public class LinkActivationEvent extends EventObject {
    protected String referencedURI;

    public LinkActivationEvent(Object source, SVGAElement link, String uri) {
        super(source);
        referencedURI = uri;
    }

    public String getReferencedURI() {
        return referencedURI;
    }
}

So my first question is, why is the SVGAElement in the contructor?  And where
does it go?  Why is it not used?

I tried accessing it by changing the code to save the SVGAElement "link"
variable to a local variable called "referencedLink" and added a getter for it.
 Then in my LinkActionListener I have the following code:

  public void linkActivated(LinkActivationEvent evt) {
       String uri = evt.getReferencedURI();
       System.out.println(uri);
       SVGAElement link = evt.getReferencedLink();
       System.out.println("Link: "+link.getNodeName());
       SVGAnimatedString animatedString = link.getHref();
       NamedNodeMap atts = link.getAttributes();
       for(int i=0; i < atts.getLength(); i++){
         System.out.println("Attribute"+i+": "+atts.item(i).getNodeName()+"= "+
                             getValue(atts.item(i));
          // getValue(Node n) is a local method that returns a string
          // equal to the value of any children text nodes
       }
       System.out.println("XLINK:"+link.getAttribute("xlink:href"));
       System.out.println("AnimVal: "+ animatedString.getAnimVal());
       System.out.println("BaseVal: "+animatedString.getBaseVal());
       ...
   }

Now first off the SVGAnimatedString.getAnimVal() has yet to be implemented, so
I commented that out.  Then I tried it on this link (saved in an SVG file named
mimiclink.svg):

<a xlink:type="simple" xlink:actuate="onRequest"
   xlink:href="http://myserver.com">
 <text x="40" y="40" style="font-family: sans-serif; font-size: 24pt; 
                    stroke:none; fill: black;">Title</text>
</a>

And I get this output:

file://uspitfil03/users/farra/My Documents/mimiclink.svg
Link: a
Attribute0: xmlns:xlink= http://www.w3.org/1999/xlink
Attribute1: xlink:href= http://myserver.com
Attribute2: xlink:type= simple
Attribute3: xlink:type= simple
Attribute4: xlink:actuate= onRequest
Attribute5: xlink:show= replace
Attribute6: xlink:actuate= onRequest
XLINK:
BaseVal:


When I try it on the "anchor.svg" file in the batik samples/tests/spec/linking
directory, I get the following output:


file:/C:/cygwin/opt/java/batik-1.5/samples/tests/spec/linking/anchor.svg#svgView
(viewBox(3,2.5,4,4))
Link: a
Attribute0: xlink:type= simple
Attribute1: xlink:actuate= onRequest
Attribute2: xlink:show= replace
Attribute3: xmlns:xlink= http://www.w3.org/1999/xlink
Attribute4: xlink:href= #svgView(viewBox(3,2.5,4,4))
XLINK:
BaseVal: #svgView(viewBox(3,2.5,4,4))

So my question is: is this the only way to get the value of the HREF attribute
for the xlink?  Why do I not get a return from link.getAttribute("xlink:href")?
 And why is there no getter for the SVGAElement "link" in the LinkActionEvent
class?  Any thoughts?

Thank you!
jaaron

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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


Re: More on linking...

Posted by J Aaron Farr <ja...@yahoo.com>.
--- Thomas E Deweese <th...@kodak.com> wrote:
> >>>>> "JAF" == J Aaron Farr <ja...@yahoo.com> writes:
> 
> JAF> So my question is: is this the only way to get the value of the
> JAF> HREF attribute for the xlink?  Why do I not get a return from
> JAF> link.getAttribute("xlink:href")?  
> 
>      Because the correct way to access the href attribute in the xlink
> namespace is:
> 
>      link.getAttributeNS("http://www.w3.org/1999/xlink", "href");
> 

Thank you for the clarification.

> JAF> And why is there no getter for the SVGAElement "link" in the
> JAF> LinkActionEvent class?  Any thoughts?
> 
>      I don't know for certain, if I had to guess there were concerns
> about memory leaks...
> 

Memory leaks?  I don't quite understand why that would be an issue, however, is
there any chance that this change could end up in the final code?  Otherwise,
is there some other way to get the xlink:href value in the LinkActionListener
class?

Thanks,
jaaron

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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


More on linking...

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "JAF" == J Aaron Farr <ja...@yahoo.com> writes:

JAF> So my question is: is this the only way to get the value of the
JAF> HREF attribute for the xlink?  Why do I not get a return from
JAF> link.getAttribute("xlink:href")?  

     Because the correct way to access the href attribute in the xlink
namespace is:

     link.getAttributeNS("http://www.w3.org/1999/xlink", "href");

JAF> And why is there no getter for the SVGAElement "link" in the
JAF> LinkActionEvent class?  Any thoughts?

     I don't know for certain, if I had to guess there were concerns
about memory leaks...


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