【发布时间】:2026-02-02 15:25:02
【问题描述】:
我完全是任何逻辑的菜鸟,现在我正在尝试通过代码制作简单的网络; (具有两个 pointNode 的网络,以及链接它们的路径) 遇到问题。
当我运行我的模型时,控制台显示“使用 initialize() 方法”,但我已经知道 在较低版本中不推荐使用初始化方法。 (我使用的是 8.5.1 版本)
如何通过代码创建路径
真的需要你的帮助
谢谢。
PointNode node1 = new PointNode();
node1.setPos(0, 0, 0);
node1.setDrawMode(SHAPE_DRAW_2D3D);
node1.setFillColor(black);
node1.setOwner(this);
node1.setRadius(10);
node1.setVisible(true);
presentation.add(node1);
PointNode node2 = new PointNode();
node2.setPos(100, 0, 0);
node2.setDrawMode(SHAPE_DRAW_2D3D);
node2.setFillColor(black);
node2.setOwner(this);
node2.setRadius(10);
node2.setVisible(true);
presentation.add(node2);
Path path1 = new Path();
path1.setBidirectional(true);
path1.setDrawingType(PATH_LINE);
path1.setDrawMode(SHAPE_DRAW_2D3D);
path1.setLineColor(black);
path1.setLineWidth(10);
path1.setOwner(this);
path1.setSource(node1);
path1.setTarget(node2);
path1.setVisible(true);
path1.toPath3D();
path1.initialize();
presentation.add(path1);
Network net1 = new Network(this,"aa");
net1.setDrawMode(SHAPE_DRAW_2D3D);
net1.setVisible(true);
net1.addAll(node1, node2, path1);
【问题讨论】: