com.jme3.system
Class AppSettings

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.lang.Object>
          extended by com.jme3.system.AppSettings
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>

public final class AppSettings
extends java.util.HashMap<java.lang.String,java.lang.Object>

AppSettings provides a store of configuration to be used by the application.

By default only the context uses the configuration, however the user may set and retrieve the settings as well. The settings can be stored either in the Java preferences (using save(java.lang.String) or a .properties file (using save(java.io.OutputStream).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
static java.lang.String LWJGL_OPENAL
          Use the LWJGL OpenAL based renderer for audio capabilities.
static java.lang.String LWJGL_OPENGL_ANY
          Use LWJGL as the display system and allow the context to choose an appropriate renderer based on system capabilities.
static java.lang.String LWJGL_OPENGL1
          Use LWJGL as the display system and force using the OpenGL1.1 renderer.
static java.lang.String LWJGL_OPENGL2
          Use LWJGL as the display system and force using the OpenGL2.0 renderer.
static java.lang.String LWJGL_OPENGL3
          Use LWJGL as the display system and force using the core OpenGL3.3 renderer.
 
Constructor Summary
AppSettings(boolean loadDefaults)
          Create a new instance of AppSettings.
 
Method Summary
 void copyFrom(AppSettings other)
          Copies all settings from other to this AppSettings.
 java.lang.String getAudioRenderer()
          Get the audio renderer
 int getBitsPerPixel()
          Get the bits per pixel
 boolean getBoolean(java.lang.String key)
          Get a boolean from the settings.
 int getDepthBits()
          Get the number of depth bits
 float getFloat(java.lang.String key)
          Get a float from the settings.
 int getFrameRate()
          Get the framerate.
 int getFrequency()
          Get the frequency
 int getHeight()
          Get the height
 java.lang.Object[] getIcons()
          Get the icon array
 int getInteger(java.lang.String key)
          Get an integer from the settings.
 java.lang.String getRenderer()
          Get the renderer
 int getSamples()
          Get the number of samples
 java.lang.String getSettingsDialogImage()
          Get the settings dialog image
 int getStencilBits()
          Get the number of stencil bits
 java.lang.String getString(java.lang.String key)
          Get a string from the settings.
 java.lang.String getTitle()
          Get the application title
 int getWidth()
          Get the width
 boolean isEmulateMouse()
          Returns true if mouse emulation is enabled, false otherwise.
 boolean isEmulateMouseFlipX()
           
 boolean isEmulateMouseFlipY()
           
 boolean isFullscreen()
          Get the fullscreen state
 boolean isVSync()
          Get the vsync state
 void load(java.io.InputStream in)
          Loads the settings from the given properties input stream.
 void load(java.lang.String preferencesKey)
          Loads settings previously saved in the Java preferences.
 void mergeFrom(AppSettings other)
          Same as copyFrom(com.jme3.system.AppSettings), except doesn't overwrite settings that are already set.
 void putBoolean(java.lang.String key, boolean value)
          Set a boolean on the settings.
 void putFloat(java.lang.String key, float value)
          Set a float on the settings.
 void putInteger(java.lang.String key, int value)
          Set an integer on the settings.
 void putString(java.lang.String key, java.lang.String value)
          Set a string on the settings.
 void save(java.io.OutputStream out)
          Saves all settings to the given properties output stream.
 void save(java.lang.String preferencesKey)
          Saves settings into the Java preferences.
 void setAudioRenderer(java.lang.String audioRenderer)
          Set the audio renderer to use.
 void setBitsPerPixel(int value)
          Set the bits per pixel for the display.
 void setCustomRenderer(java.lang.Class<? extends JmeContext> clazz)
          Set a custom graphics renderer to use.
 void setDepthBits(int value)
          Sets the number of depth bits to use.
 void setEmulateMouse(boolean emulateMouse)
          Enable or disable mouse emulation on touchscreen based devices.
 void setEmulateMouseFlipAxis(boolean flipX, boolean flipY)
          Specify if the X or Y (or both) axes should be flipped for emulated mouse.
 void setFrameRate(int frameRate)
           
 void setFrequency(int value)
          Set the frequency, also known as refresh rate, for the rendering display.
 void setFullscreen(boolean value)
           
 void setHeight(int value)
           
 void setIcons(java.lang.Object[] value)
          Sets the application icons to be used, with the most preferred first.
 void setRenderer(java.lang.String renderer)
          Set the graphics renderer to use, one of:
AppSettings.LWJGL_OPENGL1 - Force OpenGL1.1 compatability AppSettings.LWJGL_OPENGL2 - Force OpenGL2 compatability AppSettings.LWJGL_OPENGL3 - Force OpenGL3.3 compatability AppSettings.LWJGL_OPENGL_ANY - Choose an appropriate OpenGL version based on system capabilities null - Disable graphics rendering
 void setResolution(int width, int height)
          Set the resolution for the rendering display
 void setSamples(int value)
          Set the number of samples per pixel.
 void setSettingsDialogImage(java.lang.String path)
          Sets the path of the settings dialog image to use.
 void setStencilBits(int value)
          Set the number of stencil bits.
 void setStereo3D(boolean value)
          Enable 3D stereo.
 void setTitle(java.lang.String title)
           
 void setUseInput(boolean use)
           
 void setUseJoysticks(boolean use)
           
 void setVSync(boolean value)
          Set to true to enable vertical-synchronization, limiting and synchronizing every frame rendered to the monitor's refresh rate.
 void setWidth(int value)
           
 boolean useInput()
          Get the use input state.
 boolean useJoysticks()
          Get the use joysticks state
 boolean useStereo3D()
          Get the stereo 3D state
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

LWJGL_OPENGL1

public static final java.lang.String LWJGL_OPENGL1
Use LWJGL as the display system and force using the OpenGL1.1 renderer.

See Also:
setRenderer(java.lang.String), Constant Field Values

LWJGL_OPENGL2

public static final java.lang.String LWJGL_OPENGL2
Use LWJGL as the display system and force using the OpenGL2.0 renderer.

If the underlying system does not support OpenGL2.0, then the context initialization will throw an exception.

See Also:
setRenderer(java.lang.String), Constant Field Values

LWJGL_OPENGL3

public static final java.lang.String LWJGL_OPENGL3
Use LWJGL as the display system and force using the core OpenGL3.3 renderer.

If the underlying system does not support OpenGL3.3, then the context initialization will throw an exception. Note that currently jMonkeyEngine does not have any shaders that support OpenGL3.3 therefore this option is not useful.

See Also:
setRenderer(java.lang.String), Constant Field Values

LWJGL_OPENGL_ANY

public static final java.lang.String LWJGL_OPENGL_ANY
Use LWJGL as the display system and allow the context to choose an appropriate renderer based on system capabilities.

If the GPU supports OpenGL2 or later, then the OpenGL2.0 renderer will be used, otherwise, the OpenGL1.1 renderer is used.

See Also:
setRenderer(java.lang.String), Constant Field Values

LWJGL_OPENAL

public static final java.lang.String LWJGL_OPENAL
Use the LWJGL OpenAL based renderer for audio capabilities.

See Also:
setAudioRenderer(java.lang.String), Constant Field Values
Constructor Detail

AppSettings

public AppSettings(boolean loadDefaults)
Create a new instance of AppSettings.

If loadDefaults is true, then the default settings will be set on the AppSettings. Use false if you want to change some settings but you would like the application to load settings from previous launches.

Parameters:
loadDefaults - If default settings are to be loaded.
Method Detail

copyFrom

public void copyFrom(AppSettings other)
Copies all settings from other to this AppSettings.

Any settings that are specified in other will overwrite settings set on this AppSettings.

Parameters:
other - The AppSettings to copy the settings from

mergeFrom

public void mergeFrom(AppSettings other)
Same as copyFrom(com.jme3.system.AppSettings), except doesn't overwrite settings that are already set.

Parameters:
other - The AppSettings to merge the settings from

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Loads the settings from the given properties input stream.

Parameters:
in - The InputStream to load from
Throws:
java.io.IOException - If an IOException occurs
See Also:
save(java.io.OutputStream)

save

public void save(java.io.OutputStream out)
          throws java.io.IOException
Saves all settings to the given properties output stream.

Parameters:
out - The OutputStream to write to
Throws:
java.io.IOException - If an IOException occurs
See Also:
load(java.io.InputStream)

load

public void load(java.lang.String preferencesKey)
          throws java.util.prefs.BackingStoreException
Loads settings previously saved in the Java preferences.

Parameters:
preferencesKey - The preferencesKey previously used to save the settings.
Throws:
java.util.prefs.BackingStoreException - If an exception occurs with the preferences
See Also:
save(java.lang.String)

save

public void save(java.lang.String preferencesKey)
          throws java.util.prefs.BackingStoreException
Saves settings into the Java preferences.

On the Windows operating system, the preferences are saved in the registry at the following key:
HKEY_CURRENT_USER\Software\JavaSoft\Prefs\[preferencesKey]

Parameters:
preferencesKey - The preferences key to save at. Generally the application's unique name.
Throws:
java.util.prefs.BackingStoreException - If an exception occurs with the preferences

getInteger

public int getInteger(java.lang.String key)
Get an integer from the settings.

If the key is not set, then 0 is returned.


getBoolean

public boolean getBoolean(java.lang.String key)
Get a boolean from the settings.

If the key is not set, then false is returned.


getString

public java.lang.String getString(java.lang.String key)
Get a string from the settings.

If the key is not set, then null is returned.


getFloat

public float getFloat(java.lang.String key)
Get a float from the settings.

If the key is not set, then 0.0 is returned.


putInteger

public void putInteger(java.lang.String key,
                       int value)
Set an integer on the settings.


putBoolean

public void putBoolean(java.lang.String key,
                       boolean value)
Set a boolean on the settings.


putString

public void putString(java.lang.String key,
                      java.lang.String value)
Set a string on the settings.


putFloat

public void putFloat(java.lang.String key,
                     float value)
Set a float on the settings.


setEmulateMouse

public void setEmulateMouse(boolean emulateMouse)
Enable or disable mouse emulation on touchscreen based devices. This will convert taps on the touchscreen or movement of finger over touchscreen (only the first) into the appropriate mouse events.

Parameters:
emulateMouse - If mouse emulation should be enabled.

isEmulateMouse

public boolean isEmulateMouse()
Returns true if mouse emulation is enabled, false otherwise.

Returns:
Mouse emulation mode.

setEmulateMouseFlipAxis

public void setEmulateMouseFlipAxis(boolean flipX,
                                    boolean flipY)
Specify if the X or Y (or both) axes should be flipped for emulated mouse.

Parameters:
flipX - Set to flip X axis
flipY - Set to flip Y axis
See Also:
setEmulateMouse(boolean)

isEmulateMouseFlipX

public boolean isEmulateMouseFlipX()

isEmulateMouseFlipY

public boolean isEmulateMouseFlipY()

setFrameRate

public void setFrameRate(int frameRate)
Parameters:
frameRate - The frame-rate is the upper limit on how high the application's frames-per-second can go. (Default: -1 no frame rate limit imposed)

setUseInput

public void setUseInput(boolean use)
Parameters:
use - If true, the application will initialize and use input. Set to false for headless applications that do not require keyboard or mouse input. (Default: true)

setUseJoysticks

public void setUseJoysticks(boolean use)
Parameters:
use - If true, the application will initialize and use joystick input. Set to false if no joystick input is desired. (Default: false)

setRenderer

public void setRenderer(java.lang.String renderer)
Set the graphics renderer to use, one of:

Parameters:
renderer - The renderer to set (Default: AppSettings.LWJGL_OPENGL2)

setCustomRenderer

public void setCustomRenderer(java.lang.Class<? extends JmeContext> clazz)
Set a custom graphics renderer to use. The class should implement the JmeContext interface.

Parameters:
clazz - The custom context class. (Default: not set)

setAudioRenderer

public void setAudioRenderer(java.lang.String audioRenderer)
Set the audio renderer to use. One of:

Parameters:
audioRenderer - (Default: LWJGL)

setWidth

public void setWidth(int value)
Parameters:
value - the width for the rendering display. (Default: 640)

setHeight

public void setHeight(int value)
Parameters:
value - the height for the rendering display. (Default: 480)

setResolution

public void setResolution(int width,
                          int height)
Set the resolution for the rendering display

Parameters:
width - The width
height - The height (Default: 640x480)

setFrequency

public void setFrequency(int value)
Set the frequency, also known as refresh rate, for the rendering display.

Parameters:
value - The frequency (Default: 60)

setDepthBits

public void setDepthBits(int value)
Sets the number of depth bits to use.

The number of depth bits specifies the precision of the depth buffer. To increase precision, specify 32 bits. To decrease precision, specify 16 bits. On some platforms 24 bits might not be supported, in that case, specify 16 bits.

(Default: 24)

Parameters:
value - The depth bits

setStencilBits

public void setStencilBits(int value)
Set the number of stencil bits.

This value is only relevant when the stencil buffer is being used. Specify 8 to indicate an 8-bit stencil buffer, specify 0 to disable the stencil buffer.

(Default: 0)

Parameters:
value - Number of stencil bits

setBitsPerPixel

public void setBitsPerPixel(int value)
Set the bits per pixel for the display. Appropriate values are 16 for RGB565 color format, or 24 for RGB8 color format.

Parameters:
value - The bits per pixel to set (Default: 24)

setSamples

public void setSamples(int value)
Set the number of samples per pixel. A value of 1 indicates each pixel should be single-sampled, higher values indicate a pixel should be multi-sampled.

Parameters:
value - The number of samples (Default: 1)

setTitle

public void setTitle(java.lang.String title)
Parameters:
title - The title of the rendering display (Default: jMonkeyEngine 3.0)

setFullscreen

public void setFullscreen(boolean value)
Parameters:
value - true to enable full-screen rendering, false to render in a window (Default: false)

setVSync

public void setVSync(boolean value)
Set to true to enable vertical-synchronization, limiting and synchronizing every frame rendered to the monitor's refresh rate.

Parameters:
value - (Default: false)

setStereo3D

public void setStereo3D(boolean value)
Enable 3D stereo.

This feature requires hardware support from the GPU driver.

See Also:
http://en.wikipedia.org/wiki/Quad_buffering
Once enabled, filters or scene processors that handle 3D stereo rendering could use this feature to render using hardware 3D stereo.

(Default: false)

setIcons

public void setIcons(java.lang.Object[] value)
Sets the application icons to be used, with the most preferred first. For Windows you should supply at least one 16x16 icon and one 32x32. The former is used for the title/task bar, the latter for the alt-tab icon. Linux (and similar platforms) expect one 32x32 icon. Mac OS X should be supplied one 128x128 icon.
The icon is used for the settings window, and the LWJGL render window. Not currently supported for JOGL. Note that a bug in Java 6 (bug ID 6445278, currently hidden but available in Google cache) currently prevents the icon working for alt-tab on the settings dialog in Windows.

Parameters:
value - An array of BufferedImages to use as icons. (Default: not set)

setSettingsDialogImage

public void setSettingsDialogImage(java.lang.String path)
Sets the path of the settings dialog image to use.

The image will be displayed in the settings dialog when the application is started.

(Default: /com/jme3/app/Monkey.png)

Parameters:
path - The path to the image in the classpath.

getFrameRate

public int getFrameRate()
Get the framerate.

See Also:
setFrameRate(int)

useInput

public boolean useInput()
Get the use input state.

See Also:
setUseInput(boolean)

getRenderer

public java.lang.String getRenderer()
Get the renderer

See Also:
setRenderer(java.lang.String)

getWidth

public int getWidth()
Get the width

See Also:
setWidth(int)

getHeight

public int getHeight()
Get the height

See Also:
setHeight(int)

getBitsPerPixel

public int getBitsPerPixel()
Get the bits per pixel

See Also:
setBitsPerPixel(int)

getFrequency

public int getFrequency()
Get the frequency

See Also:
setFrequency(int)

getDepthBits

public int getDepthBits()
Get the number of depth bits

See Also:
setDepthBits(int)

getStencilBits

public int getStencilBits()
Get the number of stencil bits

See Also:
setStencilBits(int)

getSamples

public int getSamples()
Get the number of samples

See Also:
setSamples(int)

getTitle

public java.lang.String getTitle()
Get the application title

See Also:
setTitle(java.lang.String)

isVSync

public boolean isVSync()
Get the vsync state

See Also:
setVSync(boolean)

isFullscreen

public boolean isFullscreen()
Get the fullscreen state

See Also:
setFullscreen(boolean)

useJoysticks

public boolean useJoysticks()
Get the use joysticks state

See Also:
setUseJoysticks(boolean)

getAudioRenderer

public java.lang.String getAudioRenderer()
Get the audio renderer

See Also:
setAudioRenderer(java.lang.String)

useStereo3D

public boolean useStereo3D()
Get the stereo 3D state

See Also:
setStereo3D(boolean)

getIcons

public java.lang.Object[] getIcons()
Get the icon array

See Also:
setIcons(java.lang.Object[])

getSettingsDialogImage

public java.lang.String getSettingsDialogImage()
Get the settings dialog image

See Also:
setSettingsDialogImage(java.lang.String)