Package jme3utilities.ui
Class DisplaySettings
java.lang.Object
jme3utilities.ui.DisplaySettings
Manage an application's render settings.
-
Constructor Summary
ConstructorDescriptionDisplaySettings
(com.jme3.app.Application app, String appName, jme3utilities.math.RectSizeLimits sizeLimits) Instantiate settings for the specified Application. -
Method Summary
Modifier and TypeMethodDescriptionReturn the name of the application whose settings are being edited.protected void
applyOverrides
(com.jme3.system.AppSettings settings) Apply overrides to the specified settings.void
Apply the proposed settings to the graphics context and restart the context to put them into effect.boolean
Test whether the proposed settings have been applied since their last applicable modification.boolean
areSaved()
Test whether the proposed settings have been saved (written to persistent storage) since their last modification.boolean
areValid()
Test the validity of the proposed settings prior to a save.boolean
canApply()
Test whether the proposed settings can be applied immediately.int
Determine the color depth.Explain why these settings cannot be applied.Explain why the proposed settings are invalid.protected com.jme3.app.Application
Access the application.jme3utilities.math.RectSizeLimits
Access the max/min framebuffer size.Return the name of the graphics API.int
height()
Determine the display height.com.jme3.system.AppSettings
Initialize the settings before the application starts.boolean
Test whether center-on-start is enabled for LWJGL v3 windowed mode.boolean
Test whether full-screen mode is enabled.boolean
Test whether gamma correction is enabled.boolean
Test whether graphics debugging is enabled.boolean
Test whether graphics tracing is enabled.boolean
isVSync()
Test whether VSync is enabled.static String[]
Enumerate all known graphics APIs.boolean
load()
Attempt to load settings from user preferences (persistent storage).void
Reset the proposed settings to the application's default values.int
Determine the sampling factor for multi-sample anti-aliasing (MSAA).int
Determine the display's refresh rate, which is relevant only to full-screen displays.void
resize
(int newWidth, int newHeight) Update the dimensions of a resizable viewport, assuming the change has already been applied.boolean
save()
Write the proposed settings to persistent storage, so that they will take effect the next time the application is launched.void
scaleSize
(float widthFactor, float heightFactor) Scale the height and width of the display by the specified factors and clamp to the size limits.void
setCentered
(boolean newSetting) Alter whether center-on-start is enabled for LWJGL v3 windowed mode.void
setColorDepth
(int newDepth) Alter the color depth.void
setDimensions
(int newWidth, int newHeight) Alter the display dimensions.void
setFullscreen
(boolean newSetting) Enable or disable full-screen mode.void
setGammaCorrection
(boolean newSetting) Enable or disable gamma-correction mode.void
setGraphicsApi
(String apiName) Alter the graphics API.void
setGraphicsDebug
(boolean newSetting) Alter the graphics-debug flag.void
setGraphicsTrace
(boolean newSetting) Alter the graphics-trace flag.void
Maximize the display dimensions.void
Minimize the display dimensions.void
setMsaaFactor
(int newFactor) Alter the sampling factor for multi-sample anti-aliasing (MSAA).void
setRefreshRate
(int newRate) Alter the refresh rate.void
setShowDialog
(ShowDialog newSetting) Alter how often the JME settings dialog should be shown during initialize().void
setStartLocation
(int newX, int newY) Alter the initial location for LWJGL v3 windowed mode with setCentered(false).void
setVSync
(boolean newSetting) Enable or disable VSync mode.Determine how often the JME settings dialog should be shown during initialize().int
startX()
Return the initial X location for LWJGL v3 windowed mode with setCentered(false).int
startY()
Return the initial Y location for LWJGL v3 windowed mode with setCentered(false).int
width()
Determine the display width.
-
Constructor Details
-
DisplaySettings
public DisplaySettings(com.jme3.app.Application app, String appName, jme3utilities.math.RectSizeLimits sizeLimits) Instantiate settings for the specified Application.- Parameters:
app
- the current application instance (not null, alias created)appName
- the name of the application (not null)sizeLimits
- the desired framebuffer-size limits (not null, alias created)
-
-
Method Details
-
applicationName
Return the name of the application whose settings are being edited.- Returns:
- the name (not null)
-
applyToContext
public void applyToContext()Apply the proposed settings to the graphics context and restart the context to put them into effect. -
areApplied
public boolean areApplied()Test whether the proposed settings have been applied since their last applicable modification.- Returns:
- true if clean, otherwise false
-
areSaved
public boolean areSaved()Test whether the proposed settings have been saved (written to persistent storage) since their last modification.- Returns:
- true if clean, otherwise false
-
areValid
public boolean areValid()Test the validity of the proposed settings prior to a save.- Returns:
- true if good enough, otherwise false
-
canApply
public boolean canApply()Test whether the proposed settings can be applied immediately.- Returns:
- true if they can be applied, otherwise false
-
colorDepth
public int colorDepth()Determine the color depth.- Returns:
- depth (in bits per pixel) or ≤0 for unknown/don't care
-
feedbackApplicable
Explain why these settings cannot be applied.- Returns:
- message text (not null)
-
feedbackValid
Explain why the proposed settings are invalid.- Returns:
- message text (not null, not empty) or "" if settings are valid
-
getSizeLimits
public jme3utilities.math.RectSizeLimits getSizeLimits()Access the max/min framebuffer size.- Returns:
- the pre-existing instance (not null)
-
graphicsApi
Return the name of the graphics API.- Returns:
- a name found in
listGraphicsApis()
(not null, not empty)
-
height
public int height()Determine the display height.- Returns:
- height (in pixels, >0)
-
initialize
public com.jme3.system.AppSettings initialize()Initialize the settings before the application starts.- Returns:
- a new AppSettings instance, or null if user clicked on the "Cancel" button
-
isCentered
public boolean isCentered()Test whether center-on-start is enabled for LWJGL v3 windowed mode.- Returns:
- true if centering, otherwise false
-
isFullscreen
public boolean isFullscreen()Test whether full-screen mode is enabled.- Returns:
- true if full-screen, otherwise false
-
isGammaCorrection
public boolean isGammaCorrection()Test whether gamma correction is enabled.- Returns:
- true if enabled, otherwise false
-
isGraphicsDebug
public boolean isGraphicsDebug()Test whether graphics debugging is enabled.- Returns:
- true if enabled, otherwise false
-
isGraphicsTrace
public boolean isGraphicsTrace()Test whether graphics tracing is enabled.- Returns:
- true if enabled, otherwise false
-
isVSync
public boolean isVSync()Test whether VSync is enabled.- Returns:
- true if enabled, otherwise false
-
listGraphicsApis
Enumerate all known graphics APIs.- Returns:
- a new array (not null)
-
load
public boolean load()Attempt to load settings from user preferences (persistent storage). If successful, this reverts all properties to their last saved values.- Returns:
- true if successful, otherwise false
-
loadDefaults
public void loadDefaults()Reset the proposed settings to the application's default values. -
msaaFactor
public int msaaFactor()Determine the sampling factor for multi-sample anti-aliasing (MSAA).- Returns:
- sampling factor (in samples per pixel, ≥0)
-
refreshRate
public int refreshRate()Determine the display's refresh rate, which is relevant only to full-screen displays.- Returns:
- frequency (in Hertz) or ≤0 for unknown/don't care
-
resize
public void resize(int newWidth, int newHeight) Update the dimensions of a resizable viewport, assuming the change has already been applied.- Parameters:
newWidth
- (in pixels, >0)newHeight
- (in pixels, >0)- See Also:
-
save
public boolean save()Write the proposed settings to persistent storage, so that they will take effect the next time the application is launched.- Returns:
- true if successful, otherwise false
-
scaleSize
public void scaleSize(float widthFactor, float heightFactor) Scale the height and width of the display by the specified factors and clamp to the size limits.- Parameters:
widthFactor
- scaling factor for the display width (>0)heightFactor
- scaling factor for the display height (>0)
-
setCentered
public void setCentered(boolean newSetting) Alter whether center-on-start is enabled for LWJGL v3 windowed mode.- Parameters:
newSetting
- true for centering, false to specify screen coordinates
-
setColorDepth
public void setColorDepth(int newDepth) Alter the color depth.- Parameters:
newDepth
- the desired color depth (in bits per pixel) or ≤0 for unknown/don't care
-
setDimensions
public void setDimensions(int newWidth, int newHeight) Alter the display dimensions.- Parameters:
newWidth
- width (in pixels, ≥minWidth, ≤maxWidth)newHeight
- height (in pixels, ≥minHeight, ≤maxHeight)
-
setFullscreen
public void setFullscreen(boolean newSetting) Enable or disable full-screen mode.- Parameters:
newSetting
- true→full screen, false→ windowed
-
setGammaCorrection
public void setGammaCorrection(boolean newSetting) Enable or disable gamma-correction mode.- Parameters:
newSetting
- true→enable correction, false→ disable it
-
setGraphicsApi
Alter the graphics API.- Parameters:
apiName
- a name found inlistGraphicsApis()
(not null, not empty, found inapiNameMap
)
-
setGraphicsDebug
public void setGraphicsDebug(boolean newSetting) Alter the graphics-debug flag.- Parameters:
newSetting
- true to enable debugging, false to disable it
-
setGraphicsTrace
public void setGraphicsTrace(boolean newSetting) Alter the graphics-trace flag.- Parameters:
newSetting
- true to enable tracing, false to disable it
-
setMaxSize
public void setMaxSize()Maximize the display dimensions. -
setMinSize
public void setMinSize()Minimize the display dimensions. -
setMsaaFactor
public void setMsaaFactor(int newFactor) Alter the sampling factor for multi-sample anti-aliasing (MSAA).- Parameters:
newFactor
- number of samples per pixel (≥1)
-
setRefreshRate
public void setRefreshRate(int newRate) Alter the refresh rate.- Parameters:
newRate
- frequency (in Hertz) or ≤0 for unknown/don't care
-
setShowDialog
Alter how often the JME settings dialog should be shown during initialize().- Parameters:
newSetting
- the desired option (not null)
-
setStartLocation
public void setStartLocation(int newX, int newY) Alter the initial location for LWJGL v3 windowed mode with setCentered(false).- Parameters:
newX
- screen X coordinate for the left edge of the content areanewY
- screen Y coordinate for the top edge of the content area
-
setVSync
public void setVSync(boolean newSetting) Enable or disable VSync mode.- Parameters:
newSetting
- true→synchronize, false→ don't synchronize
-
showDialog
Determine how often the JME settings dialog should be shown during initialize().- Returns:
- an enum value
-
startX
public int startX()Return the initial X location for LWJGL v3 windowed mode with setCentered(false).- Returns:
- the screen X coordinate for the left edge of the content area
-
startY
public int startY()Return the initial Y location for LWJGL v3 windowed mode with setCentered(false).- Returns:
- the screen Y coordinate for the left edge of the content area
-
width
public int width()Determine the display width.- Returns:
- width (in pixels, >0)
-
applyOverrides
protected void applyOverrides(com.jme3.system.AppSettings settings) Apply overrides to the specified settings.This implementation is meant to be overridden by an application-specific version.
- Parameters:
settings
- which settings to modify (not null)
-
getApplication
protected com.jme3.app.Application getApplication()Access the application.- Returns:
- the pre-existing instance (not null)
-