Class RenderableString


  • public class RenderableString
    extends Object
    Represents graphical information related to the drawing of a string with a font.

    Drawing a renderable string is faster than drawing a regular string. This optimization is done by caching the index within the font of every character of the string as soon as the renderable string is created. However a RenderableString consumes significant heap memory.

    • Constructor Detail

      • RenderableString

        public RenderableString​(String string,
                                Font font)
        Creates a renderable string.
        Parameters:
        string - the string to draw.
        font - the font to use in order to draw the string.
    • Method Detail

      • getString

        public String getString()
        Returns the string associated with this renderable string.
        Returns:
        the string associated with this renderable string.
      • getFont

        public Font getFont()
        Returns the font associated with this renderable string.
        Returns:
        the font associated with this renderable string.
      • getWidth

        public int getWidth()
        Returns the width of the graphical bounds of this renderable string.

        This method has the same specifications as Font.stringWidth(String).

        Returns:
        the width taken by this renderable string, in pixels.
      • getHeight

        public int getHeight()
        Returns the height of the graphical bounds of this renderable string.

        This method has the same specifications as Font.getHeight().

        Returns:
        the height taken by this renderable string, in pixels.