- final double margin = 1;
- bounds.setFrame(bounds.getMinX() - margin, bounds.getMinY() - margin, bounds.getWidth() + 2*margin, bounds.getHeight() + 2*margin);
+
+ Point2D scale = GeometryUtils.getScale2D(selectionTransform);
+ final double marginX = Math.abs(scale.getX()) > 1e-10 ? 1 / scale.getX() : 1;
+ final double marginY = Math.abs(scale.getY()) > 1e-10 ? 1 / scale.getY() : 1;
+
+ bounds.setFrame(bounds.getMinX() - marginX, bounds.getMinY() - marginY, bounds.getWidth() + 2*marginX, bounds.getHeight() + 2*marginY);