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)
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANDROID_MEDIAPLAYER
Deprecated.
This audio renderer has too many limitations.
use
ANDROID_OPENAL_SOFT instead. |
static java.lang.String |
ANDROID_OPENAL_SOFT
Use the OpenAL Soft based renderer for Android audio capabilities.
|
static java.lang.String |
JOAL
Use JogAmp's JOAL as the audio renderer.
|
static java.lang.String |
JOGL_OPENGL_BACKWARD_COMPATIBLE
Use JogAmp's JOGL as the display system, with the backward compatible profile
|
static java.lang.String |
JOGL_OPENGL_FORWARD_COMPATIBLE
Use JogAmp's JOGL as the display system, with the OpenGL forward compatible profile
|
static java.lang.String |
LWJGL_OPENAL
Use the LWJGL OpenAL based renderer for audio capabilities.
|
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
Deprecated.
Previously meant 3.2, use LWJGL_OPENGL32 or LWJGL_OPENGL30
|
static java.lang.String |
LWJGL_OPENGL30
Use LWJGL as the display system and force using the core OpenGL3.0 renderer.
|
static java.lang.String |
LWJGL_OPENGL31
Use LWJGL as the display system and force using the core OpenGL3.1 renderer.
|
static java.lang.String |
LWJGL_OPENGL32
Use LWJGL as the display system and force using the core OpenGL3.2 renderer.
|
static java.lang.String |
LWJGL_OPENGL33
Use LWJGL as the display system and force using the OpenGL3.3 renderer.
|
static java.lang.String |
LWJGL_OPENGL4
Deprecated.
Use LWJGL_OPENGL40
|
static java.lang.String |
LWJGL_OPENGL40
Use LWJGL as the display system and force using the OpenGL4.0 renderer.
|
static java.lang.String |
LWJGL_OPENGL41
Use LWJGL as the display system and force using the OpenGL4.1 renderer.
|
static java.lang.String |
LWJGL_OPENGL42
Use LWJGL as the display system and force using the OpenGL4.2 renderer.
|
static java.lang.String |
LWJGL_OPENGL43
Use LWJGL as the display system and force using the OpenGL4.3 renderer.
|
static java.lang.String |
LWJGL_OPENGL44
Use LWJGL as the display system and force using the OpenGL4.4 renderer.
|
static java.lang.String |
LWJGL_OPENGL45
Use LWJGL as the display system and force using the OpenGL4.5 renderer.
|
Constructor and Description |
---|
AppSettings(boolean loadDefaults)
Create a new instance of
AppSettings . |
Modifier and Type | Method and Description |
---|---|
void |
copyFrom(AppSettings other)
Copies all settings from
other to this
AppSettings. |
int |
getAlphaBits()
Android Only
Get the number of alpha bits for the surface view to use.
|
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.
|
int |
getMinHeight()
Get the height
|
int |
getMinWidth()
Get the width
|
java.lang.String |
getOpenCLPlatformChooser() |
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 |
isEmulateKeyboard()
Returns true if keyboard emulation is enabled, false otherwise.
|
boolean |
isEmulateMouse()
Returns true if mouse emulation is enabled, false otherwise.
|
boolean |
isEmulateMouseFlipX() |
boolean |
isEmulateMouseFlipY() |
boolean |
isFullscreen()
Get the fullscreen state
|
boolean |
isGammaCorrection()
Test whether gamma correction should be enabled.
|
boolean |
isGraphicsDebug()
Determine if the renderer will be run in Graphics Debug mode, which means every openGL call is checked and
if it returns an error code, throw a
RendererException .Without this, many openGL calls might fail without notice, so turning it on is recommended for development. |
boolean |
isGraphicsTiming()
Determine if the renderer will be run in Graphics Timing mode, which means every openGL call is checked and
if it runs for longer than a millisecond, log it.
It also keeps track of the time spent in GL Calls in general and displays them when GL.resetStats() is called. |
boolean |
isGraphicsTrace()
Determine if the renderer will be run in Graphics Trace mode, which means every openGL call is logged so one
can trace what openGL commands where executed in which order by the engine.
|
boolean |
isOpenCLSupport() |
boolean |
isResizable()
Determine if the display window can be resized by dragging its edges.
|
boolean |
isSwapBuffers()
Determine if the display context will swap buffers every frame.
|
boolean |
isVSync()
Test whether vertical synchronization should be enabled.
|
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 |
setAlphaBits(int value)
Android Only
Sets the number of alpha bits to use.
|
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 |
setEmulateKeyboard(boolean emulateKeyboard)
Enable or disable keyboard emulation on touchscreen based devices.
|
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 |
setGammaCorrection(boolean gammaCorrection)
Enable or disable gamma correction.
|
void |
setGraphicsDebug(boolean debug)
Set whether the renderer will be run in Graphics Debug mode, which means every openGL call is checked and
if it returns an error code, throw a
RendererException .Without this, many openGL calls might fail without notice, so turning it on is recommended for development. |
void |
setGraphicsTiming(boolean timing)
Set whether the renderer will be run in Graphics Timing mode, which means every openGL call is checked and
if it runs for longer than a millisecond, log it.
It also keeps track of the time spent in GL Calls in general and displays them when GL.resetStats() is called. |
void |
setGraphicsTrace(boolean trace)
Set whether the renderer will be run in Graphics Trace mode, which means every openGL call is logged so one
can trace what openGL commands where executed in which order by the engine.
|
void |
setHeight(int value) |
void |
setIcons(java.lang.Object[] value)
Sets the application icons to be used, with the most preferred first.
|
void |
setMinHeight(int value) |
void |
setMinResolution(int width,
int height)
Set the minimum resolution the settings window will allow for the rendering display
|
void |
setMinWidth(int value) |
void |
setOpenCLPlatformChooser(java.lang.Class<? extends PlatformChooser> chooser)
Sets a custom platform chooser.
|
void |
setOpenCLSupport(boolean support)
True to enable the creation of an OpenCL context.
|
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 AppSettings.JOGL_OPENGL_BACKWARD_COMPATIBLE AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE null - Disable graphics rendering |
void |
setResizable(boolean resizable)
Allows the display window to be resized by dragging its edges.
|
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 |
setSwapBuffers(boolean swapBuffers)
When enabled the display context will swap buffers every frame.
|
void |
setTitle(java.lang.String title) |
void |
setUseInput(boolean use) |
void |
setUseJoysticks(boolean use) |
void |
setVSync(boolean value)
Enable or disable vertical synchronization.
|
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
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public static final java.lang.String LWJGL_OPENGL2
If the underlying system does not support OpenGL2.0, then the context initialization will throw an exception.
@Deprecated public static final java.lang.String LWJGL_OPENGL3
If the underlying system does not support OpenGL3.2, then the context initialization will throw an exception. Note that currently jMonkeyEngine does not have any shaders that support OpenGL3.2 therefore this option is not useful.
Note: OpenGL 3.2 is used to give 3.x support to Mac users.
public static final java.lang.String LWJGL_OPENGL30
If the underlying system does not support OpenGL3.0, then the context initialization will throw an exception. Note that currently jMonkeyEngine does not have any shaders that support OpenGL3.0 therefore this option is not useful.
public static final java.lang.String LWJGL_OPENGL31
If the underlying system does not support OpenGL3.1, then the context initialization will throw an exception. Note that currently jMonkeyEngine does not have any shaders that support OpenGL3.0 therefore this option is not useful.
public static final java.lang.String LWJGL_OPENGL32
If the underlying system does not support OpenGL3.2, then the context initialization will throw an exception. Note that currently jMonkeyEngine does not have any shaders that support OpenGL3.2 therefore this option is not useful.
Note: OpenGL 3.2 is used to give 3.x support to Mac users.
public static final java.lang.String LWJGL_OPENGL33
If the underlying system does not support OpenGL3.3, then the context initialization will throw an exception.
@Deprecated public static final java.lang.String LWJGL_OPENGL4
If the underlying system does not support OpenGL4.0, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENGL40
If the underlying system does not support OpenGL4.0, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENGL41
If the underlying system does not support OpenGL4.1, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENGL42
If the underlying system does not support OpenGL4.2, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENGL43
If the underlying system does not support OpenGL4.3, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENGL44
If the underlying system does not support OpenGL4.4, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENGL45
If the underlying system does not support OpenGL4.5, then the context initialization will throw an exception.
public static final java.lang.String LWJGL_OPENAL
@Deprecated public static final java.lang.String ANDROID_MEDIAPLAYER
ANDROID_OPENAL_SOFT
instead.NOTE: Supports Android 2.2+ platforms.
public static final java.lang.String ANDROID_OPENAL_SOFT
This is the current default for Android platforms. NOTE: Only to be used on Android 2.3+ platforms due to using OpenSL.
public static final java.lang.String JOGL_OPENGL_FORWARD_COMPATIBLE
N.B: This backend is EXPERIMENTAL
public static final java.lang.String JOGL_OPENGL_BACKWARD_COMPATIBLE
N.B: This backend is EXPERIMENTAL
public static final java.lang.String JOAL
N.B: This backend is EXPERIMENTAL
public AppSettings(boolean loadDefaults)
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.
loadDefaults
- If default settings are to be loaded.public void copyFrom(AppSettings other)
other
to this
AppSettings.
Any settings that are specified in other will overwrite settings set on this AppSettings.
other
- The AppSettings to copy the settings frompublic void mergeFrom(AppSettings other)
copyFrom(com.jme3.system.AppSettings)
, except
doesn't overwrite settings that are already set.other
- The AppSettings to merge the settings frompublic void load(java.io.InputStream in) throws java.io.IOException
in
- The InputStream to load fromjava.io.IOException
- If an IOException occurssave(java.io.OutputStream)
public void save(java.io.OutputStream out) throws java.io.IOException
out
- The OutputStream to write tojava.io.IOException
- If an IOException occursload(java.io.InputStream)
public void load(java.lang.String preferencesKey) throws java.util.prefs.BackingStoreException
preferencesKey
- The preferencesKey previously used to save the settings.java.util.prefs.BackingStoreException
- If an exception occurs with the preferencessave(java.lang.String)
public void save(java.lang.String preferencesKey) throws java.util.prefs.BackingStoreException
On the Windows operating system, the preferences are saved in the registry
at the following key:
HKEY_CURRENT_USER\Software\JavaSoft\Prefs\[preferencesKey]
preferencesKey
- The preferences key to save at. Generally the
application's unique name.java.util.prefs.BackingStoreException
- If an exception occurs with the preferencespublic int getInteger(java.lang.String key)
If the key is not set, then 0 is returned.
key
- the key of an integer settingpublic boolean getBoolean(java.lang.String key)
If the key is not set, then false is returned.
key
- the key of a boolean settingpublic java.lang.String getString(java.lang.String key)
If the key is not set, then null is returned.
key
- the key of a string settingpublic float getFloat(java.lang.String key)
If the key is not set, then 0.0 is returned.
key
- the key of a float settingpublic void putInteger(java.lang.String key, int value)
key
- the desired keyvalue
- the desired integer valuepublic void putBoolean(java.lang.String key, boolean value)
key
- the desired keyvalue
- the desired boolean valuepublic void putString(java.lang.String key, java.lang.String value)
key
- the desired keyvalue
- the desired string valuepublic void putFloat(java.lang.String key, float value)
key
- the desired keyvalue
- the desired float valuepublic void setEmulateMouse(boolean emulateMouse)
emulateMouse
- If mouse emulation should be enabled.public boolean isEmulateMouse()
public void setEmulateMouseFlipAxis(boolean flipX, boolean flipY)
flipX
- Set to flip X axisflipY
- Set to flip Y axissetEmulateMouse(boolean)
public boolean isEmulateMouseFlipX()
public boolean isEmulateMouseFlipY()
public void setEmulateKeyboard(boolean emulateKeyboard)
emulateKeyboard
- If soft keyboard emulation should be enabled.public boolean isEmulateKeyboard()
public void setFrameRate(int frameRate)
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)public void setUseInput(boolean use)
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)public void setUseJoysticks(boolean use)
use
- If true, the application will initialize and use joystick
input. Set to false if no joystick input is desired.
(Default: false)public void setRenderer(java.lang.String renderer)
renderer
- The renderer to set
(Default: AppSettings.LWJGL_OPENGL2)public void setCustomRenderer(java.lang.Class<? extends JmeContext> clazz)
JmeContext
interface.clazz
- The custom context class.
(Default: not set)public void setAudioRenderer(java.lang.String audioRenderer)
audioRenderer
- (Default: LWJGL)public void setWidth(int value)
value
- the width for the rendering display.
(Default: 640)public void setHeight(int value)
value
- the height for the rendering display.
(Default: 480)public void setResolution(int width, int height)
width
- The widthheight
- The height
(Default: 640x480)public void setMinWidth(int value)
value
- the minimum width the settings window will allow for the rendering display.
(Default: 0)public void setMinHeight(int value)
value
- the minimum height the settings window will allow for the rendering display.
(Default: 0)public void setMinResolution(int width, int height)
width
- The minimum widthheight
- The minimum height
(Default: 0x0)public void setFrequency(int value)
value
- The frequency
(Default: 60)public void setDepthBits(int value)
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)
value
- The depth bitspublic void setAlphaBits(int value)
The number of alpha bits specifies the precision of the surface view background alpha value. To set the surface view to opaque (fastest setting), leave the number of alpha bits = 0. This will cause faster rendering, but android views located behind the surface view will not be viewable. To set the surface view to translucent, set the number of alphaBits to 8 or higher. Values less than 8 (except 0) will set the surface view pixel format to transparent.
(Default: 0)
value
- The alpha bitspublic void setStencilBits(int value)
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)value
- Number of stencil bitspublic void setBitsPerPixel(int value)
value
- The bits per pixel to set
(Default: 24)public void setSamples(int value)
value
- The number of samples
(Default: 1)public void setTitle(java.lang.String title)
title
- The title of the rendering display
(Default: jMonkeyEngine 3.0)public void setFullscreen(boolean value)
value
- true to enable full-screen rendering, false to render in a window
(Default: false)public void setVSync(boolean value)
value
- true to enable, false to disable (Default : true)public void setStereo3D(boolean value)
This feature requires hardware support from the GPU driver.
See 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.
value
- true to enable 3-D stereo, false to disable (default=false)public void setIcons(java.lang.Object[] value)
value
- An array of BufferedImages to use as icons.
(Default: not set)public void setSettingsDialogImage(java.lang.String path)
The image will be displayed in the settings dialog when the application is started.
(Default: /com/jme3/app/Monkey.png)path
- The path to the image in the classpath.public void setGammaCorrection(boolean gammaCorrection)
gammaCorrection
- true to enable, false to disable (Default : true)public int getFrameRate()
setFrameRate(int)
public boolean useInput()
setUseInput(boolean)
public java.lang.String getRenderer()
setRenderer(java.lang.String)
public int getWidth()
setWidth(int)
public int getHeight()
setHeight(int)
public int getMinWidth()
setWidth(int)
public int getMinHeight()
setHeight(int)
public int getBitsPerPixel()
setBitsPerPixel(int)
public int getFrequency()
setFrequency(int)
public int getDepthBits()
setDepthBits(int)
public int getAlphaBits()
setAlphaBits(int)
public int getStencilBits()
setStencilBits(int)
public int getSamples()
setSamples(int)
public java.lang.String getTitle()
setTitle(java.lang.String)
public boolean isVSync()
setVSync(boolean)
public boolean isFullscreen()
setFullscreen(boolean)
public boolean useJoysticks()
setUseJoysticks(boolean)
public java.lang.String getAudioRenderer()
setAudioRenderer(java.lang.String)
public boolean useStereo3D()
setStereo3D(boolean)
public java.lang.Object[] getIcons()
setIcons(java.lang.Object[])
public java.lang.String getSettingsDialogImage()
setSettingsDialogImage(java.lang.String)
public boolean isGammaCorrection()
public void setResizable(boolean resizable)
JmeContext.Type.Display
contexts which
are in windowed mode, ignored for other types.
The default value is false
.resizable
- True to make a resizable window, false to make a fixed
size window.public boolean isResizable()
setResizable(boolean)
public void setSwapBuffers(boolean swapBuffers)
setFrameRate(int)
.
The default is true
.swapBuffers
- True to enable buffer swapping, false to disable it.public boolean isSwapBuffers()
setSwapBuffers(boolean)
public void setOpenCLSupport(boolean support)
support
- whether to create the context or notpublic boolean isOpenCLSupport()
public void setOpenCLPlatformChooser(java.lang.Class<? extends PlatformChooser> chooser)
chooser
- the class of the chooser, must have a default constructorpublic java.lang.String getOpenCLPlatformChooser()
public boolean isGraphicsDebug()
RendererException
.setGraphicsDebug(boolean)
public void setGraphicsDebug(boolean debug)
RendererException
.debug
- whether the context will be run in Graphics Debug Mode or notisGraphicsDebug()
public boolean isGraphicsTiming()
GL.resetStats()
is called.setGraphicsTiming(boolean)
,
GLTiming
public void setGraphicsTiming(boolean timing)
GL.resetStats()
is called.timing
- whether the context will be run in Graphics Timing Mode or notisGraphicsTiming()
,
GLTiming
public boolean isGraphicsTrace()
setGraphicsTrace(boolean)
,
GLTracer
public void setGraphicsTrace(boolean trace)
trace
- whether the context will be run in Graphics Trace Mode or notisGraphicsTrace()
,
GLTracer