Class Rectangle

java.lang.Object
com.luciad.cartesian.Rectangle

public final class Rectangle extends Object
A "POD" for a 2D rectangle.

Not a geometry, to be used for communicating 2D cartesian rectangles.

  • Constructor Details Link icon

    • Rectangle Link icon

      public Rectangle()
      Creates a Rectangle at the origin, with width and height 0.
    • Rectangle Link icon

      public Rectangle(double x, double y, double width, double height)
      Creates a Rectangle with the provided x, y, width, and height values.
      Parameters:
      x - the lower left corner's x-ordinate
      y - the lower left corner's y-ordinate
      width - the rectangle's width
      height - the rectangle's height
    • Rectangle Link icon

      public Rectangle(@NotNull Coordinate corner1, @NotNull Coordinate corner2)
      Creates a Rectangle with the given corners.

      The corners do not need to have any particular relation to each other. Only the x and y ordinates of the corners are considered.

      Parameters:
      corner1 - one corner position
      corner2 - another corner position
    • Rectangle Link icon

      public Rectangle(@NotNull Rectangle other)
  • Method Details Link icon

    • grow Link icon

      public void grow(double margin)
      Grows this rectangle by the given margin.

      The lower left corner is moved in the direction of negative x and y by margin. The upper right corner is moved in the direction of positive x and y by margin.

      Parameters:
      margin - a margin
    • getX Link icon

      public double getX()
      The lower left corner's x-ordinate.
    • getY Link icon

      public double getY()
      The lower left corner's y-ordinate.
    • getWidth Link icon

      public double getWidth()
      The rectangle's width.
    • getHeight Link icon

      public double getHeight()
      The rectangle's height.
    • getLowerLeftCorner Link icon

      @NotNull public Coordinate getLowerLeftCorner()
      Returns the coordinate at the lower left corner of this rectangle.
      Returns:
      the coordinate at the lower left corner of this rectangle.
    • getLowerRightCorner Link icon

      @NotNull public Coordinate getLowerRightCorner()
      Returns the coordinate at the lower right corner of this rectangle.
      Returns:
      the coordinate at the lower right corner of this rectangle.
    • getUpperLeftCorner Link icon

      @NotNull public Coordinate getUpperLeftCorner()
      Returns the coordinate at the upper left corner of this rectangle.
      Returns:
      the coordinate at the upper left corner of this rectangle.
    • getUpperRightCorner Link icon

      @NotNull public Coordinate getUpperRightCorner()
      Returns the coordinate at the upper right corner of this rectangle.
      Returns:
      the coordinate at the upper right corner of this rectangle.
    • getCenter Link icon

      @NotNull public Coordinate getCenter()
      Returns the coordinate in the center of this rectangle.
      Returns:
      the coordinate in the center of this rectangle.
    • isValid Link icon

      public boolean isValid()
      Returns whether all fields are neither not-a-number nor infinite and the width and height are non-negative.
      Returns:
      whether all fields are neither not-a-number nor infinite and the width and height are non-negative.
    • equals Link icon

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Returns the hash for this rectangle.
      Overrides:
      hashCode in class Object
      Returns:
      the hash for this rectangle.
    • toString Link icon

      @NotNull public String toString()
      Overrides:
      toString in class Object