Package de.xima.fc.graphics
Class ActiveGraphics2D
- java.lang.Object
 - 
- de.xima.fc.graphics.ActiveGraphics2D
 
 
- 
- All Implemented Interfaces:
 AutoCloseable
public final class ActiveGraphics2D extends Object implements AutoCloseable
Wrapper for aGraphics2Dinstance that disposes of the instance automatically when closed. Also has static methods for creating new wrappers.- Author:
 - XIMA MEDIA GmbH
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description Graphics2Dg2dThe underlyingGraphics2Dinstance. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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 Detail
- 
g2d
public final Graphics2D g2d
The underlyingGraphics2Dinstance. 
 - 
 
- 
Method Detail
- 
close
public void close()
- Specified by:
 closein interfaceAutoCloseable
 
- 
fromImage
public static ActiveGraphics2D fromImage(BufferedImage image)
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
public static ActiveGraphics2D wrap(Graphics2D g2d)
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. 
 
 - 
 
 -