Class SimpleTextElement

java.lang.Object
edu.tufts.hrilab.ava.display.SimpleTextElement

public class SimpleTextElement extends Object
Class responsible for managing the display of text on the canvas.
  • Constructor Details

    • SimpleTextElement

      public SimpleTextElement(Font font, Color fg, Color fgRobot)
      Constructor for TextManager.
      Parameters:
      font - The font to be used for text rendering.
      fg - The color to be used for human text.
      fgRobot - The color to be used for robot text.
  • Method Details

    • setText

      public void setText(String text, long textTimeout, Runnable runnable)
      Sets the text to be displayed and specifies if it is robot text.
      Parameters:
      text - The text to be displayed
    • getText

      public String getText()
      Gets the currently displayed text
    • clearText

      public void clearText()
      Clears the text from the display.
    • paint

      public Rectangle paint(Graphics2D g, int screenPad)
      Paints the current text onto the provided Graphics2D context.
      Parameters:
      g - The Graphics2D context to paint on.
      screenPad - The padding around the text.
    • paintText

      public Rectangle paintText(Graphics2D g, String text, Color color, SimpleTextElement.TextAlignment alignment, SimpleTextElement.TextWrapping wrapping, int baselineHeight, int screenPad)
      Painting text with a certain alignment and baseline level and the screen padding with specific wrapping desired
      Parameters:
      g - The graphics object to paint onto
      text - The text to be painted
      color - The color of the text to be painted
      alignment - The alignment on the screen to paint the text (LEFT, RIGHT, CENTER)
      baselineHeight - The height of the baseline of the text
      screenPad - The padding for the text against the screen
      Returns:
      The footprint of the string
    • paintDialogue

      public Rectangle paintDialogue(Graphics2D g, List<DialogueMessage> messages, int baseLine, int screenPad, boolean isCentered)
      Method for displaying dialogue correctly
      Parameters:
      g - The graphics object to paint onto
      messages - The list of messages that needs to be painted
      screenPad - The padding of the text against the screen
      isCentered - If the text should be centered in the screen
      Returns:
      The footprint of the object