Class LegacyApplication
- All Implemented Interfaces:
- Application,- SystemListener
- Direct Known Subclasses:
- SimpleApplication
LegacyApplication class represents an instance of a
 real-time 3D rendering jME application.
 An LegacyApplication provides all the tools that are commonly used in jME3
 applications.
 jME3 applications *SHOULD NOT EXTEND* this class but extend SimpleApplication instead.- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AssetManagerprotected AudioRendererprotected Cameraprotected JmeContextprotected ViewPortprotected booleanprotected InputManagerprotected JoyInputprotected KeyInputprotected Listenerprotected LostFocusBehaviorprotected MouseInputprotected booleanprotected AppProfilerprotected Rendererprotected RenderManagerprotected AppSettingsprotected floatprotected AppStateManagerprotected Timerprotected TouchInputprotected ViewPort
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new instance ofLegacyApplication.LegacyApplication(AppState... initialStates) Create a new instance ofLegacyApplication, preinitialized with the specified set of app states.
- 
Method SummaryModifier and TypeMethodDescriptionvoidInitializes the application's canvas for use.voiddestroy()Do not call manually.protected voidvoidEnqueues a runnable object to execute in the jME3 rendering thread.<V> Future<V>Enqueues a task/callable object to execute in the jME3 rendering thread.voidInternal use only.Returns the current AppProfiler hook, or null if none is set.Determine the application's behavior when unfocused.getTimer()voidhandleError(String errMsg, Throwable t) Internal use only.voidDo not call manually.booleanReturns true if pause on lost focus is enabled, false otherwise.voidInternal use only.voidrequestClose(boolean esc) Internal use only.voidrescale(float x, float y) Called to notify the application that the scale has changed.voidreshape(int w, int h) Internal use only.voidrestart()Restarts the context, applying any changed settings.protected voidRuns tasks enqueued viaenqueue(Callable)voidsetAppProfiler(AppProfiler prof) Sets an AppProfiler hook that will be called back for specific steps within a single update frame.voidsetAssetManager(AssetManager assetManager) Deprecated.voidsetLostFocusBehavior(LostFocusBehavior lostFocusBehavior) Changes the application's behavior when unfocused.voidsetPauseOnLostFocus(boolean pauseOnLostFocus) Enable or disable pause on lost focus.voidsetSettings(AppSettings settings) Set the display settings to define the display created.voidSets the Timer implementation that will be used for calculating frame times.voidstart()Starts the application indisplaymode.voidstart(boolean waitFor) Starts the application indisplaymode.voidstart(JmeContext.Type contextType) Starts the application.voidstart(JmeContext.Type contextType, boolean waitFor) Starts the application.voidStarts the rendering thread after createCanvas() has been called.voidstartCanvas(boolean waitFor) Starts the rendering thread after createCanvas() has been called.voidstop()Requests the context to close, shutting down the main loop and making necessary cleanup operations.voidstop(boolean waitFor) Requests the context to close, shutting down the main loop and making necessary cleanup operations.voidupdate()Do not call manually.
- 
Field Details- 
assetManager
- 
audioRenderer
- 
renderer
- 
renderManager
- 
viewPort
- 
guiViewPort
- 
context
- 
settings
- 
timer
- 
cam
- 
listener
- 
inputEnabledprotected boolean inputEnabled
- 
lostFocusBehavior
- 
speedprotected float speed
- 
pausedprotected boolean paused
- 
mouseInput
- 
keyInput
- 
joyInput
- 
touchInput
- 
inputManager
- 
stateManager
- 
prof
 
- 
- 
Constructor Details- 
LegacyApplicationpublic LegacyApplication()Create a new instance ofLegacyApplication.
- 
LegacyApplicationCreate a new instance ofLegacyApplication, preinitialized with the specified set of app states.- Parameters:
- initialStates- app states to pre-attach, or null for none
 
 
- 
- 
Method Details- 
getLostFocusBehaviorDetermine the application's behavior when unfocused.- Specified by:
- getLostFocusBehaviorin interface- Application
- Returns:
- The lost focus behavior of the application.
 
- 
setLostFocusBehaviorChanges the application's behavior when unfocused. By default, the application willthrottle the update loopso as not to use 100% of the CPU when out of focus, e.g. alt-tabbed, minimized, or hidden by another window.- Specified by:
- setLostFocusBehaviorin interface- Application
- Parameters:
- lostFocusBehavior- The new lost focus behavior to use.
- See Also:
 
- 
isPauseOnLostFocuspublic boolean isPauseOnLostFocus()Returns true if pause on lost focus is enabled, false otherwise.- Specified by:
- isPauseOnLostFocusin interface- Application
- Returns:
- true if pause on lost focus is enabled
- See Also:
 
- 
setPauseOnLostFocuspublic void setPauseOnLostFocus(boolean pauseOnLostFocus) Enable or disable pause on lost focus.By default, pause on lost focus is enabled. If enabled, the application will stop updating when it loses focus or becomes inactive (e.g. alt-tab). For online or real-time applications, this might be undesirable, so this feature should be disabled. For other applications, it is best to keep it enabled so the CPU is not used unnecessarily. - Specified by:
- setPauseOnLostFocusin interface- Application
- Parameters:
- pauseOnLostFocus- True to enable pause on lost focus, false otherwise.
- See Also:
 
- 
setAssetManagerDeprecated.
- 
setSettingsSet the display settings to define the display created.Examples of display parameters include display pixel width and height, color bit depth, z-buffer bits, anti-aliasing samples, and update frequency. If this method is called while the application is already running, then restart()must be called to apply the settings to the display.- Specified by:
- setSettingsin interface- Application
- Parameters:
- settings- The settings to set.
 
- 
setTimerSets the Timer implementation that will be used for calculating frame times. By default, Application will use the Timer as returned by the current JmeContext implementation.- Specified by:
- setTimerin interface- Application
- Parameters:
- timer- the desired timer (alias created)
 
- 
getTimer- Specified by:
- getTimerin interface- Application
 
- 
getAssetManager- Specified by:
- getAssetManagerin interface- Application
- Returns:
- The asset managerfor this application.
 
- 
getInputManager- Specified by:
- getInputManagerin interface- Application
- Returns:
- the input manager.
 
- 
getStateManager- Specified by:
- getStateManagerin interface- Application
- Returns:
- the app state manager
 
- 
getRenderManager- Specified by:
- getRenderManagerin interface- Application
- Returns:
- the render manager
 
- 
getRenderer- Specified by:
- getRendererin interface- Application
- Returns:
- The rendererfor the application
 
- 
getAudioRenderer- Specified by:
- getAudioRendererin interface- Application
- Returns:
- The audio rendererfor the application
 
- 
getListener- Specified by:
- getListenerin interface- Application
- Returns:
- The listenerobject for audio
 
- 
getContext- Specified by:
- getContextin interface- Application
- Returns:
- The display contextfor the application
 
- 
getCamera- Specified by:
- getCamerain interface- Application
- Returns:
- The camerafor the application
 
- 
startpublic void start()Starts the application indisplaymode.- Specified by:
- startin interface- Application
- See Also:
 
- 
startpublic void start(boolean waitFor) Starts the application indisplaymode.- Specified by:
- startin interface- Application
- Parameters:
- waitFor- true→wait for the context to be initialized, false→don't wait
- See Also:
 
- 
startStarts the application. Creating a rendering context and executing the main loop in a separate thread.- Parameters:
- contextType- the type of context to create
 
- 
startStarts the application. Creating a rendering context and executing the main loop in a separate thread.- Parameters:
- contextType- the type of context to create
- waitFor- true→wait for the context to be initialized, false→don't wait
 
- 
setAppProfilerSets an AppProfiler hook that will be called back for specific steps within a single update frame. Value defaults to null.- Specified by:
- setAppProfilerin interface- Application
- Parameters:
- prof- the profiler to use (alias created) or null for none
 
- 
getAppProfilerReturns the current AppProfiler hook, or null if none is set.- Specified by:
- getAppProfilerin interface- Application
- Returns:
- the pre-existing instance, or null if none
 
