xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric MacMillan"<e...@nortelnetworks.com>
Subject Re: Add user info to SVG shapes
Date Wed, 24 Apr 2002 10:13:09 GMT
If it helps, here is a Java method that adds a <desc> tooltip to any element.
Seems to work.

  public void setDescTooltip( SVGOMDocument doc, Element element, String
desc_text )
  {
    // remove the old <desc> tooltip, if any
    NodeList    nodelist    = element.getElementsByTagNameNS(
SVGDOMImplementation.SVG_NAMESPACE_URI, "desc" );
    for (int i = 0; i < nodelist.getLength(); i++)
      element.removeChild( nodelist.item( i ) );

    // now add the new <desc> tooltip, if any
    if (desc_text != null) {
      // create a <desc> element and its text node which contains the tip text.

      Element       desc_element    = doc.createElementNS(
SVGDOMImplementation.SVG_NAMESPACE_URI, "desc" );
      Text          text_node       = doc.createTextNode( desc_text );
      desc_element.appendChild( text_node );

      // append the tooltip <desc> to the ID'd element
      element.appendChild( desc_element );
    }
  }

Enjoy.

Cheers,
    Eric


"MECHOULAM, Mickael" wrote:

> Hi,
>
> Thank you for your answer. However it seems to me the text in these <title>
> and <desc> tooltips cannot be formatted (new lines, colors etc...) so I
> suppose I must use scripting.
> Furthermore I still do not know how to insert the text of these tooltips in
> the SVG file : I suppose I will have to write a specific method for each
> figure that generates the SVG code and adds to it the text of the tooltips ?
>
> Mikael Mechoulam
>
> > -----Original Message-----
> > From: Thomas E Deweese [mailto:thomas.deweese@kodak.com]
> > Sent: Tuesday, April 23, 2002 5:09 PM
> > To: Batik Users
> > Subject: Add user info to SVG shapes
> >
> >
> >
> > Hi Mickael,
> >
> >    You might try using the <title> and <desc> elements.  If present
> > Batik will automatically show tooltips when the mouse hovers over the
> > associated graphics element.
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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


Mime
View raw message