Class TextItem

java.lang.Object
ch.epfl.cs107.play.window.swing.TextItem
All Implemented Interfaces:
Item, Comparable<Item>

public final class TextItem extends Object implements Item
Draw a single string.
  • Constructor Details

    • TextItem

      public TextItem(String text, float fontSize, Transform transform, Color fillColor, Color outlineColor, float thickness, String fontName, boolean bold, boolean italics, Vector anchor, TextAlign.Horizontal hAlign, TextAlign.Vertical vAlign, float depth, float alpha)
      Creates a new text graphics.
      Parameters:
      text - (String): content, not null
      fontSize - (float): size
      transform - (Transform): affine transform, not null
      fillColor - (Color): fill color, may be null
      outlineColor - (Color): outline color, may be null
      thickness - (float): outline thickness
      bold - (boolean): whether to use bold font
      italics - (boolean): whether to use italics font
      anchor - (Vector): text anchor
      hAlign - (TextAlign.Horizontal): the horizontal alignment
      vAlign - (TextAlign.Vertical): the vertical alignment
      depth - (float): render priority, lower-values drawn first
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
  • Method Details

    • getDepth

      public float getDepth()
      Specified by:
      getDepth in interface Item
      Returns:
      render priority, lower-values drawn first
    • render

      public void render(Graphics2D g)
      Description copied from interface: Item
      Renders the item.
      Specified by:
      render in interface Item
      Parameters:
      g - target context, not null