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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]