Package com.jme3.app.state
Class ScreenshotAppState
java.lang.Object
com.jme3.app.state.AbstractAppState
com.jme3.app.state.ScreenshotAppState
- All Implemented Interfaces:
- AppState,- ActionListener,- InputListener,- SceneProcessor
- 
Field SummaryFields inherited from class com.jme3.app.state.AbstractAppStateinitialized
- 
Constructor SummaryConstructorsConstructorDescriptionUsing this constructor, the screenshot files will be written sequentially to the system default storage folder.ScreenshotAppState(String filePath) This constructor allows you to specify the output file path of the screenshot.ScreenshotAppState(String filePath, long shotIndex) This constructor allows you to specify the output file path of the screenshot and a base index for the shot index.ScreenshotAppState(String filePath, String fileName) This constructor allows you to specify the output file path of the screenshot.ScreenshotAppState(String filePath, String fileName, long shotIndex) This constructor allows you to specify the output file path of the screenshot and a base index for the shot index.
- 
Method SummaryModifier and TypeMethodDescriptionvoidcleanup()Clean up this AppState during the first update after it gets detached.voidinitialize(AppStateManager stateManager, Application app) Called byAppStateManagerwhen transitioning thisAppStatefrom initializing to running.
 This will happen on the next iteration through the update loop afterAppStateManager.attach(com.jme3.app.state.AppState)was called.voidinitialize(RenderManager rm, ViewPort vp) Called in the render thread to initialize the scene processor.booleanvoidCalled when an input to which this listener is registered to is invoked.voidpostFrame(FrameBuffer out) Called after a frame has been rendered and the queue flushed.voidpostQueue(RenderQueue rq) Called after the scene graph has been queued, but before it is flushed.voidpreFrame(float tpf) Called before a framevoidCalled when the resolution of the viewport has been changed.voidsetFileName(String fileName) Set the file name of the screenshot.voidsetFilePath(String filePath) Set the file path to store the screenshot.voidsetIsNumbered(boolean numberedWanted) Sets if the filename should be appended with a number representing the current sequence.voidsetProfiler(AppProfiler profiler) Sets a profiler Instance for this processor.voidsetShotIndex(long index) Sets the base index that will used for subsequent screenshots.voidprotected voidwriteImageFile(File file) Called by postFrame() once the screen has been captured to outBuf.Methods inherited from class com.jme3.app.state.AbstractAppStategetId, isEnabled, postRender, render, setEnabled, setId, stateAttached, stateDetached, updateMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jme3.post.SceneProcessorrescale
- 
Constructor Details- 
ScreenshotAppStatepublic ScreenshotAppState()Using this constructor, the screenshot files will be written sequentially to the system default storage folder.
- 
ScreenshotAppStateThis constructor allows you to specify the output file path of the screenshot. Include the separator at the end of the path. Use an empty string to use the application folder. Use NULL to use the system default storage folder.- Parameters:
- filePath- The screenshot file path to use. Include the separator at the end of the path.
 
- 
ScreenshotAppStateThis constructor allows you to specify the output file path of the screenshot. Include the separator at the end of the path. Use an empty string to use the application folder. Use NULL to use the system default storage folder.- Parameters:
- filePath- The screenshot file path to use. Include the separator at the end of the path.
- fileName- The name of the file to save the screenshot as.
 
- 
ScreenshotAppStateThis constructor allows you to specify the output file path of the screenshot and a base index for the shot index. Include the separator at the end of the path. Use an empty string to use the application folder. Use NULL to use the system default storage folder.- Parameters:
- filePath- The screenshot file path to use. Include the separator at the end of the path.
- shotIndex- The base index for screenshots. The first screenshot will have shotIndex + 1 appended, the next shotIndex + 2, and so on.
 
- 
ScreenshotAppStateThis constructor allows you to specify the output file path of the screenshot and a base index for the shot index. Include the separator at the end of the path. Use an empty string to use the application folder. Use NULL to use the system default storage folder.- Parameters:
- filePath- The screenshot file path to use. Include the separator at the end of the path.
- fileName- The name of the file to save the screenshot as.
- shotIndex- The base index for screenshots. The first screenshot will have shotIndex + 1 appended, the next shotIndex + 2, and so on.
 
 
- 
- 
Method Details- 
setFilePathSet the file path to store the screenshot. Include the separator at the end of the path. Use an empty string to use the application folder. Use NULL to use the system default storage folder.- Parameters:
- filePath- File path to use to store the screenshot. Include the separator at the end of the path.
 
- 
setFileNameSet the file name of the screenshot.- Parameters:
- fileName- File name to save the screenshot as.
 
- 
setShotIndexpublic void setShotIndex(long index) Sets the base index that will used for subsequent screenshots.- Parameters:
- index- the desired base index
 
- 
setIsNumberedpublic void setIsNumbered(boolean numberedWanted) Sets if the filename should be appended with a number representing the current sequence.- Parameters:
- numberedWanted- If numbering is wanted.
 
- 
initializeDescription copied from interface:AppStateCalled byAppStateManagerwhen transitioning thisAppStatefrom initializing to running.
 This will happen on the next iteration through the update loop afterAppStateManager.attach(com.jme3.app.state.AppState)was called.AppStateManagerwill call this only from the update loop inside the rendering thread. This means is it safe to modify the scene graph from this method.- Specified by:
- initializein interface- AppState
- Overrides:
- initializein class- AbstractAppState
- Parameters:
- stateManager- The state manager
- app- The application
 
- 
cleanuppublic void cleanup()Clean up this AppState during the first update after it gets detached.Because each ScreenshotAppState is also a SceneProcessor (in addition to being an AppState) this method is also invoked when the SceneProcessor get removed from its ViewPort, leading to an indirect recursion: - AppStateManager invokes ScreenshotAppState.cleanup()
- cleanup() invokes ViewPort.removeProcessor()
- removeProcessor() invokes ScreenshotAppState.cleanup()
- ... and so on.
 In order to break this recursion, this method only removes the SceneProcessor if it has not previously been removed. A better design would have the AppState and SceneProcessor be 2 distinct objects, but doing so now might break applications that rely on them being a single object. - Specified by:
- cleanupin interface- AppState
- Specified by:
- cleanupin interface- SceneProcessor
- Overrides:
- cleanupin class- AbstractAppState
 
- 
onActionDescription copied from interface:ActionListenerCalled when an input to which this listener is registered to is invoked.- Specified by:
- onActionin interface- ActionListener
- Parameters:
- name- The name of the mapping that was invoked
- value- True if the action is "pressed", false otherwise
- tpf- The time per frame value.
 
- 
takeScreenshotpublic void takeScreenshot()
- 
initializeDescription copied from interface:SceneProcessorCalled in the render thread to initialize the scene processor.- Specified by:
- initializein interface- SceneProcessor
- Parameters:
- rm- The render manager to which the SP was added to
- vp- The viewport to which the SP is assigned
 
- 
isInitializedpublic boolean isInitialized()- Specified by:
- isInitializedin interface- AppState
- Specified by:
- isInitializedin interface- SceneProcessor
- Overrides:
- isInitializedin class- AbstractAppState
- Returns:
- True if initialize()was called on the state, false otherwise.
 
- 
reshapeDescription copied from interface:SceneProcessorCalled when the resolution of the viewport has been changed.- Specified by:
- reshapein interface- SceneProcessor
- Parameters:
- vp- the affected ViewPort
- w- the new width (in pixels)
- h- the new height (in pixels)
 
- 
preFramepublic void preFrame(float tpf) Description copied from interface:SceneProcessorCalled before a frame- Specified by:
- preFramein interface- SceneProcessor
- Parameters:
- tpf- Time per frame
 
- 
postQueueDescription copied from interface:SceneProcessorCalled after the scene graph has been queued, but before it is flushed.- Specified by:
- postQueuein interface- SceneProcessor
- Parameters:
- rq- The render queue
 
- 
postFrameDescription copied from interface:SceneProcessorCalled after a frame has been rendered and the queue flushed.- Specified by:
- postFramein interface- SceneProcessor
- Parameters:
- out- The FB to which the scene was rendered.
 
- 
setProfilerDescription copied from interface:SceneProcessorSets a profiler Instance for this processor.- Specified by:
- setProfilerin interface- SceneProcessor
- Parameters:
- profiler- the profiler instance.
 
- 
writeImageFileCalled by postFrame() once the screen has been captured to outBuf.- Parameters:
- file- the output file
- Throws:
- IOException- if an I/O error occurs
 
 
-