com.jme.system
Class PreferencesGameSettings

java.lang.Object
  extended by com.jme.system.AbstractGameSettings
      extended by com.jme.system.PreferencesGameSettings
All Implemented Interfaces:
GameSettings

public class PreferencesGameSettings
extends AbstractGameSettings

PreferencesGameSettings uses the Preferences system in Java and implements the GameSettings interface.

Author:
Matthew D. Hicks
See Also:
GameSettings

Field Summary
 
Fields inherited from class com.jme.system.AbstractGameSettings
defaultAlphaBits, defaultDepth, defaultDepthBits, defaultFramerate, defaultFrequency, defaultFullscreen, defaultHeight, defaultMusic, defaultRenderer, defaultSamples, defaultSettingsWidgetImage, defaultSFX, defaultStencilBits, defaultVerticalSync, defaultWidth, isNew
 
Fields inherited from interface com.jme.system.GameSettings
DEFAULT_ALPHA_BITS, DEFAULT_DEPTH, DEFAULT_DEPTH_BITS, DEFAULT_FRAMERATE, DEFAULT_FREQUENCY, DEFAULT_FULLSCREEN, DEFAULT_HEIGHT, DEFAULT_MUSIC, DEFAULT_RENDERER, DEFAULT_SAMPLES, DEFAULT_SFX, DEFAULT_STENCIL_BITS, DEFAULT_VERTICAL_SYNC, DEFAULT_WIDTH
 
Constructor Summary
PreferencesGameSettings(java.util.prefs.Preferences preferences)
          Warning: Only the caller knows whether the passed 'preferences' object is new.
PreferencesGameSettings(java.util.prefs.Preferences preferences, boolean isNew)
          Legacy constructor wrapper.
PreferencesGameSettings(java.util.prefs.Preferences preferences, boolean isNew, java.lang.String dfltsFilename)
          Use this constructor to set the defaults for your game according to a file like "gamename.properties" in the root of a CLASSPATH element (like in the root of a jar file).
 
Method Summary
 void clear()
          Clears all settings.
 java.lang.String get(java.lang.String name, java.lang.String defaultValue)
           
 int getAlphaBits()
          Returns the alpha bits to use for the renderer as stored or the default.
 boolean getBoolean(java.lang.String name, boolean defaultValue)
           
 byte[] getByteArray(java.lang.String name, byte[] defaultValue)
           
 int getDepth()
          Returns the depth for the screen as stored or the default.
 int getDepthBits()
          Returns the depth bits to use for the renderer as stored or the default.
 double getDouble(java.lang.String name, double defaultValue)
           
 float getFloat(java.lang.String name, float defaultValue)
           
 int getFramerate()
          Returns the specified framerate or -1 if variable framerate is specified.
 int getFrequency()
          Returns the screen refresh frequency as stored or the default.
 int getHeight()
          Returns the height for the screen as stored or the default.
 int getInt(java.lang.String name, int defaultValue)
           
 long getLong(java.lang.String name, long defaultValue)
           
 java.lang.Object getObject(java.lang.String name, java.lang.Object defaultValue)
           
 java.lang.String getRenderer()
          Returns the stored rendering API name, or the default
 int getSamples()
          Returns the number of samples to use for the multisample buffer as stored or the default.
 int getStencilBits()
          Returns the stencil bits to use for the renderer as stored or the default.
 int getWidth()
          Returns the width for the screen as stored or the default.
 boolean isFullscreen()
          Returns the screen's fullscreen status as stored or the default.
 boolean isMusic()
          Returns the enabled status of music as stored or the default.
 boolean isSFX()
          Returns the enabled status of sound effects as stored or the default.
 boolean isVerticalSync()
          Returns the current state of vertical synchronization.
 void remove(java.lang.String name)
           
 void save()
          This method forces the Preferences node to (re)persist now.
 void set(java.lang.String name, java.lang.String value)
           
 void setAlphaBits(int alphaBits)
          Sets the alpha bits for use with the renderer.
 void setBoolean(java.lang.String name, boolean value)
           
 void setByteArray(java.lang.String name, byte[] value)
           
 void setDepth(int depth)
          Sets the depth for the screen.
 void setDepthBits(int depthBits)
          Sets the depth bits for use with the renderer.
 void setDouble(java.lang.String name, double value)
           
 void setFloat(java.lang.String name, float value)
           
 void setFramerate(int framerate)
          Sets the framerate.
 void setFrequency(int frequency)
          Sets the screen refresh frequency.
 void setFullscreen(boolean fullscreen)
          Sets the fullscreen status for the screen.
 void setHeight(int height)
          Sets the height for the screen.
 void setInt(java.lang.String name, int value)
           
 void setLong(java.lang.String name, long value)
           
 void setMusic(boolean musicEnabled)
          Sets the enabled status of music.
 void setObject(java.lang.String name, java.lang.Object value)
           
 void setRenderer(java.lang.String renderer)
          Sets the rendering API.
 void setSamples(int samples)
          Sets the number of samples to use for the multisample buffer.
 void setSFX(boolean sfxEnabled)
          Sets the enabled status of sound effects.
 void setStencilBits(int stencilBits)
          Sets the stencil bits for use with the renderer.
 void setVerticalSync(boolean vsync)
          Sets the state of vertical synchronization.
 void setWidth(int width)
          Sets the width for the screen.
 