- 
createCanvaspublic void createCanvas()Initializes the application's canvas for use.After calling this method, cast the getContext()context to JmeCanvasContext, then acquire the canvas with JmeCanvasContext.getCanvas() and attach it to an AWT/Swing Frame. The rendering thread will start when the canvas becomes visible on screen, however if you wish to start the context immediately you may callstartCanvas()to force the rendering thread to start.- See Also:
 
- 
startCanvaspublic void startCanvas()Starts the rendering thread after createCanvas() has been called.Same as calling startCanvas(false) - See Also:
 
- 
startCanvaspublic void startCanvas(boolean waitFor) Starts the rendering thread after createCanvas() has been called.Calling this method is optional, the canvas will start automatically when it becomes visible. - Parameters:
- waitFor- If true, the current thread will block until the rendering thread is running
 
- 
reshapepublic void reshape(int w, int h) Internal use only.- Specified by:
- reshapein interface- SystemListener
- Parameters:
- w- the new width of the display (in pixels, ≥0)
- h- the new height of the display (in pixels, ≥0)
 
- 
rescalepublic void rescale(float x, float y) Description copied from interface:SystemListenerCalled to notify the application that the scale has changed.- Specified by:
- rescalein interface- SystemListener
- Parameters:
- x- the new horizontal scale of the display
- y- the new vertical scale of the display
 
- 
restartpublic void restart()Restarts the context, applying any changed settings.Changes to the AppSettingsof this Application are not applied immediately; calling this method forces the context to restart, applying the new settings.- Specified by:
- restartin interface- Application
 
- 
stoppublic void stop()Requests the context to close, shutting down the main loop and making necessary cleanup operations. Same as calling stop(false)- Specified by:
- stopin interface- Application
- See Also:
 
- 
stoppublic void stop(boolean waitFor) Requests the context to close, shutting down the main loop and making necessary cleanup operations. After the application has stopped, it cannot be used anymore.- Specified by:
- stopin interface- Application
- Parameters:
- waitFor- true→wait for the context to be fully destroyed, false→don't wait
 
- 
initializepublic void initialize()Do not call manually. Callback from ContextListener.Initializes the Application, by creating a display and default camera. If display settings are not specified, a default 640x480 display is created. Default values are used for the camera; perspective projection with 45° field of view, with near and far values 1 and 1000 units respectively.- Specified by:
- initializein interface- SystemListener
 
- 
handleErrorInternal use only.- Specified by:
- handleErrorin interface- SystemListener
- Parameters:
- errMsg- The error message, if any, or null.
- t- Throwable object, or null.
 
- 
gainFocuspublic void gainFocus()Internal use only.- Specified by:
- gainFocusin interface- SystemListener
 
- 
loseFocuspublic void loseFocus()Internal use only.- Specified by:
- loseFocusin interface- SystemListener
 
- 
requestClosepublic void requestClose(boolean esc) Internal use only.- Specified by:
- requestClosein interface- SystemListener
- Parameters:
- esc- If true, the user pressed ESC to close the application.
 
- 
enqueueEnqueues a task/callable object to execute in the jME3 rendering thread.Callables are executed right at the beginning of the main loop. They are executed even if the application is currently paused or out of focus. - Specified by:
- enqueuein interface- Application
- Type Parameters:
- V- type of result returned by the Callable
- Parameters:
- callable- The callable to run in the main jME3 thread
- Returns:
- a new instance
 
- 
enqueueEnqueues a runnable object to execute in the jME3 rendering thread.Runnables are executed right at the beginning of the main loop. They are executed even if the application is currently paused or out of focus. - Specified by:
- enqueuein interface- Application
- Parameters:
- runnable- The runnable to run in the main jME3 thread
 
- 
runQueuedTasksprotected void runQueuedTasks()Runs tasks enqueued viaenqueue(Callable)
- 
updatepublic void update()Do not call manually. Callback from ContextListener.- Specified by:
- updatein interface- SystemListener
 
- 
destroyInputprotected void destroyInput()
- 
destroypublic void destroy()Do not call manually. Callback from ContextListener.- Specified by:
- destroyin interface- SystemListener
 
- 
getGuiViewPort- Specified by:
- getGuiViewPortin interface- Application
- Returns:
- The GUI viewport. Which is used for the on screen statistics and FPS.
 
- 
getViewPort- Specified by:
- getViewPortin interface- Application
 
 
-