Class BMTextBackground

All Implemented Interfaces:
Pickable, Hintable, Renderable, BMTextChangeListener, Savable

public class BMTextBackground extends Mesh implements BMTextChangeListener
A 9-slice capable background, suitable for sitting behind BMText to increase readability.
  • Constructor Details

  • Method Details

    • setBackgroundColor

      public void setBackgroundColor(ReadOnlyColorRGBA color)
    • setBorderScale

      public void setBorderScale(float scale)
      Sets the scale of the 9 slice border texture. By default this is set to 1 meaning we attempt to make it pixel perfect. If the source texture is too large or small, leading to an undesired border size, changing this value will adjust the border without scaling other transform values.
      Parameters:
      scale - the scale
    • getBorderScale

      public float getBorderScale()
    • setTexBorderOffsets

      public void setTexBorderOffsets(ReadOnlyVector4 offsets)
      Splits up the texture drawn on this background into a grid. x,y,z, and w of the given vector are interpreted as the u/v coordinate offset from the left, top, right and bottom edges of the texture respectively. This forms a 9 slice/patch grid. The edges of the grid are stretched along their given axis to fit. The corners are presented without stretching their natural ratio. The center patch is stretched to fit on both axis. The default value is (.25, .25, .25, .25) which reserves a 25% border around the center content.
      Parameters:
      offsets - the offsets
    • setTexBorderOffsets

      public void setTexBorderOffsets(float offset)
      Set the amount of texture uv space to reserve for the border for all sides to the same value.
      Parameters:
      offset - the offset
    • setTexBorderOffsets

      public void setTexBorderOffsets(float x, float y, float z, float w)
    • getTexBorderOffsets

      public ReadOnlyVector4 getTexBorderOffsets()
    • setContentPadding

      public void setContentPadding(ReadOnlyVector4 padding)
      Set internal padding between text and border.
      Parameters:
      padding - the padding
    • setContentPadding

      public void setContentPadding(float padding)
      Set internal padding between text and border.
      Parameters:
      padding - the padding
    • setContentPadding

      public void setContentPadding(float x, float y, float z, float w)
      Set internal padding between text and border.
      Parameters:
      x - the x value
      y - the y value
      z - the z value
      w - the w value
    • getContentPadding

      public ReadOnlyVector4 getContentPadding()
    • draw

      public void draw(Renderer r)
      Description copied from class: Spatial
      draw abstract method that handles drawing data to the renderer if it is geometry and passing the call to it's children if it is a node.
      Overrides:
      draw in class Mesh
      Parameters:
      r - the renderer used for display.
    • textSizeChanged

      public void textSizeChanged(BMText text, ReadOnlyVector2 size)
      Specified by:
      textSizeChanged in interface BMTextChangeListener
    • textAlphaChanged

      public void textAlphaChanged(BMText text, float alpha)
      Specified by:
      textAlphaChanged in interface BMTextChangeListener
    • getClassTag

      public Class<? extends BMTextBackground> getClassTag()
      Specified by:
      getClassTag in interface Savable
      Overrides:
      getClassTag in class Mesh
      See Also:
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class Mesh
      Parameters:
      capsule - the capsule
      Throws:
      IOException - Signals that an I/O exception has occurred.
      See Also:
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class Mesh
      Parameters:
      capsule - the input capsule
      Throws:
      IOException - Signals that an I/O exception has occurred.
      See Also: