Xj3D 2.0 VRML/X3D Code API

org.xj3d.ui.awt.browser.ogl
Class ThumbnailRecorder

java.lang.Object
  extended by org.xj3d.ui.awt.browser.ogl.ThumbnailRecorder
All Implemented Interfaces:
VRMLNodeListener, ScreenCaptureListener

public class ThumbnailRecorder
extends java.lang.Object
implements ScreenCaptureListener, VRMLNodeListener

A function module that performs an image capture of an X3D scene for the purpose of creating a thumbnail image. The requirements of the X3D world are:

The image capture is managed as follows:

Version:
$Revision: 1.5 $
Author:
Rex Melton

Field Summary
protected  java.lang.String[] alphaTypes
          Image encoding types that may have an alpha
protected  java.lang.Object canvas
          The rendering surface
protected  OGLConstruct construct
          The construct instance to record from
protected  OGLStandardBrowserCore core
          The browser core
protected  ErrorReporter errorReporter
          The error reporting mechanism
protected  long fileTime
          The total file write time
protected  boolean hasAlpha
          Flag indicating that the selected encoding type may have an alpha
protected  int height
          The height of the output images
protected  int imageARGB
           
protected  int isBound_index
          The index of the viewpoint's isBound field.
protected  RecorderListener listener
          Listener for recorder status events
protected  int number
          The sequence capture number, somewhat unnecessary as in this application, it only ever reaches one (1)
protected  java.io.File outputFile
          The output file for the captured images
protected  boolean postProcess
          Flag indicating that the image capture should be post processed
protected  long renderTime
          The total frame rendering time
protected  int snapRGB
          RGB value for snap pixels that should be replaced
protected  long startFrameTime
          The last start of frame rendering time
protected  java.lang.String type
          The image encoding type
protected  org.web3d.vrml.renderer.common.nodes.navigation.BaseViewpoint viewpoint
          The viewpoint node, used when we have to wait for the named viewpoint to be bound
protected  java.lang.String viewpointName
          The name of the x3d viewpoint to capture.
protected  int width
          The width of the output images
 
Constructor Summary
ThumbnailRecorder(OGLConstruct construct)
          Constructor
 
Method Summary
 void fieldChanged(int index)
          Listener for the viewpoint binding, if necessary
 double getFileTime()
          Return the file write time in milliseconds
 double getRenderTime()
          Return the frame rendering time in milliseconds
 void saveScreen(java.nio.Buffer buffer, int width, int height)
          Process the screen capture buffer into a BufferedImage and save it to a file
 void screenCaptured(java.nio.Buffer buffer)
          Notification of a new screen capture.
 void setBackgroundColor(java.awt.Color x3dBackgroundColor, java.awt.Color imageBackgroundColor)
          Set the background color for the image.
 boolean setEncoding(java.lang.String type)
          Set the image encoding type
 boolean setOutputFile(java.io.File file)
          Set the output file for the image
 void setSize(int width, int height)
          Set the image size
 void setViewpointName(java.lang.String name)
          Set the DEF'ed name of the Viewpoint
 void start(RecorderListener listener)
          Initiate the capture
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

construct

protected OGLConstruct construct
The construct instance to record from


core

protected OGLStandardBrowserCore core
The browser core


errorReporter

protected ErrorReporter errorReporter
The error reporting mechanism


canvas

protected java.lang.Object canvas
The rendering surface


number

protected int number
The sequence capture number, somewhat unnecessary as in this application, it only ever reaches one (1)


viewpointName

protected java.lang.String viewpointName
The name of the x3d viewpoint to capture. Default value is "ICON_VIEWPOINT"


viewpoint

protected org.web3d.vrml.renderer.common.nodes.navigation.BaseViewpoint viewpoint
The viewpoint node, used when we have to wait for the named viewpoint to be bound


isBound_index

protected int isBound_index
The index of the viewpoint's isBound field.


outputFile

protected java.io.File outputFile
The output file for the captured images


listener

protected RecorderListener listener
Listener for recorder status events


width

protected int width
The width of the output images


height

protected int height
The height of the output images


type

protected java.lang.String type
The image encoding type


hasAlpha

protected boolean hasAlpha
Flag indicating that the selected encoding type may have an alpha


alphaTypes

protected java.lang.String[] alphaTypes
Image encoding types that may have an alpha


fileTime

protected long fileTime
The total file write time


renderTime

protected long renderTime
The total frame rendering time


startFrameTime

protected long startFrameTime
The last start of frame rendering time


postProcess

protected boolean postProcess
Flag indicating that the image capture should be post processed


snapRGB

protected int snapRGB
RGB value for snap pixels that should be replaced


imageARGB

protected int imageARGB
Constructor Detail

ThumbnailRecorder

public ThumbnailRecorder(OGLConstruct construct)
Constructor

Parameters:
construct - The construct instance to record from
Method Detail

screenCaptured

public void screenCaptured(java.nio.Buffer buffer)
Notification of a new screen capture. The buffer will be in openGL pixel order.

Specified by:
screenCaptured in interface ScreenCaptureListener
Parameters:
buffer - The screen capture

fieldChanged

public void fieldChanged(int index)
Listener for the viewpoint binding, if necessary

Specified by:
fieldChanged in interface VRMLNodeListener
Parameters:
index - The index of the field that has changed

getRenderTime

public double getRenderTime()
Return the frame rendering time in milliseconds

Returns:
the frame rendering time in milliseconds

getFileTime

public double getFileTime()
Return the file write time in milliseconds

Returns:
the file write time in milliseconds

setEncoding

public boolean setEncoding(java.lang.String type)
Set the image encoding type

Parameters:
type - The image encoding type
Returns:
true if the encoding type is valid, false otherwise.

setSize

public void setSize(int width,
                    int height)
Set the image size

Parameters:
width - The image width
height - The image height

setBackgroundColor

public void setBackgroundColor(java.awt.Color x3dBackgroundColor,
                               java.awt.Color imageBackgroundColor)
Set the background color for the image.

Parameters:
x3dBackgroundColor - The background color of the X3D model to replace with the image background color. If null, the image background will not be changed from the capture.
imageBackgroundColor - The color to set for the image background. If null, the image background will not be changed from the capture.

setOutputFile

public boolean setOutputFile(java.io.File file)
Set the output file for the image

Parameters:
file - The output file for the image
Returns:
true if the output file is of a valid encoding type, false otherwise.

setViewpointName

public void setViewpointName(java.lang.String name)
Set the DEF'ed name of the Viewpoint

Parameters:
name - The DEF'ed name of the Viewpoint

start

public void start(RecorderListener listener)
Initiate the capture


saveScreen

public void saveScreen(java.nio.Buffer buffer,
                       int width,
                       int height)
Process the screen capture buffer into a BufferedImage and save it to a file

Parameters:
buffer - The screen capture buffer
width - The width of the image
height - The height of the image

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium