Because our legacy UI only stored link midpoints in the database we have to calculate the start and end points for links. This code works but but the link centers on the entire node instead of the port.
midpoints = change.midpoints;
if (midpoints.length > 0) {
points = new go.List(go.Point);
link = diagram.goDiagram.findLinkForData(e.model.findLinkDataForKey(change.key));
node = diagram.goDiagram.findNodeForKey(change.from);
points.add(link.getLinkPointFromPoint(node, node.port, node.actualBounds.center, midpoints[0], true));
Ext.each(midpoints, function(midpoint) {
points.add(new go.Point(midpoint.x, midpoint.y));
}, me);
node = diagram.goDiagram.findNodeForKey(change.to);
points.add(link.getLinkPointFromPoint(node, node.port, node.actualBounds.center, midpoints[midpoints.length - 1], false));
link.points = points;
}
Here is what it looks like.
This code above link.getLinkPointFromPoint(node, node.port, node.actualBounds.center, midpoints[0], true)
returns this toString “Point(180.09090825612827,119.99986226116681)”
Changing it to link.getLinkPointFromPoint(node, node.port, node.port.actualBounds.center, midpoints[0], true)
returns this toString “Point(NaN,NaN)”
Any idea on what I’m doing wrong or suggestions on how to get link to center of port instead of node?