/**
* Returns an image of the home viewed by this component at the given size.
*/
public BufferedImage getOffScreenImage(int width, int height) {
List<Selectable> selectedItems = this.home.getSelectedItems();
SimpleUniverse offScreenImageUniverse = null;
try {
View view;
if (this.offscreenUniverse == null) {
offScreenImageUniverse = createUniverse(this.displayShadowOnFloor, false, true);
view = offScreenImageUniverse.getViewer().getView();
// Replace textures by clones because Java 3D doesn't accept all the time
// to share textures between offscreen and onscreen environments
Map<Texture, Texture> replacedTextures = new HashMap<Texture, Texture>();
for (Enumeration it = offScreenImageUniverse.getLocale().getAllBranchGraphs(); it.hasMoreElements(); ) {
cloneTexture((Node)it.nextElement(), replacedTextures);
}
} else {
view = this.offscreenUniverse.getViewer().getView();
}
// Empty temporarily selection to create the off screen image
List<Selectable> emptySelection = Collections.emptyList();
this.home.setSelectedItems(emptySelection);
return Component3DManager.getInstance().getOffScreenImage(view, width, height);
} finally {
// Restore selection
this.home.setSelectedItems(selectedItems);
if (offScreenImageUniverse != null) {
offScreenImageUniverse.cleanup();
}
}
}