Package jme3utilities.ui
Class Overlay
java.lang.Object
com.jme3.app.state.BaseAppState
jme3utilities.ui.Overlay
- All Implemented Interfaces:
com.jme3.app.state.AppState
- Direct Known Subclasses:
DsEditOverlay
public class Overlay
extends com.jme3.app.state.BaseAppState
An AppState for displaying "content" (lines of text) against a rectangular
background with rounded corners.
By default, an Overlay is located in the upper-left corner of the display and the text is white and left-aligned on a black background.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.jme3.font.BitmapFont.Alignalignment(int lineIndex) Return the horizontal alignment of the indexed content line.protected voidcleanup(com.jme3.app.Application application) Transition this AppState from terminating to detached.floatReturn the Z offset of the content lines relative to the background.com.jme3.math.ColorRGBAcopyBackgroundColor(com.jme3.math.ColorRGBA storeResult) Copy the color of the background.com.jme3.math.Vector3fcopyLocation(com.jme3.math.Vector3f storeResult) Copy the location of upper-left corner of the background.intDetermine the number of the content lines.Return the location policy.floatheight()Return height of the background.protected voidinitialize(com.jme3.app.Application application) Initialize this AppState prior to its first update.floatReturn the vertical interval between successive content lines.voidonColorSpaceChange(com.jme3.texture.image.ColorSpace newColorSpace) Update colors after the renderer's ColorSpace changes.protected voidTransition this AppState from enabled to disabled.protected voidonEnable()Transition this AppState from disabled to enabled.voidonViewPortResize(int newViewPortWidth, int newViewPortHeight) Relocate this overlay for the specified viewport dimensions.floatpadding()Return the amount of padding between the content lines and top/bottom/left/right edges of the background.voidsetAlignment(int lineIndex, com.jme3.font.BitmapFont.Align alignment) Alter the horizontal alignment of the indexed content line.voidsetAlignmentAll(com.jme3.font.BitmapFont.Align alignment) Alter the horizontal alignment of all content.voidsetBackgroundColor(com.jme3.math.ColorRGBA newColor) Alter the color of the background.voidsetBackgroundZ(float newZ) Alter the Z coordinate for the background.voidsetColor(int lineIndex, com.jme3.math.ColorRGBA color) Alter the color of the indexed content line.voidsetContentZOffset(float newOffset) Alter the Z offset of content relative to the background.voidsetLineSpacing(float newSpacing) Alter the vertical interval between successive content lines.voidsetLocation(com.jme3.math.Vector3f newLocation) Move to the specified location.voidsetLocationPolicy(LocationPolicy newPolicy) Alter the location policy.voidsetPadding(float newPadding) Alter the padding between the content lines and the edges of the background.voidAlter the text of the indexed content line.voidAlter the indexed content line.voidsetWidth(float newWidth) Alter the width of the background.voidsetXMargin(float newMargin) Alter the horizontal margin between the background and the edges of the viewport.voidsetYMargin(float newMargin) Alter the vertical margin between the background and the edges of the viewport.floatwidth()Return width of the background.floatxMargin()Return the horizontal margin between the background and the edges of the viewport.floatyMargin()Return the vertical margin between the background and the edges of the viewport.Methods inherited from class com.jme3.app.state.BaseAppState
cleanup, getApplication, getId, getState, getState, getState, getState, getStateManager, initialize, isEnabled, isInitialized, postRender, render, setEnabled, setId, stateAttached, stateDetached, update
-
Constructor Details
-
Overlay
Instantiate an uninitialized AppState.- Parameters:
id- the desired AppState ID (not null, unique within the current application)width- the desired width of the background in framebuffer pixels (>0)numLines- the desired number of content lines (>0)
-
-
Method Details
-
alignment
public com.jme3.font.BitmapFont.Align alignment(int lineIndex) Return the horizontal alignment of the indexed content line.- Parameters:
lineIndex- which content line to access (≥0, <numLines)- Returns:
- the enum value (not null)
-
contentZOffset
public float contentZOffset()Return the Z offset of the content lines relative to the background.- Returns:
- the offset (>0)
-
copyBackgroundColor
public com.jme3.math.ColorRGBA copyBackgroundColor(com.jme3.math.ColorRGBA storeResult) Copy the color of the background.- Parameters:
storeResult- storage for the result (modified if not null)- Returns:
- the gamma-encoded color (either
storeResultor a new instance)
-
copyLocation
public com.jme3.math.Vector3f copyLocation(com.jme3.math.Vector3f storeResult) Copy the location of upper-left corner of the background.- Parameters:
storeResult- storage for the result (modified if not null)- Returns:
- the location vector (either
storeResultor a new instance)
-
countLines
public int countLines()Determine the number of the content lines.- Returns:
- the count (>0)
-
getLocationPolicy
Return the location policy.- Returns:
- the enum value (not null)
-
height
public float height()Return height of the background.- Returns:
- the height (including padding, in framebuffer pixels, >0)
-
lineSpacing
public float lineSpacing()Return the vertical interval between successive content lines.- Returns:
- the Y interval (in framebuffer pixels, >0)
-
onColorSpaceChange
public void onColorSpaceChange(com.jme3.texture.image.ColorSpace newColorSpace) Update colors after the renderer's ColorSpace changes.- Parameters:
newColorSpace- the new ColorSpace (not null)
-
onViewPortResize
public void onViewPortResize(int newViewPortWidth, int newViewPortHeight) Relocate this overlay for the specified viewport dimensions.- Parameters:
newViewPortWidth- the new viewport width (in framebuffer pixels, >0)newViewPortHeight- the new viewport height (in framebuffer pixels, >0)
-
padding
public float padding()Return the amount of padding between the content lines and top/bottom/left/right edges of the background.- Returns:
- the padding (in framebuffer pixels, ≥0)
-
setAlignment
public void setAlignment(int lineIndex, com.jme3.font.BitmapFont.Align alignment) Alter the horizontal alignment of the indexed content line.- Parameters:
lineIndex- which line to modify (≥0, <numLines)alignment- the desired alignment (not null, default=Left)
-
setAlignmentAll
public void setAlignmentAll(com.jme3.font.BitmapFont.Align alignment) Alter the horizontal alignment of all content.- Parameters:
alignment- the desired alignment (not null, default=Left)
-
setBackgroundColor
public void setBackgroundColor(com.jme3.math.ColorRGBA newColor) Alter the color of the background.- Parameters:
newColor- the desired color (not null, unaffected, gamma-encoded, default=opaque black)
-
setBackgroundZ
public void setBackgroundZ(float newZ) Alter the Z coordinate for the background.- Parameters:
newZ- the desired Z coordinate (default=-2)
-
setColor
public void setColor(int lineIndex, com.jme3.math.ColorRGBA color) Alter the color of the indexed content line.- Parameters:
lineIndex- which line to modify (≥0, <countLines)color- the desired foreground color (not null, unaffected, gamma-encoded, default=White)
-
setContentZOffset
public void setContentZOffset(float newOffset) Alter the Z offset of content relative to the background.- Parameters:
newOffset- the desired offset (>0, default=0.1)
-
setLineSpacing
public void setLineSpacing(float newSpacing) Alter the vertical interval between successive content lines.- Parameters:
newSpacing- the desired Y offset (in framebuffer pixels, >0, default=20)
-
setLocation
public void setLocation(com.jme3.math.Vector3f newLocation) Move to the specified location.- Parameters:
newLocation- the desired framebuffer coordinates for the upper-left corner of the background (not null, unaffected)
-
setLocationPolicy
Alter the location policy.- Parameters:
newPolicy- the desired policy (not null, default=UpperLeft)
-
setPadding
public void setPadding(float newPadding) Alter the padding between the content lines and the edges of the background.- Parameters:
newPadding- the desired padding (in framebuffer pixels, ≥0, default=5)
-
setText
Alter the text of the indexed content line.- Parameters:
lineIndex- which line to modify (≥0, <countLines)text- the desired text (not null)
-
setText
Alter the indexed content line.- Parameters:
lineIndex- which line to modify (≥0, <numLines)text- the desired text (not null)color- the desired foreground color (not null, unaffected, gamma-encoded)
-
setWidth
public void setWidth(float newWidth) Alter the width of the background.- Parameters:
newWidth- the desired width (in framebuffer pixels, >0)
-
setXMargin
public void setXMargin(float newMargin) Alter the horizontal margin between the background and the edges of the viewport. (Ignored if the location policy is Center.)- Parameters:
newMargin- the desired margin (in framebuffer pixels, ≥0, default=5)
-
setYMargin
public void setYMargin(float newMargin) Alter the vertical margin between the background and the edges of the viewport. (Ignored if the location policy is Center.)- Parameters:
newMargin- the desired margin (in framebuffer pixels, ≥0, default=5)
-
width
public float width()Return width of the background.- Returns:
- the width (including padding, in framebuffer pixels, >0)
-
xMargin
public float xMargin()Return the horizontal margin between the background and the edges of the viewport.- Returns:
- the margin (in framebuffer pixels, ≥0)
-
yMargin
public float yMargin()Return the vertical margin between the background and the edges of the viewport.- Returns:
- the margin (in framebuffer pixels, ≥0)
-
cleanup
protected void cleanup(com.jme3.app.Application application) Transition this AppState from terminating to detached. Should be invoked only by a subclass or by the AppStateManager.Invoked once for each time
initialize(com.jme3.app.Application)is invoked.- Specified by:
cleanupin classcom.jme3.app.state.BaseAppState- Parameters:
application- the application which owns this AppState (not null)
-
initialize
protected void initialize(com.jme3.app.Application application) Initialize this AppState prior to its first update. Should be invoked only by a subclass or by the AppStateManager.- Specified by:
initializein classcom.jme3.app.state.BaseAppState- Parameters:
application- the application which owns this AppState (not null)
-
onDisable
protected void onDisable()Transition this AppState from enabled to disabled.- Specified by:
onDisablein classcom.jme3.app.state.BaseAppState
-
onEnable
protected void onEnable()Transition this AppState from disabled to enabled.- Specified by:
onEnablein classcom.jme3.app.state.BaseAppState
-