Class Rectangles

java.lang.Object
org.jhotdraw8.geom.Rectangles

public class Rectangles extends Object
Provides geometry utility functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The bitmask that indicates that a point lies below the rectangle.
    static final int
    The bitmask that indicates that a point lies to the left of the rectangle.
    static final int
    The bitmask that indicates that a point lies to the right of the rectangle.
    static final int
    The bitmask that indicates that a point lies above the rectangle.
    static final double
    Absolute threshold to be used for comparing reals generally.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(double rx, double ry, double rw, double rh, double x, double y, double tolerance)
    Returns true if the bounds contain the specified point within the given tolerance.
    static boolean
    Returns true, if rectangle 1 contains rectangle 2.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OUT_BOTTOM

      public static final int OUT_BOTTOM
      The bitmask that indicates that a point lies below the rectangle.
      See Also:
    • OUT_LEFT

      public static final int OUT_LEFT
      The bitmask that indicates that a point lies to the left of the rectangle.
      See Also:
    • OUT_RIGHT

      public static final int OUT_RIGHT
      The bitmask that indicates that a point lies to the right of the rectangle.
      See Also:
    • OUT_TOP

      public static final int OUT_TOP
      The bitmask that indicates that a point lies above the rectangle.
      See Also:
    • REAL_THRESHOLD

      public static final double REAL_THRESHOLD
      Absolute threshold to be used for comparing reals generally.
      See Also:
  • Method Details

    • contains

      public static boolean contains(double rx, double ry, double rw, double rh, double x, double y, double tolerance)
      Returns true if the bounds contain the specified point within the given tolerance.
      Parameters:
      rx - the bounds x-coordinate
      ry - the bounds y-coordinate
      rw - the bounds width
      rh - the bounds height
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      tolerance - the tolerance
      Returns:
      true if inside
    • containsAWT

      public static boolean containsAWT(@NonNull Rectangle2D r1, @NonNull Rectangle2D r2)
      Returns true, if rectangle 1 contains rectangle 2.

      This method is similar to Rectangle2D.contains, but also returns true, when rectangle1 contains rectangle2 and either or both of them are empty.

      Parameters:
      r1 - Rectangle 1.
      r2 - Rectangle 2.
      Returns:
      true if r1 contains r2.