Package view

Class TextView

All Implemented Interfaces:
Configuration

public class TextView extends EntityView
The text view class provides a view for the TextEntity class. If presents a text message, rendered in a specific font, using a specific color. The default font is "Courier New", in bold with a point size of 12 pixels. The default color is white.
Author:
Krish Pillai
See Also:
  • Constructor Details

    • TextView

      public TextView(String message, Font font, Color color)
      Constructor creates a text view with the specified font and color. The width and height are computed based on the font selected.
      Parameters:
      message - The text message
      font - The font type specifying name, style, and point size.
      color - The color of the font
      See Also:
      • DEFAULT_FONT
      • DEFAULT_COLOR
    • TextView

      public TextView(String message, Color color)
      Constructor using default font with the specified color
      Parameters:
      message - the displayed text
      color - font color
    • TextView

      public TextView(String message)
      Constructor using default setting
      Parameters:
      message - The text to be rendered
  • Method Details

    • getFont

      public Font getFont()
      Returns the font in use
      Returns:
      f The font used to render text
    • getColor

      public Color getColor()
      Returns the color for this rendering
      Returns:
      color The color setting
    • getBounds

      public Dimension getBounds()
      Returns the dimensions for the rendered text for the font and point size.
      Returns:
      dim The dimension defining the width and height of the rendered text
    • modifyMessage

      public void modifyMessage(String message)
      Changes the current text to the specified message. The width, the height, and the appearance of the text is modified as needed.
      Parameters:
      message - The new message
    • iterator

      public ViewIterator iterator()
    • getWidth

      public int getWidth()
      Description copied from class: EntityView
      The width of the scaled visual representation for this entity.
      Specified by:
      getWidth in class EntityView
      Returns:
      width
    • getHeight

      public int getHeight()
      Description copied from class: EntityView
      The height of the scaled visual representation for this entity.
      Specified by:
      getHeight in class EntityView
      Returns:
      height