Package ecs

Class Text


public class Text extends Object
Author:
Asher Haun Represents a renderable string containing a TTF font reference, color data, and font size.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Text(String string, float x, float y)
     
    Text(String string, Font font, Color color, float x, float y)
     
    Text(String string, Font font, Color color, float x, float y, int zIndex, boolean isSticky, boolean isCentered)
     
    Text(String string, Color color, float x, float y)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addX(float x)
    Add to the existing X position incrementally each time this method is called.
    void
    addY(float y)
    Add to the existing Y position incrementally each time this method is called.
    void
    change(String string)
    This method is called when the user wants to modify the string in the Text object.
     
    float
     
    float
     
    boolean
     
    void
    Applies a rainbow effect to the Text, gradually changing the color of each Glyph in a rainbow.
    void
    setCentered(boolean centered)
    Allows the user to change the text alignment after creation.
    void
    setColor(Color color)
    Set the color of the entire Text object.
    void
    setPosition(org.joml.Vector2f position)
    Allows the user to change the position of the Text object.
    void
    setX(float x)
     
    void
    setY(float y)
     
    void
    Update method called for every text object by the scene.Scene.updateUI() method.
    int
     

    Methods inherited from class java.lang.Object

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

    • Text

      public Text(String string, Font font, Color color, float x, float y, int zIndex, boolean isSticky, boolean isCentered)
      Parameters:
      string - the text to be rendered.
      font - the Font object that contains your preferred .ttf font file.
      color - the Color object that contains your prefered RGBA color.
      x - the X position of the Text object.
      y - the Y position of the Text object.
      zIndex - the Z-Index of the Text Object (currently can only be set on creation, this will change in the future).
      isSticky - boolean determining whether the text sticks in one position regardless of the camera position (isSticky = true) or if it will move in world space.
      isCentered - boolean determining whether the text is left aligned or center aligned. This can be changed after creation using .setCentered().
    • Text

      public Text(String string, Font font, Color color, float x, float y)
      Parameters:
      string - the text to be rendered.
      font - the Font object that contains your preferred .ttf font file.
      color - the Color object that contains your prefered RGBA color.
      x - the X position of the Text object.
      y - the Y position of the Text object.
    • Text

      public Text(String string, Color color, float x, float y)
      Parameters:
      string - the text to be rendered.
      color - the Color object that contains your prefered RGBA color.
      x - the X position of the Text object.
      y - the Y position of the Text object.
    • Text

      public Text(String string, float x, float y)
      Parameters:
      string - the text to be rendered.
      x - the X position of the Text object.
      y - the Y position of the Text object.
  • Method Details

    • update

      public void update()
      Update method called for every text object by the scene.Scene.updateUI() method. This should not be called by general users.
    • change

      public void change(String string)
      This method is called when the user wants to modify the string in the Text object. This can be called anytime after object creation.
      Parameters:
      string - the text to change the current string to.
    • getGlyphRenderers

      public ArrayList<GlyphRenderer> getGlyphRenderers()
    • setColor

      public void setColor(Color color)
      Set the color of the entire Text object.
      Parameters:
      color - RGBA Color object.
    • rainbowify

      public void rainbowify()
      Applies a rainbow effect to the Text, gradually changing the color of each Glyph in a rainbow.
    • isCentered

      public boolean isCentered()
      Returns:
      boolean value of isCentered.
    • setCentered

      public void setCentered(boolean centered)
      Allows the user to change the text alignment after creation.
      Parameters:
      centered - boolean isCentered.
    • zIndex

      public int zIndex()
    • getX

      public float getX()
    • getY

      public float getY()
    • setX

      public void setX(float x)
    • setY

      public void setY(float y)
    • setPosition

      public void setPosition(org.joml.Vector2f position)
      Allows the user to change the position of the Text object.
      Parameters:
      position - Vector2f containing new position data.
    • addY

      public void addY(float y)
      Add to the existing Y position incrementally each time this method is called.
      Parameters:
      y - amount to increment Y position by.
    • addX

      public void addX(float x)
      Add to the existing X position incrementally each time this method is called.
      Parameters:
      x - amount to increment X position by.