Class Rectangle

java.lang.Object
com.github.ngoanh2n.Rectangle

@CanIgnoreReturnValue @ParametersAreNonnullByDefault public class Rectangle extends Object
A copy of java.awt.Rectangle.

Repository:
Since:
2021
  • Constructor Details

    • Rectangle

      public Rectangle(Dimension dimension)
      Construct a new Rectangle by location 0:0 and size d.
      Parameters:
      dimension - The size of the newly constructed Rectangle.
    • Rectangle

      public Rectangle(Point point, Dimension dimension)
      Construct a new Rectangle by location p and size d.
      Parameters:
      point - The position of the newly constructed Rectangle.
      dimension - The size of the newly constructed Rectangle.
    • Rectangle

      public Rectangle(int x, int y, int w, int h)
      Construct a new Rectangle by location x:y and size w,h.
      Parameters:
      x - The X coordinate of the newly constructed Point.
      y - The Y coordinate of the newly constructed Point.
      w - The width of the newly constructed Dimension.
      h - The height of the newly constructed Dimension.
  • Method Details

    • getX

      public int getX()
      Get the X coordinate of this Rectangle.
      Returns:
      The X coordinate of this Rectangle.
    • getY

      public int getY()
      Get the Y coordinate of this Rectangle.
      Returns:
      The Y coordinate of this Rectangle.
    • getWidth

      public int getWidth()
      Get width of this Rectangle.
      Returns:
      The width of this Rectangle.
    • getHeight

      public int getHeight()
      Get height of this Rectangle.
      Returns:
      The height of this Rectangle.
    • getLocation

      public Point getLocation()
      Get location of this Rectangle.
      Returns:
      The location of this Rectangle.
    • setLocation

      public Rectangle setLocation(Point value)
      Set value for this Rectangle.
      Parameters:
      value - The new value for this Rectangle.
      Returns:
      This Rectangle.
    • getSize

      public Dimension getSize()
      Get size of this Rectangle.
      Returns:
      The size of this Rectangle.
    • setSize

      public Rectangle setSize(Dimension value)
      Set size for this Rectangle.
      Parameters:
      value - The new size for this Rectangle.
      Returns:
      This Rectangle.
    • toString

      public String toString()
      Returns a string representation of this Rectangle.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this Rectangle.