Package org.xj3d.ui.awt.browser.ogl
Class ThumbnailRecorder
java.lang.Object
org.xj3d.ui.awt.browser.ogl.ThumbnailRecorder
- All Implemented Interfaces:
ScreenCaptureListener,FrameStateListener,VRMLNodeListener
public class ThumbnailRecorder
extends Object
implements ScreenCaptureListener, VRMLNodeListener, FrameStateListener
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:
- Optionally there may be a DEF'ed Viewpoint with a known DEF name.
- By default the Viewpoint's DEF name is "ICON_VIEWPOINT". The Viewpoint's DEF name is programmatically configurable in this module.
- In the absence of a DEF'ed Viewpoint, the default viewpoint will be captured.
- On the completion of the world and content loading, the DEF'ed Viewpoint node is searched for and bound if necessary.
- The image capture is initiated immediately if the DEF'd Viewpoint is not found, or the DEF'ed Viewpoint is found and currently bound.
- Otherwise, the capture is initiated immediately upon notification that the DEF'd Viewpoint has been bound.
- Version:
- $Revision: 1.8 $
- Author:
- Rex Melton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag used in the end of frame listener, indicating that the new nodes may be added to the sceneprotected String[]Image encoding types that may have an alphaprotected ObjectThe rendering surfaceprotected booleanSynchronization flagprotected OGLConstructThe construct instance to record fromprotected OGLStandardBrowserCoreThe browser coreprotected org.j3d.util.ErrorReporterThe error reporting mechanismprotected longThe total file write timeprotected FrameStateManagerThe frame state managerprotected booleanFlag indicating that the selected encoding type may have an alphaprotected booleanShould the headlight be onprotected intThe height of the output imagesprotected intprotected intThe index of the viewpoint's isBound field.protected RecorderListenerListener for recorder status eventsprotected OGLNavigationInfoThe viewpointprotected intThe sequence capture number, somewhat unnecessary as in this application, it only ever reaches one (1)protected FileThe output file for the captured imagesprotected booleanFlag indicating that the image capture should be post processedprotected longThe total frame rendering timeprotected booleanShould the navigation info be replaced to use the headlight valueprotected VRMLWorldRootNodeTypeThe scene root, parent for the nav info and viewpoint nodesprotected intRGB value for snap pixels that should be replacedprotected longThe last start of frame rendering timeprotected StringThe image encoding typeprotected BaseViewpointThe viewpoint node, used when we have to wait for the named viewpoint to be boundprotected StringThe name of the x3d viewpoint to capture.protected intThe width of the output images -
Constructor Summary
ConstructorsConstructorDescriptionThumbnailRecorder(OGLConstruct construct, boolean replaceNavInfo, boolean headlight) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidNotification that the rendering of the event model is complete and that rendering is about to begin.voidfieldChanged(int index) Notification that the field represented by the given index has changed.doubleReturn the file write time in millisecondsdoubleReturn the frame rendering time in millisecondsvoidsaveScreen(Buffer buffer, int width, int height) Process the screen capture buffer into a BufferedImage and save it to a filevoidscreenCaptured(Buffer buffer, int width, int height) Notification of a new screen capture.voidsetBackgroundColor(Color x3dBackgroundColor, Color imageBackgroundColor) Set the background color for the image.booleansetEncoding(String type) Set the image encoding typebooleansetOutputFile(File file) Set the output file for the imagevoidsetSize(int width, int height) Set the image sizevoidsetViewpointName(String name) Set the DEF'ed name of the Viewpointvoidstart(RecorderListener listener) Initiate the capture
-
Field Details
-
construct
The construct instance to record from -
core
The browser core -
errorReporter
protected org.j3d.util.ErrorReporter errorReporterThe error reporting mechanism -
canvas
The rendering surface -
root
The scene root, parent for the nav info and viewpoint nodes -
addNodes
protected boolean addNodesFlag used in the end of frame listener, indicating that the new nodes may be added to the scene -
fsm
The frame state manager -
configComplete
protected boolean configCompleteSynchronization flag -
number
protected int numberThe sequence capture number, somewhat unnecessary as in this application, it only ever reaches one (1) -
viewpointName
The name of the x3d viewpoint to capture. Default value is "ICON_VIEWPOINT" -
viewpoint
The viewpoint node, used when we have to wait for the named viewpoint to be bound -
isBound_index
protected int isBound_indexThe index of the viewpoint's isBound field. -
outputFile
The output file for the captured images -
listener
Listener for recorder status events -
headlight
protected boolean headlightShould the headlight be on -
width
protected int widthThe width of the output images -
height
protected int heightThe height of the output images -
type
The image encoding type -
hasAlpha
protected boolean hasAlphaFlag indicating that the selected encoding type may have an alpha -
alphaTypes
Image encoding types that may have an alpha -
fileTime
protected long fileTimeThe total file write time -
renderTime
protected long renderTimeThe total frame rendering time -
startFrameTime
protected long startFrameTimeThe last start of frame rendering time -
postProcess
protected boolean postProcessFlag indicating that the image capture should be post processed -
snapRGB
protected int snapRGBRGB value for snap pixels that should be replaced -
imageARGB
protected int imageARGB
-
-
Constructor Details
-
ThumbnailRecorder
Constructor- Parameters:
construct- The construct instance to record fromreplaceNavInfo- Should the navigationInfo be replacedheadlight- Should the headlight be on
-
-
Method Details
-
screenCaptured
Notification of a new screen capture. The buffer will be in openGL pixel order.- Specified by:
screenCapturedin interfaceScreenCaptureListener- Parameters:
buffer- The screen capturewidth- The width in pixels of the captured screenheight- The height in pixels of the captured screen
-
fieldChanged
public void fieldChanged(int index) Description copied from interface:VRMLNodeListenerNotification that the field represented by the given index has changed.- Specified by:
fieldChangedin interfaceVRMLNodeListener- Parameters:
index- The index of the field that has changed
-
allEventsComplete
public void allEventsComplete()Description copied from interface:FrameStateListenerNotification that the rendering of the event model is complete and that rendering is about to begin. If the node needs to update itself for this frame, it should do so now before the render pass takes place.- Specified by:
allEventsCompletein interfaceFrameStateListener
-
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
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 widthheight- The image height
-
setBackgroundColor
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
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
Set the DEF'ed name of the Viewpoint- Parameters:
name- The DEF'ed name of the Viewpoint
-
start
-
saveScreen
Process the screen capture buffer into a BufferedImage and save it to a file- Parameters:
buffer- The screen capture bufferwidth- The width of the imageheight- The height of the image
-