如何通过编程将mxgraph中的正交边连接到顶点上的精确点。
我已经完成了“手动”连接到顶点上的精确点的操作。在这种情况下,每当您移动源/目标终端时,该线就会正交重建正确的
v1 = graph.insertEdge(parent, line.id, "line", source, dest,"edgeStyle=orthogonalEdgeStyle");
//create Segments of the line
v1.getGeometry().points = points;
//Set terminals, actually it works in constructor, it's just manual tries to set exact point
v1.geometry.setTerminalPoint(new mxPoint(1,0.5),true);
v1.geometry.setTerminalPoint(new mxPoint(0,0.5),false);
v1.geometry.relative = true;
预期的行为必须像是从编辑器创建的edge那样。这意味着端点始终与连接点保持正交,并且不按顶点的周长移动。换句话说,如何使连接点固定并保持正交边
更新: 解决方案是在从mxGraph手动创建边缘之后设置约束:
v1 = graph.insertEdge(parent, line.id, "line", source, dest,"edgeStyle=orthogonalEdgeStyle");
//create Segments of the line
v1.getGeometry().points = points;
graph.setConnectionConstraint(v1, source, true, new mxConnectionConstraint(new mxPoint(1, 0.5), true))
graph.setConnectionConstraint(v1, dest, false, new mxConnectionConstraint(new mxPoint(0, 0.5), true))