1

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

具有依赖关系的课程列表 我遇到的问题是,当试图将同一个端口作为两个连接的源时,它只需要一个而忽略另一个。有任何想法吗?下面是一个快速示例:

$(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);
});
4

1 回答 1

2

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

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

一个似乎指定了一个端口,另一个似乎指定了一个定位器。

于 2013-02-08T19:12:10.133 回答