Class BaseAppState
- All Implemented Interfaces:
- AppState
- Direct Known Subclasses:
- ArmatureDebugAppState,- AudioListenerState,- BasicProfilerState,- ConstantVerifierState,- DetailedProfilerState,- EnvironmentCamera,- LightsDebugState
initialize() and cleanup() can be used by subclasses to manage resources that should exist the entire time that the app state is attached. This is useful for resources that might be expensive to create or load.
onEnable()/onDisable() can be used for managing things that should only exist while the state is enabled. Prime examples would be scene graph attachment or input listener attachment.
The base class logic is such that onDisable() will always be called before cleanup() if the state is enabled. Likewise, enable() will always be called after initialize() if the state is enable(). onEnable()/onDisable() are also called appropriate when setEnabled() is called that changes the enabled state AND if the state is attached. In other words, onEnable()/onDisable() are only ever called on an already attached state.
It is technically safe to do all initialization and cleanup in the onEnable()/onDisable() methods. Choosing to use initialize() and cleanup() for this is a matter of performance specifics for the implementor.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidcleanup()Do not call directly: Called by the state manager to terminate this state post-detachment or during state manager termination.protected abstract voidcleanup(Application app) Called after the app state is detached or during application shutdown if the state is still attached.final ApplicationgetId()Returns the unique ID for this AppState or null if it has no unique ID.final <T extends AppState>
 Tfinal <T extends AppState>
 Tfinal <T extends AppState>
 Tfinal <T extends AppState>
 Tfinal AppStateManagerprotected abstract voidinitialize(Application app) Called during initialization once the app state is attached and before onEnable() is called.final voidinitialize(AppStateManager stateManager, Application app) Do not call directly: Called by the state manager to initialize this state post-attachment.final booleanfinal booleanprotected abstract voidCalled when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.protected abstract voidonEnable()Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.voidCalled after all rendering commands are flushed.voidrender(RenderManager rm) Render the state.final voidsetEnabled(boolean enabled) Enable or disable the functionality of theAppState.protected voidSets the unique ID of this app state.voidstateAttached(AppStateManager stateManager) Called byAppStateManager.attach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom detached to initializing.voidstateDetached(AppStateManager stateManager) Called byAppStateManager.detach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom running to terminating.voidupdate(float tpf) Called to update theAppState.
- 
Constructor Details- 
BaseAppStateprotected BaseAppState()
- 
BaseAppState
 
- 
- 
Method Details- 
initializeCalled during initialization once the app state is attached and before onEnable() is called.- Parameters:
- app- the application
 
- 
cleanupCalled after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.- Parameters:
- app- the application
 
- 
onEnableprotected abstract void onEnable()Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.
- 
onDisableprotected abstract void onDisable()Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.
- 
initializeDo not call directly: Called by the state manager to initialize this state post-attachment. This implementation calls initialize(app) and then onEnable() if the state is enabled.- Specified by:
- initializein interface- AppState
- Parameters:
- stateManager- The state manager
- app- The application
 
- 
isInitializedpublic final boolean isInitialized()- Specified by:
- isInitializedin interface- AppState
- Returns:
- True if initialize()was called on the state, false otherwise.
 
- 
setIdSets the unique ID of this app state. Note: that setting this while an app state is attached to the state manager will have no effect on ID-based lookups.- Parameters:
- id- the desired ID
 
- 
getIdDescription copied from interface:AppStateReturns the unique ID for this AppState or null if it has no unique ID.
- 
getApplication
- 
getStateManager
- 
getState
- 
getState
- 
getState
- 
getState
- 
setEnabledpublic final void setEnabled(boolean enabled) Description copied from interface:AppStateEnable or disable the functionality of theAppState. The effect of this call depends on implementation. AnAppStatestarts as being enabled by default. A disabledAppStates does not get calls toAppState.update(float),AppState.render(RenderManager), orAppState.postRender()from itsAppStateManager.- Specified by:
- setEnabledin interface- AppState
- Parameters:
- enabled- activate the AppState or not.
 
- 
isEnabledpublic final boolean isEnabled()
- 
stateAttachedDescription copied from interface:AppStateCalled byAppStateManager.attach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom detached to initializing.There is no assumption about the thread from which this function is called, therefore it is unsafe to modify the scene graph from this method. Please use AppState.initialize(com.jme3.app.state.AppStateManager, com.jme3.app.Application)instead.- Specified by:
- stateAttachedin interface- AppState
- Parameters:
- stateManager- State manager to which the state was attached to.
 
- 
stateDetachedDescription copied from interface:AppStateCalled byAppStateManager.detach(com.jme3.app.state.AppState)when transitioning thisAppStatefrom running to terminating.There is no assumption about the thread from which this function is called, therefore it is unsafe to modify the scene graph from this method. Please use AppState.cleanup()instead.- Specified by:
- stateDetachedin interface- AppState
- Parameters:
- stateManager- The state manager from which the state was detached from.
 
- 
updatepublic void update(float tpf) Description copied from interface:AppStateCalled to update theAppState. This method will be called every render pass if theAppStateis both attached and enabled.
- 
renderDescription copied from interface:AppStateRender the state. This method will be called every render pass if theAppStateis both attached and enabled.
- 
postRenderpublic void postRender()Description copied from interface:AppStateCalled after all rendering commands are flushed. This method will be called every render pass if theAppStateis both attached and enabled.- Specified by:
- postRenderin interface- AppState
 
- 
cleanuppublic final void cleanup()Do not call directly: Called by the state manager to terminate this state post-detachment or during state manager termination. This implementation calls onDisable() if the state is enabled and then cleanup(app).
 
-