Class TextBasedEntity<T extends TextureBasedEntity<?>>

Type Parameters:
T - a subclass inheriting TextureBasedEntity, used in order to return this as a T instead of a TextBasedEntity.
Direct Known Subclasses:
BitmapText, Text

public abstract class TextBasedEntity<T extends TextureBasedEntity<?>> extends TextureBasedEntity<T>
Generic type for entities containing text.
  • Field Details

    • text

      protected String text
    • fontSize

      protected int fontSize
    • maxWidth

      protected int maxWidth
    • textAlign

      protected TextBasedEntity.TextAlign textAlign
  • Constructor Details

    • TextBasedEntity

      public TextBasedEntity()
  • Method Details

    • getText

      public String getText()
      Returns the string this TextBasedEntity displays.

      Default is "" (empty string).

      Returns:
      the string of this TextBasedEntity.
    • setText

      public T setText(String text)
      Sets the string for this TextBasedEntity to display.

      Default is "" (empty string).

      Parameters:
      text - the string for this TextBasedEntity to display.
      Returns:
      this Text.
      Throws:
      NullPointerException - if text is null.
    • getTextAlign

      public TextBasedEntity.TextAlign getTextAlign()
      Returns text alignment of this TextBasedEntity.

      Default is TextAlign.LEFT (align left).

      Returns:
      the text alignment of this TextBasedEntity.
    • setTextAlign

      public T setTextAlign(TextBasedEntity.TextAlign align)
      Sets the text alignment of this TextBasedEntity.

      Default is TextAlign.LEFT (align left).

      Parameters:
      align - the text alignment of this TextBasedEntity.
      Returns:
      this Text.
      Throws:
      NullPointerException - if align is null.
    • getFontSize

      public int getFontSize()
      Returns the size of the font of this TextBasedEntity in px.

      Default is 26.

      Returns:
      the size of the font of this TextBasedEntity.
    • setFontSize

      public T setFontSize(int fontSize)
      Sets the size of the font of this TextBasedEntity in px.

      Default is 26.

      Parameters:
      fontSize - the size for the font of this TextBasedEntity.
      Returns:
      this Text.
    • setFontSize

      public T setFontSize(int fontSize, Curve curve)
      Sets the size of the font of this TextBasedEntity in px.

      Default is 26.

      Parameters:
      fontSize - the size for the font of this TextBasedEntity.
      curve - the transition to animate between values of this property.
      Returns:
      this Text.
    • getMaxWidth

      public int getMaxWidth()
      Returns the maximum width of this TextBasedEntity in pixels, before it gets ellipsed.

      The ellipsis is applied before the entity is scaled. A max width of 0 means there is no maximum width.

      Default is 0 (no max width).

      Returns:
      the maximum width in pixels of this TextBasedEntity.
    • setMaxWidth

      public T setMaxWidth(int maxWidth)
      Sets the maximum width of this TextBasedEntity in pixels before it gets ellipsed.

      The ellipsis is applied before the entity is scaled. A max width of 0 means there is no maximum width.

      Default is 0 (no max width).

      Parameters:
      maxWidth - the maximum width in pixels of this TextBasedEntity.
      Returns:
      this Text.