Class AbstractTextElement

  • All Implemented Interfaces:
    be.yildizgames.common.util.Registerable, Element

    public abstract class AbstractTextElement
    extends BaseElement
    Base element to print text.
    Author:
    Grégory Van Den Borre
    • Constructor Detail

      • AbstractTextElement

        protected AbstractTextElement​(be.yildizgames.module.coordinate.BaseCoordinate coordinates,
                                      Font textFont)
        Full constructor.
        Parameters:
        coordinates - Text position and size.
        textFont - Font to use to print the text.
    • Method Detail

      • getTextWidth

        public final int getTextWidth()
        Compute the width in pixel of the printed text.
        Returns:
        Current text width in pixel.
      • getLastLineWidth

        public final float getLastLineWidth()
        Compute the last text width, if the text is multi line.
        Returns:
        Current text last line width in pixel.
      • removeFromRegisterer

        protected final void removeFromRegisterer()
        Remove the element from registered elements.
      • getTextHeight

        public final int getTextHeight()
        Returns:
        Current text height in pixel.
      • getText

        public final String getText()
        Returns:
        The text.
      • setText

        public final boolean setText​(String newText)
        Overload the setText method to avoid the toString call.
        Parameters:
        newText - New text to print.
        Returns:
        true if the text was updated.
      • getFontHeight

        public final int getFontHeight()
        Returns:
        The font height.
      • getFont

        public final Font getFont()
        Returns:
        The text font.
      • setFont

        public final void setFont​(Font newFont)
        Parameters:
        newFont - New font.
      • setTextImpl

        protected abstract void setTextImpl​(String newText)
        Internal method, do not use externally. Update the text in graphic engine implementation.
        Parameters:
        newText - New text to print.
      • setFontImpl

        protected abstract void setFontImpl​(Font newFont)
        Internal method, do not use externally. Update the font in graphic engine implementation.
        Parameters:
        newFont - New font to use.
      • setColor

        public abstract void setColor​(be.yildizgames.module.color.Color color)
        Set the text color.
        Parameters:
        color - Color to set to this text.