private void convertPositionsToPercentage(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle layoutBounds, boolean includeNodeSize) {
// Adjust node positions and sizes
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode node = entitiesToLayout[i];
DisplayIndependentPoint location = node.getInternalLocation().convertToPercent(layoutBounds);
node.setInternalLocation(location.x, location.y);
if (includeNodeSize) { // adjust node sizes
double width = node.getInternalWidth() / layoutBounds.width;
double height = node.getInternalHeight() / layoutBounds.height;
node.setInternalSize(width, height);
}
}
// Adjust bendpoint positions
for (int i = 0; i < relationships.length; i++) {
InternalRelationship rel = relationships[i];
for (int j = 0; j < rel.getBendPoints().size(); j++) {
BendPoint bp = (BendPoint) rel.getBendPoints().get(j);
DisplayIndependentPoint toPercent = bp.convertToPercent(layoutBounds);
bp.setX(toPercent.x);
bp.setY(toPercent.y);
}
}
}