int dy = Math.abs(zoomBoxEnd.y - zoomBoxStart.y);
// ensure deltas are valid
if (dx <= 0) dx = 1;
if (dy <= 0) dy = 1;
GeometryEditPanel panel = panel();
double widthFactor = panel.getSize().width / dx;
double heightFactor = panel.getSize().height / dy;
double zoomFactor = Math.min(widthFactor, heightFactor);
// double zoomFactor = 2;
panel().zoom(centre, zoomFactor);
}