Hi,
I try to print my Canvas3D. It used to work a month ago, in the meantime
I included changes into the code but, I did not change anything with the
printing. All that I get is a blank page.
Thanks for your help in advance
Desiree
Basically I am using the following methods:
/**
* Printing in Java3D needs an additional Canvas with the view, this
* Canvas is created in this method.
*/
public void createPrintCanvas() {
System.out.println("createPrintCanvas");
// Background
createBackgroundNode(Color.white);
if (!hasOffScreen) {
configTest = SimpleUniverse.getPreferredConfiguration();
offScreenCanvas3dTest = new
OffScreenCanvas3D(configTest,true);
// Set the off-screen size based on a scale factor times the
// on-screen size
sOn = c.getScreen3D();
sOff = offScreenCanvas3dTest.getScreen3D();
dim = sOn.getSize();
dim.width *= OFF_SCREEN_SCALE;
dim.height *= OFF_SCREEN_SCALE;
sOff.setSize(dim);
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() *
OFF_SCREEN_SCALE);
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() *
OFF_SCREEN_SCALE);
// attach the offscreen canvas to the view
u.getViewer().getView().addCanvas3D(offScreenCanvas3dTest);
hasOffScreen = true;
}
Point loc = c.getLocationOnScreen();
offScreenCanvas3dTest.setOffScreenLocation(loc);
dim = c.getSize();
dim.width *= OFF_SCREEN_SCALE;
dim.height *= OFF_SCREEN_SCALE;
addBackgroundNode();
u.setJ3DThreadPriority( Thread.currentThread().getPriority() );
bImage = offScreenCanvas3dTest.doRender(dim.width, dim.height);
bImage.flush();
removeBackgroundNode();
System.runFinalization();
System.gc();
}
and doRender in OffScreenCanvas is:
BufferedImage doRender(int width, int height) {
BufferedImage bImage =
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
ImageComponent2D buffer =
new ImageComponent2D(ImageComponent.FORMAT_RGBA, bImage);
setOffScreenBuffer(buffer);
renderOffScreenBuffer();
waitForOffScreenRendering();
bImage = getOffScreenBuffer().getImage();
bImage.flush();
buffer = null;
System.gc();
return bImage;
}
and print:
/**
* Method for interface Printable.
*/
public int print(Graphics g, PageFormat pf, int pi) throws
PrinterException {
System.out.println("print in GIS3DView");
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)g;
g.dispose();
g = null;
AffineTransform t2d = new AffineTransform();
t2d.translate(pf.getImageableX(), pf.getImageableY());
double xscale = pf.getImageableWidth() /
(double)bImage.getWidth();
double yscale = pf.getImageableHeight() /
(double)bImage.getHeight();
double scale = Math.min(xscale, yscale);
t2d.scale(scale, scale);
try {
g2d.drawImage(bImage,t2d, this);
g2d.dispose();
g2d = null;
}
catch (Exception ex) {
ex.printStackTrace();
return Printable.NO_SUCH_PAGE;
}
System.runFinalization();
System.gc();
return Printable.PAGE_EXISTS;
}
oooooooooooooooooooooooooooooooooooooooooooooooo
Desiree Hilbring
Institut fuer Photogrammetrie und Fernerkundung
Universitaet Karlsruhe, Germany
email: [EMAIL PROTECTED]
# 0721 6083676
oooooooooooooooooooooooooooooooooooooooooooooooo
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".