This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: "Paul Gifford" <address@hidden>
>Organization:
>Keywords: 200312310359.hBV3xkp2021360 IDV tooltips
Hi Paul-
> How can I add tooltips to the leaves of trees (Data sources and Fields)?
>I find I need a little more room to describe the data sufficiently.
If you look at ucar.unidata.idv.ui.DataTree, the tooltips are set
as follows:
if (o instanceof DerivedDataChoice) {
DerivedDataChoice ddc = (DerivedDataChoice) o;
if (ddc.getFormula () != null) {
setToolTipText (ddc.getFormula ());
}
} else if (o instanceof DataChoice) {
DataChoice dc = (DataChoice) o;
setToolTipText ("<html> "+dc.getName()+"<br> "+dc.getDes
cription()+"</html>");
} else if (o instanceof DataSource) {
setToolTipText (((DataSource)o).getFullDescription ());
}
So for a DataChoice, you could control what's shown by passing in
a long description (using html tags if you want) in the constructor.
For the DataSource, the getFullDescription returns:
public String getFullDescription () {
return getDescription () + "<p>" + name;
}
so, you could either override this method in your subclass, or
use the constructor that passes in a description.
Let me know if you have any questions about this.
Don Murray