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 TypeMethodDescriptionvoidclose()static ActiveGraphics2DfromImage(BufferedImage image) Createsand wraps a Graphics2D instance, which can be used to draw into the givenBufferedImage.static ActiveGraphics2Dwrap(Graphics2D g2d) Wraps a Graphics2D instance.
-
Field Details
-
g2d
The underlyingGraphics2Dinstance.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
fromImage
Createsand wraps a Graphics2D instance, which can be used to draw into the givenBufferedImage. The wrapper returned by this method implementsAutoCloseableso 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
Graphics2Dwrapper thatdisposesthe underlying resource automatically when closed.
-
wrap
Wraps a Graphics2D instance. The wrapper returned by this method implementsAutoCloseableso 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
Graphics2Dwrapper thatdisposesthe underlying resource automatically when closed.
-