Class GString

java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.GString
All Implemented Interfaces:
Cloneable

public class GString extends GraphicE
This class wraps a String in a GraphicE
Author:
Federico Vera <[email protected]>
  • Constructor Details

    • GString

      public GString(GString e)
      Copy constructor
      Parameters:
      e - GString to copy
      Throws:
      IllegalArgumentException - if e is null
    • GString

      public GString(int x, int y, String str)
      GString constructor
      Parameters:
      x - X coordinate of the lower left corner of the String
      y - Y coordinate of the lower left corner of the String
      str - String to show
    • GString

      public GString(int x, int y, String str, Font font)
      GString constructor
      Parameters:
      x - X coordinate of the lower left corner of the String
      y - Y coordinate of the lower left corner of the String
      str - String to show
      font - Font
    • GString

      public GString(int x, int y, double a, String str)
      GString constructor
      Parameters:
      x - X coordinate of the lower left corner of the String
      y - Y coordinate of the lower left corner of the String
      a - The angle in degrees of the String
      str - String to show
    • GString

      public GString(int x, int y, double a, String str, Font font)
      Complete GString constructor
      Parameters:
      x - X coordinate of the lower left corner of the String
      y - Y coordinate of the lower left corner of the String
      a - The angle in degrees of the String
      str - String to show
      font - Font
  • Method Details

    • setString

      public void setString(String string) throws IllegalArgumentException
      Set's the String to print in the screen
      Parameters:
      string - String to be printed
      Throws:
      IllegalArgumentException - if string is null
    • getString

      public String getString()
      Retrieves the String
      Returns:
      string
    • setFont

      public void setFont(Font font) throws IllegalArgumentException
      Set's the font used to render this String
      Parameters:
      font - font
      Throws:
      IllegalArgumentException - if font is null
    • getFont

      public Font getFont()
      Retrieves the font used to print this String
      Returns:
      font
    • setAngle

      public void setAngle(double angle)
      Set's the angle of the String
      Parameters:
      angle - angle in degrees
    • getAngle

      public double getAngle()
      Retrieves the angle in degrees of the String
      Returns:
      angle
    • draw

      public void draw(Graphics2D g)
      Description copied from class: GraphicE
      Draws the component on the given graphics
      Specified by:
      draw in class GraphicE
      Parameters:
      g - where to draw
    • getFontMetrics

      public FontMetrics getFontMetrics(Graphics2D g)
      Retrieves the FontMetrics associated with this GString for a given Graphics2D.
      Parameters:
      g - The Graphics2D that will be used to render this GString
      Returns:
      FontMetrics object.
    • traslate

      public void traslate(int x, int y)
      Description copied from class: GraphicE
      Traslates this element on X and Y
      Specified by:
      traslate in class GraphicE
      Parameters:
      x - size in px of the horizontal translation
      y - size in px of the vertical translation
    • move

      public void move(int x, int y)
      Moves this element to the given coordinates
      Parameters:
      x - new x coordinate
      y - new y coordinate
    • clone

      public GString clone()
      Specified by:
      clone in class GraphicE
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class GraphicE
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class GraphicE
    • getX

      public int getX()
      Retrieves the x coordinate of the string
      Returns:
      x coordinate
    • getY

      public int getY()
      Retrieves the y coordinate of the string
      Returns:
      y coordinate