Methods inherited from class com.jme.system.AbstractGameSettings
assignDefaults, getDefaultSettingsWidgetImage, isNew, loadBoolean, loadInteger, normalizeName, setIsNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferencesGameSettings

public PreferencesGameSettings(java.util.prefs.Preferences preferences)
Warning: Only the caller knows whether the passed 'preferences' object is new. Therefore, you must call the setIsNew method when using this constructor. It will otherwise be assumed true.

See Also:
AbstractGameSettings.setIsNew(boolean), PreferencesGameSettings(Preferences, boolean, String)

PreferencesGameSettings

public PreferencesGameSettings(java.util.prefs.Preferences preferences,
                               boolean isNew)
Legacy constructor wrapper.

See Also:
PreferencesGameSettings(Preferences, boolean, String)

PreferencesGameSettings

public PreferencesGameSettings(java.util.prefs.Preferences preferences,
                               boolean isNew,
                               java.lang.String dfltsFilename)
Use this constructor to set the defaults for your game according to a file like "gamename.properties" in the root of a CLASSPATH element (like in the root of a jar file).

Parameters:
dfltsFilename - the properties file to use, read from CLASSPATH. Null to not seek any runtime defaults file.
Method Detail

getRenderer

public java.lang.String getRenderer()
Description copied from interface: GameSettings
Returns the stored rendering API name, or the default

Returns:
String

setRenderer

public void setRenderer(java.lang.String renderer)
Description copied from interface: GameSettings
Sets the rendering API.


getWidth

public int getWidth()
Description copied from interface: GameSettings
Returns the width for the screen as stored or the default.

Returns:
int

setWidth

public void setWidth(int width)
Description copied from interface: GameSettings
Sets the width for the screen.


getHeight

public int getHeight()
Description copied from interface: GameSettings
Returns the height for the screen as stored or the default.

Returns:
int

setHeight

public void setHeight(int height)
Description copied from interface: GameSettings
Sets the height for the screen.


getDepth

public int getDepth()
Description copied from interface: GameSettings
Returns the depth for the screen as stored or the default.

Returns:
int

setDepth

public void setDepth(int depth)
Description copied from interface: GameSettings
Sets the depth for the screen.


getFrequency

public int getFrequency()
Description copied from interface: GameSettings
Returns the screen refresh frequency as stored or the default.

Returns:
int

setFrequency

public void setFrequency(int frequency)
Description copied from interface: GameSettings
Sets the screen refresh frequency.


isVerticalSync

public boolean isVerticalSync()
Description copied from interface: GameSettings
Returns the current state of vertical synchronization. This synchronizes the game update frequency to the monitor update frequency. This can help provide a much smoother game experience and help with screen tearing.

Returns:
boolean

setVerticalSync

public void setVerticalSync(boolean vsync)
Description copied from interface: GameSettings
Sets the state of vertical synchronization. This synchronizes the game update frequency to the monitor update frequency. This can help provide a much smoother game experience and help with screen tearing.


isFullscreen

public boolean isFullscreen()
Description copied from interface: GameSettings
Returns the screen's fullscreen status as stored or the default.

