端点如何在mxGraph中的边上工作?需要边缘以连接顶点的左侧中间高度

时间:2018-08-07 06:05:15

标签: mxgraph

edge = graph.insertEdge(parent,
                                null,
                                '',
                                vertex1,
                                vertex2);

var destX = vertex2.geometry.x;
var destY = vertex2.geometry.y;
var destHeight = vertex2.geometry.height;
var sourceX = vertex2.geometry.x;
var sourceY = vertex2.geometry.y;
var sourceHeight = vertex2.geometry.height;
edge.geometry.setTerminalPoint(new 
                         mxPoint(sourceX,sourceY+(sourceHeight/2)),true);
edge.geometry.setTerminalPoint(new 
                    mxPoint(destX,destY+(destHeight/2)),false);
edge.geometry.relative = true;

这将创建默认边。请假定已插入顶点。

1 个答案:

答案 0 :(得分:0)

仅当边缘未连接时才需要终端点,并且终端点分别存储在sourcePoint>和targetPoint变量中。

https://jgraph.github.io/mxgraph/docs/js-api/files/model/mxGeometry-js.html#mxGeometry