Package edu.tufts.hrilab.ava.display
Class SimpleTextElement
java.lang.Object
edu.tufts.hrilab.ava.display.SimpleTextElement
Class responsible for managing the display of text on the canvas.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Constructor Summary
ConstructorsConstructorDescriptionSimpleTextElement(Font font, Color fg, Color fgRobot) Constructor for TextManager. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the text from the display.getText()Gets the currently displayed textpaint(Graphics2D g, int screenPad) Paints the current text onto the provided Graphics2D context.paintDialogue(Graphics2D g, List<DialogueMessage> messages, int baseLine, int screenPad, boolean isCentered) Method for displaying dialogue correctlypaintText(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 desiredvoidSets the text to be displayed and specifies if it is robot text.
-
Constructor Details
-
SimpleTextElement
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
Sets the text to be displayed and specifies if it is robot text.- Parameters:
text- The text to be displayed
-
getText
Gets the currently displayed text -
clearText
public void clearText()Clears the text from the display. -
paint
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 ontotext- The text to be paintedcolor- The color of the text to be paintedalignment- The alignment on the screen to paint the text (LEFT, RIGHT, CENTER)baselineHeight- The height of the baseline of the textscreenPad- 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 ontomessages- The list of messages that needs to be paintedscreenPad- The padding of the text against the screenisCentered- If the text should be centered in the screen- Returns:
- The footprint of the object
-