In this section, you will learn how to add
two Node instances to
a Graph instance and
two VisualNode instances to
a VisualGraphView instance.
Example 3.4. Adding two Node instances to a Graph
// add nodes to graph graphModel.addNode(nodeA); graphModel.addNode(nodeB); graphModel.addNode(nodeC);
The example above is quite trivial. All you do is tell the graph to add nodes using the
addNode(Node) method, which is part of the more abstract interface
GraphObjectContainer.
If you are using the ModelBasedGraphController class with your
Graph model, VisualNode objects are
created and inserted into your view the moment they are created in the model. For this
reason, you are not required to create them explicitly, unless of course you are using
another type of controller which does not support this behavior. Please read the
MVC chapter for more details about other
GraphController implementations which require you to explicitly
insert VisualNode objects into your view.
© 2004, 2005 Tensegrity Software GmbH