显示Diagram模型
到目前为止,仅仅显示了一个节点(Node)的图形,如何显示多个节点,也就是一个Diagram的模型呢?
我们修改NodeGefView类的showDiagram()方法,创建Diagram模型,并且创建两个Node模型,加入到Diagram中。
private void showDiagram() { Diagram diagram = new Diagram(); Node node = new Node(); node.setText("测试节点"); node.setLocation(new Point(10, 10)); diagram.addNode(node); Node node2 = new Node(); node2.setText("测试节点"); node2.setLocation(new Point(10, 70)); diagram.addNode(node2); graphicalViewer.setContents(diagram); }
但是运行时发现,现在视图上无显示,连上一步显示的Node模型对应的矩形框都没有了。
Continue reading


