Hi Dan,
Dan Slater <[email protected]> wrote on 02/09/2009 01:27:36 PM:
> SVGDocument doc = (SVGDocument)parElt.getOwnerDocument();
>
> Element a = doc.createElementNS(Intersection.svgNS, "a");
> parElt.appendChild(a);
>
> SVGUseElement use
> = (SVGUseElement)doc.createElementNS(svgNS, "use");
> use.setAttributeNS(xlinkNS, "xlink:href", "#receptor");
> use.setAttributeNS(null, "id",id);
> use.setAttributeNS(null, "x", xs);
> use.setAttributeNS(null, "y", ys);
>
> a.appendChild(use);
>
> Element title = doc.createElementNS(Intersection.svgNS,
"title");
> a.appendChild(title);
>
> Text txt = doc.createTextNode(id);
> title.appendChild(txt);
Try adding the text node before adding the title element
to the document (I don't think it matters but it might).
> ...and the <use> element displays correctly in the JSVGCanvas, sans
tooltip.
> The SVGGraphics2D output:
Hmm, how do you configure the Canvas? Do you set it to be
dynamic or interactive?
> <a xlink:type="simple" xlink:actuate="onRequest"
> xlink:show="replace" xmlns:xlink="http://www.w3.org/1999/xlink">
> <use xmlns:xlink="http://www.w3.org/1999/xlink"
> id="D1XS0R011"
> xlink:show="embed" xlink:type="simple" x="-35.0" y="107.0"
> xlink:href="#receptor" xlink:actuate="onLoad" />
> <title>D1XS0R011</title>
> </a>
>
> which, if I understand you correctly, should work. But it doesn't. For
> clarity, I stripped out some custom attributes and a transform from the
<use>
> element - I don't think that should make any difference (?).
This looks right to me.
> What Batik version did you use in your test? Could you please send
> me a snippet?
I used current trunk Batik, but I don't think anything has changed
in this area for a while. I used two tests, first was from the Batik
Distribution: samples/tests/spec/scripting/addDescOnClick.svg. I also
added an 'anchor' test row to samples/tests/spec/structure/toolTip.svg:
<g id="aRow" transform="translate(0, 220)">
<g fill="white" stroke="black" >
<rect x="0" y="0" width="60" height="20" />
<rect x="60" y="0" width="60" height="20" />
<rect x="120" y="0" width="60" height="20" />
<rect x="180" y="0" width="60" height="20" />
<rect x="240" y="0" width="60" height="20" />
</g>
<text x="30" y="15" class="label"><a></text>
<g id="aSamples" stroke="none" fill="blue"
text-anchor="middle">
<!-- No info -->
<!-- No info -->
<a xlink:href="#useElem"
><text transform="translate(60, 0)" x="30" y="15"
>Link!</text></a>
<!-- title -->
<a xlink:href="#useElem">
<text transform="translate(120, 0)" x="30" y="15"
>Link!</text>
<title><text> with <title> only</title>
</a>
<!-- desc -->
<a xlink:href="#useElem">
<desc><text> with <desc> only</desc>
<text transform="translate(180, 0)" x="30" y="15"
>Link!</text></a>
<!-- title and desc -->
<a xlink:href="#useElem">
<title>Title: <text> with <title> and
<desc></title>
<desc>Description: <text> with <desc>
and <desc></desc>
<text transform="translate(240, 0)" x="30" y="15"
>Link!</text></a>
</g>
</g> <!-- "aRow" -->
> [email protected] wrote:
> > Hi Dan,
> >
> > Dan Slater <[email protected]> wrote on 02/04/2009 02:26:28 PM:
> >
> >
> >> Does anyone have an example of code that results in a tooltip for a
> >> <use> element in a JSVGCanvas? This is unfortunately a long-standing
> >> unresolved problem I have [1]. That past example shows that, for a
Web
> >> page, it would work like so:
> >>
> >> <a xlink:href="http://www.gnote.org/" cursor="help"
> >> xlink:title="thinking about communication">
> >> <title>Thought bubbles</title>
> >> <use xlink:href="#communicate" x="90" y="-150" />
> >> </a>
> >>
> >
> >
> >> Indeed, "thinking about communication" pops up on mouseover.
> >>
> >
> > This should work for Batik, you will get a tool tip with
> > 'Thought bubbles' and not 'thinking about communication'.
> >
> >
> >> But I am developing for JSVGCanvas (Batik v1.6), not the Web. When I
> >> use this code:
> >>
> >> SVGElement elt =
(SVGElement)doc.createElementNS(Intersection.svgNS,
> >>
> >
> >
> >> "use");
> >> elt.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
> >> "#receptor");
> >> xlink.setXLinkTitle(elt, "test");
> >>
> >
> > You need to create an SVG 'title' element as your example shows and
> > put your tool-tip text in that.
> >
> >
> >> nothing pops up on hover. Nor when I wrap the <use> in an <a> and put
> >> xlink:title in the <a>. Nor when I explicitly set "xlink:title"
instead
> >>
> >
> >
> >> of using the XLinkSupport class, which just produces
'title="xyz"'....
> >>
> >
> > So we use the SVG native 'title' and 'desc' elements rather than
> > the xlink attributes.
> >
> >
> >> Element d = doc.createElementNS(Intersection.svgNS, "desc");
> >> Text t = doc.createTextNode(id);
> >>
> >> Element a = doc.createElementNS(Intersection.svgNS, "a");
> >> a.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:title",
> >>
> > "test");
> >
> >> //xlink.setXLinkTitle(a, "test");
> >>
> >> d.appendChild(t);
> >> elt.appendChild(d);
> >> a.appendChild(elt);
> >> parElt.appendChild(a);
> >>
> >> Any hints would be extremely welcome.
> >>
> >
> > This example should work and does work in my testing.
> > I'm not sure why it isn't working for you. You can drop all
> > of the 'xlink:title' stuff if you want for now.
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>