Returns:
boolean

setFullscreen

public void setFullscreen(boolean fullscreen)
Description copied from interface: GameSettings
Sets the fullscreen status for the screen.


getDepthBits

public int getDepthBits()
Description copied from interface: GameSettings
Returns the depth bits to use for the renderer as stored or the default.

Returns:
int

setDepthBits

public void setDepthBits(int depthBits)
Description copied from interface: GameSettings
Sets the depth bits for use with the renderer.


getAlphaBits

public int getAlphaBits()
Description copied from interface: GameSettings
Returns the alpha bits to use for the renderer as stored or the default.

Returns:
int

setAlphaBits

public void setAlphaBits(int alphaBits)
Description copied from interface: GameSettings
Sets the alpha bits for use with the renderer.


getStencilBits

public int getStencilBits()
Description copied from interface: GameSettings
Returns the stencil bits to use for the renderer as stored or the default.

Returns:
int

setStencilBits

public void setStencilBits(int stencilBits)
Description copied from interface: GameSettings
Sets the stencil bits for use with the renderer.


getSamples

public int getSamples()
Description copied from interface: GameSettings
Returns the number of samples to use for the multisample buffer as stored or the default.

Returns:
int

setSamples

public void setSamples(int samples)
Description copied from interface: GameSettings
Sets the number of samples to use for the multisample buffer.


isMusic

public boolean isMusic()
Description copied from interface: GameSettings
Returns the enabled status of music as stored or the default.

Returns:
boolean

setMusic

public void setMusic(boolean musicEnabled)
Description copied from interface: GameSettings
Sets the enabled status of music.


isSFX

public boolean isSFX()
Description copied from interface: GameSettings
Returns the enabled status of sound effects as stored or the default.

Returns:
boolean

setSFX

public void setSFX(boolean sfxEnabled)
Description copied from interface: GameSettings
Sets the enabled status of sound effects.


getFramerate

public int getFramerate()
Description copied from interface: GameSettings
Returns the specified framerate or -1 if variable framerate is specified.

Returns:
int

setFramerate

public void setFramerate(int framerate)
Description copied from interface: GameSettings
Sets the framerate. Use -1 to specify variable framerate.


clear

public void clear()
           throws java.io.IOException
Description copied from interface: GameSettings
Clears all settings.

This removes all settings. As a result, get*() will return the default value, but this is very different from setting default values. If all settings are removed, users will automatically receive updated system or game default settings. If a user were to set (then save) default values, they would always retrieve those values regardless to any changes to defaults.

clear() followed by save() will persist an indication that there are no values saved.

Throws:
java.io.IOException - If there is some consistency or access problem obtaining the values to be cleared.
See Also:
GameSettings.clear()

get

public java.lang.String get(java.lang.String name,
                            java.lang.String defaultValue)

getBoolean

public boolean getBoolean(java.lang.String name,
                          boolean defaultValue)

getDouble

public double getDouble(java.lang.String name,
                        double defaultValue)

getFloat

public float getFloat(java.lang.String name,
                      float defaultValue)

getInt

public int getInt(java.lang.String name,
                  int defaultValue)

getLong

public long getLong(java.lang.String name,
                    long defaultValue)

getByteArray

public byte[] getByteArray(java.lang.String name,
                           byte[] defaultValue)

getObject

public java.lang.Object getObject(java.lang.String name,
                                  java.lang.Object defaultValue)

set

public void set(java.lang.String name,
                java.lang.String value)

setBoolean

public void setBoolean(java.lang.String name,
                       boolean value)

setDouble

public void setDouble(java.lang.String name,
                      double value)

setFloat

public void setFloat(java.lang.String name,
                     float value)

setInt

public void setInt(java.lang.String name,
                   int value)

setLong

public void setLong(java.lang.String name,
                    long value)

setByteArray

public void setByteArray(java.lang.String name,
                         byte[] value)

setObject

public void setObject(java.lang.String name,
                      java.lang.Object value)

remove

public void remove(java.lang.String name)

save

public void save()
          throws java.io.IOException
This method forces the Preferences node to (re)persist now. java.util.prefs.Preferences automatically persists all value changes when it thinks they need to be persisted.

Throws:
java.io.IOException
See Also:
Preferences