Class EditMode
is a ViewMode implementation
that provides support for presenting tooltips for both nodes and edges.
You can enable tooltip presentation using showNodeTips(true) for nodes
and showEdgeTips(true) for edges.
By default, the text that is displayed when tooltips are enabled is that of the first node label, respectively the first edge label.
You will find related information in the yFiles for Java Developer's Guide:
In the yFiles for Java API:
You can easily customize the tooltip text that is displayed for nodes and edges by subclassing EditMode and overriding the getNodeTip and getEdgeTip method, respectively. Figure 1.2, “Custom tooltip text” shows a customized node tooltip.
You can incorporate the code to create this presentation into the constructor of the simple graph editor application from the Creating a Simple Graph Editor trail, for example. The SimpleGraphEditor2Tooltips application already uses this code.
Example 1.1. Customizing the tooltip text for nodes using EditMode
editMode = new EditMode() {
protected String getNodeTip(Node node) {
Graph2D graph = (Graph2D)node.getGraph();
return
"<html>width x height: <b>" +
graph.getWidth(node) + "</b> x <b>" + graph.getHeight(node) +
"</b></html>";
}
};
|
Copyright ©2008-2009, yWorks GmbH. All rights reserved. |