Package doodlepad

Class Text


public class Text extends Shape
A class that implements a graphical object made up of text. Starts filled with black and no stroke.
  • Constructor Details

    • Text

      public Text(String text, double x, double y, int size, int style, String fontName, Layer layer)
      Text object constructor
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The Font size used to draw the Text object.
      style - The Font class constant that defines the style used to draw the Text object. Example: Font.PLAIN
      fontName - The name of the font used to draw the Text object, Example: "Arial"
      layer - The Layer object to which the Text should be added, or null if not to add to a Pad.
    • Text

      public Text(String text, double x, double y, int size, int style, String fontName)
      Text object constructor
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
      style - The Font class constant that defines the style used to draw the Text object. Example: Font.PLAIN
      fontName - The name of the font used to draw the Text object, Example: "Arial"
    • Text

      public Text(String text, double x, double y, int size, int style, String fontName, Pad pad)
      Text object constructor
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
      style - The Font class constant that defines the style used to draw the Text object. Example: Font.PLAIN
      fontName - The name of the font used to draw the Text object, Example: "Arial"
      pad - The Pad to which the Text object should be added.
    • Text

      public Text(String text, double x, double y, int size, int style)
      Text object constructor. Create a Text object with an Arial font.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
      style - The Font class constant that defines the style used to draw the Text object. Example: Font.PLAIN
    • Text

      public Text(String text, double x, double y, int size, String fontName)
      Text object constructor. Create a Text object with an Arial font.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
      fontName - The name of the font used to draw the Text object, Example: "Arial"
    • Text

      public Text(String text, double x, double y, int size)
      Text object constructor. Create a Text object with style Font.PLAIN and an Arial font.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
    • Text

      public Text(String text, double x, double y, int size, Pad pad)
      Text object constructor. Create a Text object with style Font.PLAIN and an Arial font.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
      pad - The Pad to which the Text object should be added.
    • Text

      public Text(String text, double x, double y, int size, Layer layer)
      Text object constructor. Create a Text object with style Font.PLAIN and an Arial font.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      size - The font size used to draw the Text object.
      layer - The Layer object to which the Text should be added, or null if not to add to a Pad.
    • Text

      public Text(String text, double x, double y, Pad pad)
      Text object constructor. Create a Text object with the default system font attributes.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      pad - The Pad to which the Text object should be added.
    • Text

      public Text(String text, double x, double y)
      Text object constructor. Create a Text object with the default font attributes.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
    • Text

      public Text(String text, double x, double y, Layer layer)
      Text object constructor. Create a Text object with the default system font attributes.
      Parameters:
      text - The String drawn as the Text object
      x - The x-coordinate of the Text object upper left corner.
      y - The y-coordinate of the Text object upper left corner.
      layer - The Layer object to which the Text should be added, or null if not to add to a Pad.
    • Text

      public Text()
      Text object constructor. Creates a randomly positioned Text object.
  • Method Details

    • toString

      public String toString()
      Generate a representation of the Text object.
      Overrides:
      toString in class Shape
      Returns:
      String representation
    • setText

      public void setText(String text)
      Set the internal text
      Overrides:
      setText in class Shape
      Parameters:
      text - The internal text as a String
    • getText

      public String getText()
      Return the Text object String
      Overrides:
      getText in class Shape
      Returns:
      The text of the object as a String
    • setFontFamily

      public void setFontFamily(String fontFamily)
      Update the Font family for this Text object.
      Overrides:
      setFontFamily in class Shape
      Parameters:
      fontFamily - The Font family name (ex. "Arial")
    • getFontFamily

      public String getFontFamily()
      Return the Font family name for this Text object.
      Overrides:
      getFontFamily in class Shape
      Returns:
      The Font family name String
    • setFontStyle

      public void setFontStyle(int fontStyle)
      Update the Font style for this Text object.
      Overrides:
      setFontStyle in class Shape
      Parameters:
      fontStyle - The font style code (ex. 0 (Font.PLAIN), 1 (Font.BOLD), 2 (Font.ITALIC))
    • getFontStyle

      public int getFontStyle()
      Return the Font style code for this Text object.
      Overrides:
      getFontStyle in class Shape
      Returns:
      The Font style code
    • setFontSize

      public void setFontSize(int fontSize)
      Update the Font size for this Text object.
      Overrides:
      setFontSize in class Shape
      Parameters:
      fontSize - The font size (ex. 10)
    • getFontSize

      public int getFontSize()
      Return the font size for this Text object.
      Overrides:
      getFontSize in class Shape
      Returns:
      the font size.
    • draw

      public void draw(Graphics2D g)
      Draw the Text object
      Specified by:
      draw in class Shape
      Parameters:
      g - The Graphics2D object on which to draw the text object