self.canvasContext.diagram.layout.doLayout = function (coll) {
go.LayeredDigraphLayout.prototype.doLayout.call(this, coll);
self.createBoundary(); // this method is creating boundary over all the nodes
};
In previous version(1.4.8) it was working fine but in latest version it the boudary node is not coming on right place.
I have created the boundary node by calculating the left most,top most, bottom most and right most nodes positions and in previous version the position of the boundary coming perfect but in new version it is not coming on right position. the height and width is correct but the both nodes position is not correct.
Could you provide more information so that we can help you? What does createBoundary actually do? Does the layout still work reasonably well? (Note that exact positioning and sizing is not always guaranteed.)
You might want to override LayeredDigraphLayout | GoJS API to get boundary information. Or just call Diagram.computePartsBounds after the layout has finished.
//draw the rectangle on canvas
createBoundary: function () {
if (!this.collection) {
return;
}
if (this.collection.length === 1) {
self.removeBoundaries();
return;
}
var operationDiagrams = this.collection.models,
requieredBoundariesCount = operationDiagrams.length,
boundariesCount = self.countBoundaries(),
recreateBoundaries = boundariesCount !== requieredBoundariesCount,
index, operationDiagramModel, newKey, id, odId, data, cord, boundary, rectangleShape;
if (recreateBoundaries) {
self.removeBoundaries();
}
for (index = 0; index < operationDiagrams.length; index++) {
self.canvasContext.diagram.startTransaction("Set Model");
operationDiagramModel = operationDiagrams[index];
newKey = this.getNewNodeKey();
id = operationDiagramModel.get("id");
odId = operationDiagramModel.cid;
if (id && id > 0) {
odId = id;
}
data = self.getOdNodes(operationDiagramModel);
cord = self.getCordinatesFromNodes(data.nodes, data.isDCNodeExists, odId);
boundary = null;
if (recreateBoundaries) {
//add new boundary
this.canvasContext.diagram.model.addNodeData({
key: newKey, category: Enum.nodeType.boundaryNode, text: "text " + newKey, odID: odId,
boundaryColor: this.nodeUtil.getCSSStyleValue("OD-inactive-boundary")
});
boundary = self.canvasContext.diagram.findNodeForKey(newKey);
}
else {
boundary = self.findBoundaryByOdId(odId);
}
if (boundary) {
rectangleShape = boundary.findObject("rectangleShape");
if (rectangleShape) {
rectangleShape.setProperties({
width: cord.width, height: cord.height
});
}
console.log(cord.x + "<--->" + cord.y);
boundary.setProperties({ position: new go.Point(cord.x, cord.y) });
//at this point the position is correct for this boundary node but after animation is finished the position is being changed
console.log(boundary.position);
}
self.canvasContext.diagram.commitTransaction("Set Model");
}
if (self.canvasContext.currentNode && !self.currentActiveODId) {
self.currentActiveODId = self.canvasContext.currentNode.data.odID;
}
self.boundaryNodeClicked(self.currentActiveODId);
},
in this method i am creating node if needed else i am repositioning the existing node but when i am repositioning it, at the moment it is showing the current position in console but after animation is finished its position is being changed i don’t know why this is happening.