double minX = Double.MAX_VALUE;
double maxX = Double.MIN_VALUE;
double minY = Double.MAX_VALUE;
double maxY = Double.MIN_VALUE;
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode layoutEntity = entitiesToLayout[i];
minX = Math.min(minX, layoutEntity.getInternalX());
minY = Math.min(minY, layoutEntity.getInternalY());
maxX = Math.max(maxX, layoutEntity.getInternalX());
maxY = Math.max(maxY, layoutEntity.getInternalY());
}
double spanX = maxX - minX;
double spanY = maxY - minY;
double maxSpan = Math.max(spanX, spanY);
if (maxSpan > EPSILON) {
for (int i = 0; i < entitiesToLayout.length; i++) {
InternalNode layoutEntity = entitiesToLayout[i];
double x = (layoutEntity.getInternalX() - minX) / spanX;
double y = (layoutEntity.getInternalY() - minY) / spanY;
tempLocationsX[i] = x;
tempLocationsY[i] = y;
}
} else {
placeRandomly(entitiesToLayout);