Sorry, didn't mean to be proprietary or anything, just not proud of this
kludge.
Here is the code. added to my child class of JSVGCanvas. Basically this
listener checks for a hit
on each run and then checks to see if the delimiter is an <a> element. The
<a> element does not show up
in the GVT tree in any other fashion (to my understanding).
Sorry about the formatting etc. I'll have to clean this code later.
protected void newEventHandler(){
eventDispatcher.addGraphicsNodeMouseListener(new
GraphicsNodeMouseAdapter(){
public void mouseClicked(GraphicsNodeMouseEvent evt){
GraphicsNode _gnode = evt.getRelatedNode();
if(!(_gnode instanceof TextNode))
return;
TextNode _textNode = (TextNode)_gnode;
System.out.println("x = " + evt.getX() + " y = " +
evt.getY());
java.util.List _list = _textNode.getTextRuns();
for(int i = 0 ; i < _list.size(); i++){
org.apache.batik.gvt.renderer.StrokingTextPainter.TextRun
run =
(org.apache.batik.gvt.renderer.StrokingTextPainter.TextRun)_list.get(i);
AttributedCharacterIterator aci =
run.getACI();
TextSpanLayout layout = run.getLayout();
TextHit textHit =
layout.hitTestChar(evt.getX(), evt.getY() - 10);
if (textHit != null && layout.getBounds()
.contains(evt.getX(),
evt.getY()-10)) {
System.out.println("delim =" +
aci.getAttribute(TextAttribute.TEXT_COMPOUND_DELIMITER));
Object _delimiter = aci
.getAttribute(TextAttribute.TEXT_COMPOUND_DELIMITER);
if(! (_delimiter instanceof
SVGAElement))
break;
String _href = XLinkSupport
.getXLinkHref((SVGAElement)
_delimiter);
System.out.println("Href = " +
_href);
loadSVGDocument(_href);
}//if texthit
}//for runs
}//mouseClicked(..)
});//addlistener
};//newEventHandler()
-----Original Message-----
From: Stephane Hillion [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 11:39 AM
To: Batik Users
Subject: RE: GraphicsNode MouseSupport
> I had to listen for clicks and
> then check all the runs of the GVTTextNode for one who's
> TextAttribute.TEXT_COMPOUND_DELIMITER was an SVGAElement.
>
> This is kinda clunky. Anyone have a better idea?
>
No better idea, but perhaps can we integrate something like this in Batik to
make the anchors work in text elements.
It would be cool if you could give us more details (pseudo code?) about the
way you handled that.
Thanks,
Stephane.
---------------------------------------------------------------------
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]