gpt4 book ai didi

javascript - Draw2D : How to use a port as source/target for more than one connection?

转载 作者:行者123 更新时间:2023-11-30 18:10:13 26 4
gpt4 key购买 nike

因此,我正在尝试将我的类(class)作为个人项目构建,我决定使用 Draw2D,因为我认为它非常完整。我将类(class)表示为矩形并在它们之间设置连接以显示哪些类(class)是其他类(class)的先决条件,如下所示:

Course list with dependencies我遇到的问题是,当试图使同一个端口成为两个连接的源时,它只需要一个而忽略另一个。有任何想法吗?下面是一个快速示例:

$(window).load(function () {
// Create the paint area. The id in the constructor must be
// an existing DIV
var canvas = new draw2d.Canvas("gfx_holder");

// create and add two nodes which contains Ports (In and OUT)
var start = new draw2d.shape.node.Hub();
var startLocator = new draw2d.layout.locator.BottomLocator(start);
var startLocator2 = new draw2d.layout.locator.BottomLocator(start);

var startPort = start.createPort("output", startLocator);
var end = new draw2d.shape.node.End();
var end2 = new draw2d.shape.node.End();

canvas.addFigure( start, 400,100);
canvas.addFigure( end, 200,150);
canvas.addFigure( end2, 600,150);

var c = new draw2d.Connection();
c.setTargetDecorator(new draw2d.decoration.connection.ArrowDecorator());
c.setSource(startPort);
c.setTarget(end.getInputPort(0));
canvas.addFigure(c);


var c2 = new draw2d.Connection();
c2.setTargetDecorator(new draw2d.decoration.connection.ArrowDecorator());
c2.setSource(startLocator2);
c2.setTarget(end2.getInputPort(0));
canvas.addFigure(c2);
});

最佳答案

我怀疑您的问题出在 setSource 函数调用上。

c.setSource(startPort);
c2.setSource(startLocator2);

一个好像是指定端口,另一个是定位器。

关于javascript - Draw2D : How to use a port as source/target for more than one connection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14779587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com