public class LegacyApplication extends java.lang.Object implements Application, SystemListener
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.| Modifier and Type | Field and Description |
|---|---|
protected AssetManager |
assetManager |
protected AudioRenderer |
audioRenderer |
protected Camera |
cam |
protected JmeContext |
context |
protected ViewPort |
guiViewPort |
protected boolean |
inputEnabled |
protected InputManager |
inputManager |
protected JoyInput |
joyInput |
protected KeyInput |
keyInput |
protected Listener |
listener |
protected LostFocusBehavior |
lostFocusBehavior |
protected MouseInput |
mouseInput |
protected boolean |
paused |
protected AppProfiler |
prof |
protected Renderer |
renderer |
protected RenderManager |
renderManager |
protected AppSettings |
settings |
protected float |
speed |
protected AppStateManager |
stateManager |
protected Timer |
timer |
protected TouchInput |
touchInput |
protected ViewPort |
viewPort |
| Constructor and Description |
|---|
LegacyApplication()
Create a new instance of
LegacyApplication. |
LegacyApplication(AppState... initialStates)
Create a new instance of
LegacyApplication, preinitialized
with the specified set of app states. |
| Modifier and Type | Method and Description |
|---|---|
void |
createCanvas()
Initializes the application's canvas for use.
|
void |
destroy()
Do not call manually.
|
protected void |
destroyInput() |
<V> java.util.concurrent.Future<V> |
enqueue(java.util.concurrent.Callable<V> callable)
Enqueues a task/callable object to execute in the jME3
rendering thread.
|
void |
enqueue(java.lang.Runnable runnable)
Enqueues a runnable object to execute in the jME3
rendering thread.
|
void |
gainFocus()
Internal use only.
|
AppProfiler |
getAppProfiler()
Returns the current AppProfiler hook, or null if none is set.
|
AssetManager |
getAssetManager() |
AudioRenderer |
getAudioRenderer() |
Camera |
getCamera() |
JmeContext |
getContext() |
ViewPort |
getGuiViewPort() |
InputManager |
getInputManager() |
Listener |
getListener() |
LostFocusBehavior |
getLostFocusBehavior()
Determine the application's behavior when unfocused.
|
Renderer |
getRenderer() |
RenderManager |
getRenderManager() |
AppStateManager |
getStateManager() |
Timer |
getTimer() |
ViewPort |
getViewPort() |
void |
handleError(java.lang.String errMsg,
java.lang.Throwable t)
Internal use only.
|
void |
initialize()
Do not call manually.
|
boolean |
isPauseOnLostFocus()
Returns true if pause on lost focus is enabled, false otherwise.
|
void |
loseFocus()
Internal use only.
|
void |
requestClose(boolean esc)
Internal use only.
|
void |
reshape(int w,
int h)
Internal use only.
|
void |
restart()
Restarts the context, applying any changed settings.
|
protected void |
runQueuedTasks()
Runs tasks enqueued via
enqueue(Callable) |
void |
setAppProfiler(AppProfiler prof)
Sets an AppProfiler hook that will be called back for
specific steps within a single update frame.
|
void |
setAssetManager(AssetManager assetManager)
Deprecated.
|
void |
setLostFocusBehavior(LostFocusBehavior lostFocusBehavior)
Changes the application's behavior when unfocused.
|
void |
setPauseOnLostFocus(boolean pauseOnLostFocus)
Enable or disable pause on lost focus.
|
void |
setSettings(AppSettings settings)
Set the display settings to define the display created.
|
void |
setTimer(Timer timer)
Sets the Timer implementation that will be used for calculating
frame times.
|
void |
start()
Starts the application in
display mode. |
void |
start(boolean waitFor)
Starts the application in
display mode. |
void |
start(JmeContext.Type contextType)
Starts the application.
|
void |
start(JmeContext.Type contextType,
boolean waitFor)
Starts the application.
|
void |
startCanvas()
Starts the rendering thread after createCanvas() has been called.
|
void |
startCanvas(boolean waitFor)
Starts the rendering thread after createCanvas() has been called.
|
void |
stop()
Requests the context to close, shutting down the main loop
and making necessary cleanup operations.
|
void |
stop(boolean waitFor)
Requests the context to close, shutting down the main loop
and making necessary cleanup operations.
|
void |
update()
Do not call manually.
|
protected AssetManager assetManager
protected AudioRenderer audioRenderer
protected Renderer renderer
protected RenderManager renderManager
protected ViewPort viewPort
protected ViewPort guiViewPort
protected JmeContext context
protected AppSettings settings
protected Timer timer
protected Camera cam
protected Listener listener
protected boolean inputEnabled
protected LostFocusBehavior lostFocusBehavior
protected float speed
protected boolean paused
protected MouseInput mouseInput
protected KeyInput keyInput
protected JoyInput joyInput
protected TouchInput touchInput
protected InputManager inputManager
protected AppStateManager stateManager
protected AppProfiler prof
public LegacyApplication()
LegacyApplication.public LegacyApplication(AppState... initialStates)
LegacyApplication, preinitialized
with the specified set of app states.initialStates - app states to pre-attach, or null for nonepublic LostFocusBehavior getLostFocusBehavior()
getLostFocusBehavior in interface Applicationpublic void setLostFocusBehavior(LostFocusBehavior lostFocusBehavior)
throttle the update loop
so as not to use 100% of the CPU when out of focus, e.g.
alt-tabbed, minimized, or hidden by another window.setLostFocusBehavior in interface ApplicationlostFocusBehavior - The new lost focus behavior to use.LostFocusBehaviorpublic boolean isPauseOnLostFocus()
isPauseOnLostFocus in interface ApplicationgetLostFocusBehavior()public void setPauseOnLostFocus(boolean pauseOnLostFocus)
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.
setPauseOnLostFocus in interface ApplicationpauseOnLostFocus - True to enable pause on lost focus, false
otherwise.setLostFocusBehavior(com.jme3.app.LostFocusBehavior)@Deprecated public void setAssetManager(AssetManager assetManager)
public void setSettings(AppSettings settings)
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.
setSettings in interface Applicationsettings - The settings to set.public void setTimer(Timer timer)
setTimer in interface Applicationtimer - the desired timer (alias created)public Timer getTimer()
getTimer in interface Applicationpublic AssetManager getAssetManager()
getAssetManager in interface Applicationasset manager for this application.public InputManager getInputManager()
getInputManager in interface Applicationinput manager.public AppStateManager getStateManager()
getStateManager in interface Applicationapp state managerpublic RenderManager getRenderManager()
getRenderManager in interface Applicationrender managerpublic Renderer getRenderer()
getRenderer in interface Applicationrenderer for the applicationpublic AudioRenderer getAudioRenderer()
getAudioRenderer in interface Applicationaudio renderer for the applicationpublic Listener getListener()
getListener in interface Applicationlistener object for audiopublic JmeContext getContext()
getContext in interface Applicationdisplay context for the applicationpublic Camera getCamera()
getCamera in interface Applicationcamera for the applicationpublic void start()
display mode.start in interface Applicationstart(com.jme3.system.JmeContext.Type)public void start(boolean waitFor)
display mode.start in interface ApplicationwaitFor - true→wait for the context to be initialized,
false→don't waitstart(com.jme3.system.JmeContext.Type)public void start(JmeContext.Type contextType)
contextType - the type of context to createpublic void start(JmeContext.Type contextType, boolean waitFor)
contextType - the type of context to createwaitFor - true→wait for the context to be initialized,
false→don't waitpublic void setAppProfiler(AppProfiler prof)
setAppProfiler in interface Applicationprof - the profiler to use (alias created) or null for nonepublic AppProfiler getAppProfiler()
getAppProfiler in interface Applicationpublic void createCanvas()
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 call startCanvas() to force the rendering thread
to start.
JmeContext.Type.Canvaspublic void startCanvas()
Same as calling startCanvas(false)
startCanvas(boolean)public void startCanvas(boolean waitFor)
Calling this method is optional, the canvas will start automatically when it becomes visible.
waitFor - If true, the current thread will block until the
rendering thread is runningpublic void reshape(int w,
int h)
reshape in interface SystemListenerw - the new width of the display (in pixels, ≥0)h - the new height of the display (in pixels, ≥0)public void restart()
Changes to the AppSettings of this Application are not
applied immediately; calling this method forces the context
to restart, applying the new settings.
restart in interface Applicationpublic void stop()
stop in interface Applicationstop(boolean)public void stop(boolean waitFor)
stop in interface ApplicationwaitFor - true→wait for the context to be fully destroyed,
true→don't waitpublic void initialize()
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.
initialize in interface SystemListenerpublic void handleError(java.lang.String errMsg,
java.lang.Throwable t)
handleError in interface SystemListenererrMsg - The error message, if any, or null.t - Throwable object, or null.public void gainFocus()
gainFocus in interface SystemListenerpublic void loseFocus()
loseFocus in interface SystemListenerpublic void requestClose(boolean esc)
requestClose in interface SystemListeneresc - If true, the user pressed ESC to close the application.public <V> java.util.concurrent.Future<V> enqueue(java.util.concurrent.Callable<V> callable)
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.
enqueue in interface ApplicationV - type of result returned by the Callablecallable - The callable to run in the main jME3 threadpublic void enqueue(java.lang.Runnable runnable)
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.
enqueue in interface Applicationrunnable - The runnable to run in the main jME3 threadprotected void runQueuedTasks()
enqueue(Callable)public void update()
update in interface SystemListenerprotected void destroyInput()
public void destroy()
destroy in interface SystemListenerpublic ViewPort getGuiViewPort()
getGuiViewPort in interface Applicationpublic ViewPort getViewPort()
getViewPort in interface Application