double minY = Double.POSITIVE_INFINITY;
double maxY = Double.NEGATIVE_INFINITY;
boolean isDefined = false;
for (final CanvasRenderer r : renderers) {
final ViewRect rect = r.getViewRect();
if (rect != null) {
minX = Math.min(minX, rect.min.x);
maxX = Math.max(maxX, rect.max.x);
minY = Math.min(minY, rect.min.y);
maxY = Math.max(maxY, rect.max.y);
isDefined = true;
}
}
checkState(
isDefined,
"none of the available renderers implements getViewRect(), known renderers: %s",
renderers);
viewRect = new ViewRect(new Point(minX, minY), new Point(maxX, maxY));
final Rectangle area = canvas.getClientArea();
if (viewRect.width > viewRect.height) {
m = area.width / viewRect.width;
} else {