|
|
|
Re: Tooltips for Edges [message #1749945 is a reply to message #1749866] |
Wed, 14 December 2016 08:40   |
|
Hi Thomas,
JavaFX provides Tooltip [1] that can be installed to a JavaFX Node in the scene graph. Within Zest such a Tooltip is installed for nodes if they specify a tooltip text via their attributes (ZestProperties#TOOLTIP__N).
Currently, Zest does not provide tooltips for edges (or edge labels). In order to support such functionality, you would need to subclass EdgePart (or EdgeLabelPart) and specialize doRefreshVisual() as follows:
public class CustomEdgePart extends EdgePart {
private Tooltip tooltip;
@Override
public void doRefreshVisual(Connection visual) {
super.doRefreshVisual(visual);
// refresh tooltip
Map<String, Object> attr = getContent().getAttributes();
boolean hasTooltip = false;
if (attr.containsKey("tooltip")) {
String tooltipText = attr.get("tooltip");
if (hasTooltip = tooltipText != null && !tooltipText.isEmpty()) {
if (tooltip == null) {
tooltip = new Tooltip(tooltipText);
Tooltip.install(visual);
} else {
tooltip.setText(tooltipText);
}
}
}
if (!hasTooltip && tooltip != null) {
Tooltip.uninstall(visual, tooltip);
tooltip = null;
}
}
}
I think it is a good idea to support tooltips for edges and labels, so feel free to file a Bugzilla ticket for the missing functionality [2].
[1] https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Tooltip.html
[2] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GEF
Best regards,
Matthias
|
|
|
|
Powered by
FUDForum. Page generated in 0.02282 seconds