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
    Constructor
    Description
    Overlay(String id, float width, int numLines)
    Instantiate an uninitialized AppState.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.jme3.font.BitmapFont.Align
    alignment(int lineIndex)
    Return the horizontal alignment of the indexed content line.
    protected void
    cleanup(com.jme3.app.Application application)
    Transition this AppState from terminating to detached.
    float
    Return the Z offset of the content lines relative to the background.
    com.jme3.math.ColorRGBA
    copyBackgroundColor(com.jme3.math.ColorRGBA storeResult)
    Copy the color of the background.
    com.jme3.math.Vector3f
    copyLocation(com.jme3.math.Vector3f storeResult)
    Copy the location of upper-left corner of the background.
    int
    Determine the number of the content lines.
    Return the location policy.
    float
    Return height of the background.
    protected void
    initialize(com.jme3.app.Application application)
    Initialize this AppState prior to its first update.
    float
    Return the vertical interval between successive content lines.
    void
    onColorSpaceChange(com.jme3.texture.image.ColorSpace newColorSpace)
    Update colors after the renderer's ColorSpace changes.
    protected void
    Transition this AppState from enabled to disabled.
    protected void
    Transition this AppState from disabled to enabled.
    void
    onViewPortResize(int newViewPortWidth, int newViewPortHeight)
    Relocate this overlay for the specified viewport dimensions.
    float
    Return the amount of padding between the content lines and top/bottom/left/right edges of the background.
    void
    setAlignment(int lineIndex, com.jme3.font.BitmapFont.Align alignment)
    Alter the horizontal alignment of the indexed content line.
    void
    setAlignmentAll(com.jme3.font.BitmapFont.Align alignment)
    Alter the horizontal alignment of all content.
    void
    setBackgroundColor(com.jme3.math.ColorRGBA newColor)
    Alter the color of the background.
    void
    setBackgroundZ(float newZ)
    Alter the Z coordinate for the background.
    void
    setColor(int lineIndex, com.jme3.math.ColorRGBA color)
    Alter the color of the indexed content line.
    void
    setContentZOffset(float newOffset)
    Alter the Z offset of content relative to the background.
    void
    setLineSpacing(float newSpacing)
    Alter the vertical interval between successive content lines.
    void
    setLocation(com.jme3.math.Vector3f newLocation)
    Move to the specified location.
    void
    Alter the location policy.
    void
    setPadding(float newPadding)
    Alter the padding between the content lines and the edges of the background.
    void
    setText(int lineIndex, String text)
    Alter the text of the indexed content line.
    void
    setText(int lineIndex, String text, com.jme3.math.ColorRGBA color)
    Alter the indexed content line.
    void
    setWidth(float newWidth)
    Alter the width of the background.
    void
    setXMargin(float newMargin)
    Alter the horizontal margin between the background and the edges of the viewport.
    void
    setYMargin(float newMargin)
    Alter the vertical margin between the background and the edges of the viewport.
    float
    Return width of the background.
    float
    Return the horizontal margin between the background and the edges of the viewport.
    float
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Overlay

      public Overlay(String id, float width, int numLines)
      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 storeResult or 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 storeResult or a new instance)
    • countLines

      public int countLines()
      Determine the number of the content lines.
      Returns:
      the count (>0)
    • getLocationPolicy

      public LocationPolicy 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

      public void setLocationPolicy(LocationPolicy newPolicy)
      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

      public void setText(int lineIndex, String text)
      Alter the text of the indexed content line.
      Parameters:
      lineIndex - which line to modify (≥0, <countLines)
      text - the desired text (not null)
    • setText

      public void setText(int lineIndex, String text, com.jme3.math.ColorRGBA color)
      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:
      cleanup in class com.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:
      initialize in class com.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:
      onDisable in class com.jme3.app.state.BaseAppState
    • onEnable

      protected void onEnable()
      Transition this AppState from disabled to enabled.
      Specified by:
      onEnable in class com.jme3.app.state.BaseAppState