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)); } /**