Created
July 23, 2013 21:30
-
-
Save davidjgraph/6066353 to your computer and use it in GitHub Desktop.
Patch for edge bounds calculation in mxGraph.getBoundingBoxFromGeometry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mxGraph.prototype.getBoundingBoxFromGeometry = function(cells, includeEdges) | |
{ | |
includeEdges = (includeEdges != null) ? includeEdges : false; | |
var result = null; | |
if (cells != null) | |
{ | |
for (var i = 0; i < cells.length; i++) | |
{ | |
if (includeEdges || this.model.isVertex(cells[i])) | |
{ | |
// Computes the bounding box for the points in the geometry | |
var geo = this.getCellGeometry(cells[i]); | |
if (geo != null) | |
{ | |
var pts = geo.points; | |
if (pts != null && pts.length > 0) | |
{ | |
var tmp = new mxRectangle(pts[0].x, pts[0].y, 0, 0); | |
var addPoint = function(pt) | |
{ | |
if (pt != null) | |
{ | |
tmp.add(new mxRectangle(pt.x, pt.y, 0, 0)); | |
} | |
}; | |
for (var j = 1; j < pts.length; j++) | |
{ | |
addPoint(pts[j]); | |
} | |
addPoint(geo.getTerminalPoint(true)); | |
addPoint(geo.getTerminalPoint(false)); | |
geo = tmp; | |
} | |
if (result == null) | |
{ | |
result = new mxRectangle(geo.x, geo.y, geo.width, geo.height); | |
} | |
else | |
{ | |
result.add(geo); | |
} | |
} | |
} | |
} | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment