In this section, you are going to learn how to create
and manage nodes in your graph.
To create and manage nodes:
-
Create four nodes with the method
createNode()
of the Graph or the Diagram.If you use a Diagram widget, make sure to use the createNode function of the Diagram (ibm_ilog.diagram.widget.Diagram) class otherwise some features of the Diagram widget, like event dispatching, navigation, and editing do not work properly. -
Set the label on each node with the method
setLabel(label)
. -
Move the nodes with the method
move(x, y)
.
Use the following code if you use a Graph directly in
a GFX surface:
var createNode = function(label, x, y){ var node = graph.createNode(); node.setLabel(label); node.move(x, y); return node; };
Use the following code if you use a Diagram widget:
var createNode = function(label, x, y){ var node = diag.createNode(); node.setLabel(label); node.move(x, y); return node; };
At this stage, the graph looks as follows:
