Package de.xima.fc.graphics
Class ActiveGraphics2D
java.lang.Object
de.xima.fc.graphics.ActiveGraphics2D
- All Implemented Interfaces:
AutoCloseable
Wrapper for a
Graphics2D
instance that disposes of the instance automatically when closed. Also has static
methods for creating new wrappers.- Author:
- XIMA MEDIA GmbH
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static ActiveGraphics2D
fromImage
(BufferedImage image) Creates
and wraps a Graphics2D instance, which can be used to draw into the givenBufferedImage
.static ActiveGraphics2D
wrap
(Graphics2D g2d) Wraps a Graphics2D instance.
-
Field Details
-
g2d
The underlyingGraphics2D
instance.
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
fromImage
Creates
and wraps a Graphics2D instance, which can be used to draw into the givenBufferedImage
. The wrapper returned by this method implementsAutoCloseable
so that you can use with try-with-resources-statements instead of having to dispose the graphics 2D instance manually.- Parameters:
image
- Buffered image on which to draw.- Returns:
- A
Graphics2D
wrapper thatdisposes
the underlying resource automatically when closed.
-
wrap
Wraps a Graphics2D instance. The wrapper returned by this method implementsAutoCloseable
so that you can use with try-with-resources-statements instead of having to dispose the graphics 2D instance manually.- Parameters:
g2d
- Instance to wrap.- Returns:
- A
Graphics2D
wrapper thatdisposes
the underlying resource automatically when closed.
-