Top Description Fields Constructors Methods
jogamp.opengl.awt

public Class AWTTilePainter

extends Object
Class Inheritance
Imports
java.awt.Color, .Graphics2D, .Rectangle, .RenderingHints, .Shape, java.awt.geom.AffineTransform, .NoninvertibleTransformException, .Rectangle2D, java.awt.image.BufferedImage, .DataBufferInt, java.io.File, .IOException, java.util.Arrays, .Iterator, .Set, .Map.Entry, javax.imageio.ImageIO, com.jogamp.nativewindow.util.DimensionImmutable, .PixelFormat, com.jogamp.opengl.GL, .GLAutoDrawable, .GLCapabilitiesImmutable, .GLEventListener, jogamp.opengl.Debug, com.jogamp.opengl.util.TileRenderer, .TileRendererBase, .GLPixelBuffer.GLPixelAttributes, com.jogamp.opengl.util.awt.AWTGLPixelBuffer, .AWTGLPixelBuffer.AWTGLPixelBufferProvider

Implementing AWT Graphics2D based TileRenderer painter.

Maybe utilized for AWT printing.

Field Summary

Modifier and TypeField and Description
pack-priv static int
public final int
public final int
public final int
public final int
private static final boolean
public boolean
flipVertical

Default for OpenGL: True

private Graphics2D
public boolean
originBottomLeft

Default for OpenGL: True

pack-priv final GLEventListener
pack-priv final GLEventListener
public final TileRenderer
private AffineTransform
private int
public final double
public final double
private AWTGLPixelBuffer
public final boolean
private BufferedImage

Constructor Summary

AccessConstructor and Description
public
AWTTilePainter(final TileRenderer renderer, final int componentCount, final double
Graphics2D scaling factor, i.e. rendering 1/scaleMatX * width pixels
scaleMatX
,
final double
Graphics2D scaling factor, i.e. rendering 1/scaleMatY * height pixels
scaleMatY
,
final int
custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
numSamples
,
final int
custom tile width for tile renderer, pass -1 for default.
tileWidth
,
final int
custom tile height for tile renderer, pass -1 for default.
tileHeight
,
final boolean verbose)

Assumes a configured TileRenderer, i.e. an attached GLAutoDrawable with set tile size.

Method Summary

Modifier and TypeMethod and Description
private static Rectangle2D
public void
dispose()

Disposes resources and detaches the TileRenderer's GLAutoDrawable.

public static void
private static Rectangle2D
public int

Returns:

resulting number of samples by comparing w/ customNumSamples and the caps-config, 0 if disabled
getNumSamples
(final GLCapabilitiesImmutable caps)

public void
resetGraphics2D()

See {@ #setupGraphics2DAndClipBounds(Graphics2D)}.

public void
setGLOrientation(final boolean
if true, the image will be flipped vertically (Default for OpenGL).
flipVertical
,
final boolean
if true, the image's origin is on the bottom left (Default for OpenGL).
originBottomLeft
)

public void
setupGraphics2DAndClipBounds(final Graphics2D
Graphics2D instance used for transform and clipping
g2d
,
final int
width of the AWT component in case clipping is null
width
,
final int
height of the AWT component in case clipping is null
height
)

Caches the Graphics2D instance for rendering.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_counterback to summary
pack-priv static int _counter
componentCountback to summary
public final int componentCount
customNumSamplesback to summary
public final int customNumSamples
customTileHeightback to summary
public final int customTileHeight
customTileWidthback to summary
public final int customTileWidth
DEBUG_TILESback to summary
private static final boolean DEBUG_TILES
flipVerticalback to summary
public boolean flipVertical

Default for OpenGL: True

g2dback to summary
private Graphics2D g2d
originBottomLeftback to summary
public boolean originBottomLeft

Default for OpenGL: True

postTileGLELback to summary
pack-priv final GLEventListener postTileGLEL
preTileGLELback to summary
pack-priv final GLEventListener preTileGLEL
rendererback to summary
public final TileRenderer renderer
saveATback to summary
private AffineTransform saveAT
scaledYOffsetback to summary
private int scaledYOffset
scaleMatXback to summary
public final double scaleMatX
scaleMatYback to summary
public final double scaleMatY
tBufferback to summary
private AWTGLPixelBuffer tBuffer
verboseback to summary
public final boolean verbose
vFlipImageback to summary
private BufferedImage vFlipImage

Constructor Detail

AWTTilePainterback to summary
public AWTTilePainter(final TileRenderer renderer, final int componentCount, final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight, final boolean verbose)

Assumes a configured TileRenderer, i.e. an attached GLAutoDrawable with set tile size.

Sets the renderer to TileRenderer#TR_TOP_TO_BOTTOM row order.

componentCount reflects opaque, i.e. 4 if non opaque.

Parameters
scaleMatX:double

Graphics2D scaling factor, i.e. rendering 1/scaleMatX * width pixels

scaleMatY:double

Graphics2D scaling factor, i.e. rendering 1/scaleMatY * height pixels

numSamples:int

custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples

tileWidth:int

custom tile width for tile renderer, pass -1 for default.

tileHeight:int

custom tile height for tile renderer, pass -1 for default.

Method Detail

clipNegativeback to summary
private static Rectangle2D clipNegative(final Rectangle2D in)
disposeback to summary
public void dispose()

Disposes resources and detaches the TileRenderer's GLAutoDrawable.

dumpHintsAndScaleback to summary
public static void dumpHintsAndScale(final Graphics2D g2d)
getClipBounds2Dback to summary
private static Rectangle2D getClipBounds2D(final Graphics2D g)
getNumSamplesback to summary
public int getNumSamples(final GLCapabilitiesImmutable caps)
Returns:int

resulting number of samples by comparing w/ customNumSamples and the caps-config, 0 if disabled

resetGraphics2Dback to summary
public void resetGraphics2D()

See {@ #setupGraphics2DAndClipBounds(Graphics2D)}.

setGLOrientationback to summary
public void setGLOrientation(final boolean flipVertical, final boolean originBottomLeft)
Parameters
flipVertical:boolean

if true, the image will be flipped vertically (Default for OpenGL).

originBottomLeft:boolean

if true, the image's origin is on the bottom left (Default for OpenGL).

setupGraphics2DAndClipBoundsback to summary
public void setupGraphics2DAndClipBounds(final Graphics2D g2d, final int width, final int height) throws NoninvertibleTransformException

Caches the Graphics2D instance for rendering.

Copies the current Graphics2D AffineTransform and scales Graphics2D w/ scaleMatX x scaleMatY.
After rendering, the AffineTransform should be reset via resetGraphics2D().

Sets the TileRenderer's image size and tile offset according the the graphics clip bounds.

Parameters
g2d:Graphics2D

Graphics2D instance used for transform and clipping

width:int

width of the AWT component in case clipping is null

height:int

height of the AWT component in case clipping is null

Exceptions
NoninvertibleTransformException:
if the Graphics2D's AffineTransform inversion fails. Since inversion is tested before scaling the given Graphics2D, caller shall ignore the whole term.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override