Top Description Inners Fields Methods
com.jogamp.nativewindow.awt

public Interface AWTPrintLifecycle

Known Direct Implementers
com.jogamp.newt.awt.NewtCanvasAWT, com.jogamp.opengl.awt.GLCanvas, com.jogamp.opengl.awt.GLJPanel
Imports
java.awt.Component, .Container, .Graphics, .Graphics2D, java.awt.print.PrinterJob, jogamp.nativewindow.awt.AWTMisc

Interface describing print lifecycle to support AWT printing, e.g. on AWT GLAutoDrawables.
Implementations

Implementing GLAutoDrawable classes based on AWT supporting Component#print(Graphics) shall implement this interface.

Usage

Users attempting to print an AWT Container containing AWTPrintLifecycle elements shall consider decorating the Container#printAll(Graphics) call with
setupPrint(..) and releasePrint() on all AWTPrintLifecycle elements in the Container.
To minimize this burden, a user can use Context.setupPrint(..):

 Container cont;
 double scaleGLMatXY = 72.0/glDPI;
 int numSamples = 0; // leave multisampling as-is
 PrinterJob job;
 ...
   final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(cont, scaleGLMatXY, scaleGLMatXY, numSamples);
   try {
      AWTEDTExecutor.singleton.invoke(true, new Runnable() {
           public void run() {
               try {
                   job.print();
               } catch (PrinterException ex) {
                   ex.printStackTrace();
               }
          } });
   } finally {
      ctx.releasePrint();
   }

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final int

Method Summary

Modifier and TypeMethod and Description
public void
releasePrint()

Shall be called after PrinterJob#print().

public void
setupPrint(double
Graphics2D scaling factor, i.e. rendering 1/scaleMatX * width pixels
scaleMatX
,
double
Graphics2D scaling factor, i.e. rendering 1/scaleMatY * height pixels
scaleMatY
,
int
multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples
numSamples
,
int
custom tile width for tile renderer, pass -1 for default.
tileWidth
,
int
custom tile height for tile renderer, pass -1 for default. FIXME: Add border size !
tileHeight
)

Shall be called before PrinterJob#print().

Field Detail

DEFAULT_PRINT_TILE_SIZEback to summary
public static final int DEFAULT_PRINT_TILE_SIZE

Method Detail

releasePrintback to summary
public void releasePrint()

Shall be called after PrinterJob#print().

See Usage.

setupPrintback to summary
public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight)

Shall be called before PrinterJob#print().

See Usage.

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

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. FIXME: Add border size !

com.jogamp.nativewindow.awt back to summary

public Class AWTPrintLifecycle.Context

extends Object
Class Inheritance

Convenient AWTPrintLifecycle context simplifying calling setupPrint(..) and AWTPrintLifecycle#releasePrint() on all AWTPrintLifecycle elements of a Container.

See Usage.

Field Summary

Modifier and TypeField and Description
private final Container
private int
private final int
private final AWTMisc.ComponentAction
private final double
private final double
private final AWTMisc.ComponentAction
private final int
private final int

Constructor Summary

AccessConstructor and Description
private
Context(final Container c, final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight)

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

count of performed actions of last setupPrint(..) or releasePrint().
getCount
()

public void
public static AWTPrintLifecycle.Context

Returns:

the context
setupPrint
(final Container
container to be traversed through to perform setupPrint(..) on all AWTPrintLifecycle elements.
c
,
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
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
)

See Usage.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contback to summary
private final Container cont
countback to summary
private int count
numSamplesback to summary
private final int numSamples
releaseActionback to summary
private final AWTMisc.ComponentAction releaseAction
scaleMatXback to summary
private final double scaleMatX
scaleMatYback to summary
private final double scaleMatY
setupActionback to summary
private final AWTMisc.ComponentAction setupAction
tileHeightback to summary
private final int tileHeight
tileWidthback to summary
private final int tileWidth

Constructor Detail

Contextback to summary
private Context(final Container c, final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight)

Method Detail

getCountback to summary
public int getCount()
Returns:int

count of performed actions of last setupPrint(..) or releasePrint().

releasePrintback to summary
public void releasePrint()

See Usage.

setupPrintback to summary
public static AWTPrintLifecycle.Context setupPrint(final Container c, final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight)

See Usage.

Parameters
c:Container

container to be traversed through to perform setupPrint(..) on all AWTPrintLifecycle elements.

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

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.

Returns:AWTPrintLifecycle.Context

the context

setupPrintback to summary
private void setupPrint(final Container c)