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 boolean
Flag 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 Object
The rendering surfaceprotected boolean
Synchronization flagprotected OGLConstruct
The construct instance to record fromprotected OGLStandardBrowserCore
The browser coreprotected org.j3d.util.ErrorReporter
The error reporting mechanismprotected long
The total file write timeprotected FrameStateManager
The frame state managerprotected boolean
Flag indicating that the selected encoding type may have an alphaprotected boolean
Should the headlight be onprotected int
The height of the output imagesprotected int
protected int
The index of the viewpoint's isBound field.protected RecorderListener
Listener for recorder status eventsprotected OGLNavigationInfo
The viewpointprotected int
The sequence capture number, somewhat unnecessary as in this application, it only ever reaches one (1)protected File
The output file for the captured imagesprotected boolean
Flag indicating that the image capture should be post processedprotected long
The total frame rendering timeprotected boolean
Should the navigation info be replaced to use the headlight valueprotected VRMLWorldRootNodeType
The scene root, parent for the nav info and viewpoint nodesprotected int
RGB value for snap pixels that should be replacedprotected long
The last start of frame rendering timeprotected String
The image encoding typeprotected BaseViewpoint
The viewpoint node, used when we have to wait for the named viewpoint to be boundprotected String
The name of the x3d viewpoint to capture.protected int
The width of the output images -
Constructor Summary
ConstructorsConstructorDescriptionThumbnailRecorder
(OGLConstruct construct, boolean replaceNavInfo, boolean headlight) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Notification that the rendering of the event model is complete and that rendering is about to begin.void
fieldChanged
(int index) Notification that the field represented by the given index has changed.double
Return the file write time in millisecondsdouble
Return the frame rendering time in millisecondsvoid
saveScreen
(Buffer buffer, int width, int height) Process the screen capture buffer into a BufferedImage and save it to a filevoid
screenCaptured
(Buffer buffer, int width, int height) Notification of a new screen capture.void
setBackgroundColor
(Color x3dBackgroundColor, Color imageBackgroundColor) Set the background color for the image.boolean
setEncoding
(String type) Set the image encoding typeboolean
setOutputFile
(File file) Set the output file for the imagevoid
setSize
(int width, int height) Set the image sizevoid
setViewpointName
(String name) Set the DEF'ed name of the Viewpointvoid
start
(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:
screenCaptured
in 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:VRMLNodeListener
Notification that the field represented by the given index has changed.- Specified by:
fieldChanged
in interfaceVRMLNodeListener
- Parameters:
index
- The index of the field that has changed
-
allEventsComplete
public void allEventsComplete()Description copied from interface:FrameStateListener
Notification 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:
allEventsComplete
in 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
-