com.jme3.app
Class Application

java.lang.Object
  extended by com.jme3.app.Application
All Implemented Interfaces:
SystemListener
Direct Known Subclasses:
SimpleApplication

public class Application
extends java.lang.Object
implements SystemListener

The Application class represents an instance of a real-time 3D rendering jME application. An Application provides all the tools that are commonly used in jME3 applications. jME3 applications should extend this class and call start() to begin the application.


Field Summary
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  MouseInput mouseInput
           
protected  boolean paused
           
protected  boolean pauseOnFocus
           
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 Summary
Application()
          Create a new instance of Application.
 
Method Summary
 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 gainFocus()
          Internal use only.
 AssetManager getAssetManager()
           
 AudioRenderer getAudioRenderer()
           
 Camera getCamera()
           
 JmeContext getContext()
           
 ViewPort getGuiViewPort()
           
 InputManager getInputManager()
           
 Listener getListener()
           
 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 setAssetManager(AssetManager assetManager)
          Deprecated. 
 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(JmeContext.Type contextType)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

assetManager

protected AssetManager assetManager

audioRenderer

protected AudioRenderer audioRenderer

renderer

protected Renderer renderer

renderManager

protected RenderManager renderManager

viewPort

protected ViewPort viewPort

guiViewPort

protected ViewPort guiViewPort

context

protected JmeContext context

settings

protected AppSettings settings

timer

protected Timer timer

cam

protected Camera cam

listener

protected Listener listener

inputEnabled

protected boolean inputEnabled

pauseOnFocus

protected boolean pauseOnFocus

speed

protected float speed

paused

protected boolean paused

mouseInput

protected MouseInput mouseInput

keyInput

protected KeyInput keyInput

joyInput

protected JoyInput joyInput

touchInput

protected TouchInput touchInput

inputManager

protected InputManager inputManager

stateManager

protected AppStateManager stateManager
Constructor Detail

Application

public Application()
Create a new instance of Application.

Method Detail

isPauseOnLostFocus

public boolean isPauseOnLostFocus()
Returns true if pause on lost focus is enabled, false otherwise.

Returns:
true if pause on lost focus is enabled
See Also:
setPauseOnLostFocus(boolean)

setPauseOnLostFocus

public 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 not be preferable, so this feature should be set to disabled. For other applications, it is best to keep it on so that CPU usage is not used when not necessary.

Parameters:
pauseOnLostFocus - True to enable pause on lost focus, false otherwise.

setAssetManager

@Deprecated
public void setAssetManager(AssetManager assetManager)
Deprecated. 


setSettings

public void setSettings(AppSettings settings)
Set 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.

Parameters:
settings - The settings to set.

setTimer

public void setTimer(Timer timer)
Sets 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.


getTimer

public Timer getTimer()

getAssetManager

public AssetManager getAssetManager()
Returns:
The asset manager for this application.

getInputManager

public InputManager getInputManager()
Returns:
the input manager.

getStateManager

public AppStateManager getStateManager()
Returns:
the app state manager

getRenderManager

public RenderManager getRenderManager()
Returns:
the render manager

getRenderer

public Renderer getRenderer()
Returns:
The renderer for the application

getAudioRenderer

public AudioRenderer getAudioRenderer()
Returns:
The audio renderer for the application

getListener

public Listener getListener()
Returns:
The listener object for audio

getContext

public JmeContext getContext()
Returns:
The display context for the application

getCamera

public Camera getCamera()
Returns:
The camera for the application

start

public void start()
Starts the application in display mode.

See Also:
start(com.jme3.system.JmeContext.Type)

start

public void start(JmeContext.Type contextType)
Starts the application. Creating a rendering context and executing the main loop in a separate thread.


createCanvas

public void createCanvas()
Initializes the application's canvas for use.

After calling this method, cast the 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.

See Also:
JmeCanvasContext, JmeContext.Type.Canvas

startCanvas

public void startCanvas()
Starts the rendering thread after createCanvas() has been called.

Same as calling startCanvas(false)

See Also:
startCanvas(boolean)

startCanvas

public 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

reshape

public void reshape(int w,
                    int h)
Internal use only.

Specified by:
reshape in interface SystemListener

restart

public void restart()
Restarts the context, applying any changed settings.

Changes to the AppSettings of this Application are not applied immediately; calling this method forces the context to restart, applying the new settings.


stop

public void stop()
Requests the context to close, shutting down the main loop and making necessary cleanup operations. Same as calling stop(false)

See Also:
stop(boolean)

stop

public 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.


initialize

public 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:
initialize in interface SystemListener

handleError

public void handleError(java.lang.String errMsg,
                        java.lang.Throwable t)
Internal use only.

Specified by:
handleError in interface SystemListener
Parameters:
errMsg - The error message, if any, or null.
t - Throwable object, or null.

gainFocus

public void gainFocus()
Internal use only.

Specified by:
gainFocus in interface SystemListener

loseFocus

public void loseFocus()
Internal use only.

Specified by:
loseFocus in interface SystemListener

requestClose

public void requestClose(boolean esc)
Internal use only.

Specified by:
requestClose in interface SystemListener
Parameters:
esc - If true, the user pressed ESC to close the application.

enqueue

public <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.

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.


runQueuedTasks

protected void runQueuedTasks()
Runs tasks enqueued via enqueue(Callable)


update

public void update()
Do not call manually. Callback from ContextListener.

Specified by:
update in interface SystemListener

destroyInput

protected void destroyInput()

destroy

public void destroy()
Do not call manually. Callback from ContextListener.

Specified by:
destroy in interface SystemListener

getGuiViewPort

public ViewPort getGuiViewPort()
Returns:
The GUI viewport. Which is used for the on screen statistics and FPS.

getViewPort

public ViewPort getViewPort()