From 483d672f94c4690cbea83738b4e61217a5a0d7ac Mon Sep 17 00:00:00 2001 From: Axel Howind Date: Mon, 6 Jan 2025 17:26:37 +0100 Subject: [PATCH] fix wrong bounds being reported --- .../main/java/com/dua3/utility/swing/SwingGraphics.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utility-swing/src/main/java/com/dua3/utility/swing/SwingGraphics.java b/utility-swing/src/main/java/com/dua3/utility/swing/SwingGraphics.java index 4e5f2a26..074658ae 100644 --- a/utility-swing/src/main/java/com/dua3/utility/swing/SwingGraphics.java +++ b/utility-swing/src/main/java/com/dua3/utility/swing/SwingGraphics.java @@ -2,6 +2,7 @@ import com.dua3.utility.awt.AwtImageUtil; import com.dua3.utility.data.Image; +import com.dua3.utility.lang.LangUtil; import com.dua3.utility.math.geometry.Path2f; import com.dua3.utility.math.geometry.Vector2f; import com.dua3.utility.ui.Graphics; @@ -124,19 +125,19 @@ public SwingGraphics(Graphics2D g2d, Rectangle bounds) { @Override public float getWidth() { - return (float) parentBounds.getWidth(); + return (float) g2d.getClipBounds().getWidth(); } @Override public float getHeight() { - return (float) parentBounds.height; + return (float) g2d.getClipBounds().getHeight(); } @Override public Rectangle2f getBounds() { assert isDrawing : "instance has been closed!"; - return convert(parentBounds); + return convert(LangUtil.orElse(g2d.getClipBounds(), parentBounds)); } /**