Class GString

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class GString
    extends GraphicE
    This class wraps a String in a GraphicE
    • Field Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      GString​(int x, int y, double a, java.lang.String str)
      GString constructor
      GString​(int x, int y, double a, java.lang.String str, java.awt.Font font)
      Complete GString constructor
      GString​(int x, int y, java.lang.String str)
      GString constructor
      GString​(int x, int y, java.lang.String str, java.awt.Font font)
      GString constructor
      GString​(GString e)
      Copy constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      GString clone()  
      void draw​(java.awt.Graphics2D g)
      Draws the component on the given graphics
      boolean equals​(java.lang.Object obj)  
      double getAngle()
      Retrieves the angle in degrees of the String
      java.awt.Font getFont()
      Retrieves the font used to print this String
      java.awt.FontMetrics getFontMetrics​(java.awt.Graphics2D g)
      Retrieves the FontMetrics associated with this GString for a given Graphics2D.
      java.lang.String getString()
      Retrieves the String
      int getX()
      Retrieves the x coordinate of the string
      int getY()
      Retrieves the y coordinate of the string
      int hashCode()  
      void move​(int x, int y)
      Moves this element to the given coordinates
      void setAngle​(double angle)
      Set's the angle of the String
      void setFont​(java.awt.Font font)
      Set's the font used to render this String
      void setString​(java.lang.String string)
      Set's the String to print in the screen
      void traslate​(int x, int y)
      Traslates this element on X and Y
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GString

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

        public GString​(int x,
                       int y,
                       java.lang.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,
                       java.lang.String str,
                       java.awt.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,
                       java.lang.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,
                       java.lang.String str,
                       java.awt.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 Detail

      • setString

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

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

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

        public java.awt.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​(java.awt.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 java.awt.FontMetrics getFontMetrics​(java.awt.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
      • equals

        public boolean equals​(java.lang.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