Record Class Region

java.lang.Object
java.lang.Record
is.galia.image.Region
Record Components:
x - X origin.
y - Y origin.
size - Size.
isFull - When true, indicates a "full region" which renders its coordinate properties irrelevant.

public record Region(double x, double y, Size size, boolean isFull) extends Record

Region on a plane with origin and dimensions.

A negative origin is allowed. Zero-dimensions are allowed, but not negative ones.

  • Constructor Details

    • Region

      public Region(double x, double y, Size size)
    • Region

      public Region(double x, double y, Size size, boolean isFull)
      Creates an instance of a Region record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
      size - the value for the size record component
      isFull - the value for the isFull record component
    • Region

      public Region(double x, double y, double width, double height)
    • Region

      public Region(double x, double y, double width, double height, boolean isFull)
    • Region

      public Region(long x, long y, long width, long height)
    • Region

      public Region(long x, long y, long width, long height, boolean isFull)
    • Region

      public Region(Region other)
      Copy constructor.
  • Method Details

    • contains

      public boolean contains(Region other)
      Returns:
      Whether the given rectangle is entirely contained within the instance.
    • equals

      public boolean equals(Object obj)
      Override that allows a small differences between float values.
      Specified by:
      equals in class Record
    • clippedTo

      public Region clippedTo(Size size)
      Returns:
      New instance with the smaller of its current size or the given size.
    • width

      public double width()
    • height

      public double height()
    • intX

      public int intX()
      Returns:
      Rounded value of x().
    • intY

      public int intY()
      Returns:
      Rounded value of y().
    • intWidth

      public int intWidth()
      Returns:
      Rounded value of width().
    • intHeight

      public int intHeight()
      Returns:
      Rounded value of height().
    • intersects

      public boolean intersects(Region other)
    • isEmpty

      public boolean isEmpty()
      Returns:
      Whether the instance has zero dimensions and is not full.
    • longX

      public long longX()
      Returns:
      Rounded value of x().
    • longY

      public long longY()
      Returns:
      Rounded value of y().
    • longWidth

      public long longWidth()
      Returns:
      Rounded value of width().
    • longHeight

      public long longHeight()
      Returns:
      Rounded value of height().
    • moved

      public Region moved(double x, double y)
    • oriented

      public Region oriented(Size fullSize, Orientation orientation)
      Parameters:
      fullSize - Raw source image dimensions.
      orientation - Orientation to apply.
      Returns:
      New oriented instance derived from the current one.
    • resized

      public Region resized(double width, double height)
      Returns:
      New instance with the same origin and the given size.
    • scaled

      public Region scaled(double amount)
      Returns:
      New instance with origin and size scaled by the given amount.
    • scaled

      public Region scaled(double xAmount, double yAmount)
      Returns:
      New instance with origin and dimensions scaled by the given amounts.
    • size

      public Size size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • toAWTRectangle

      public Rectangle toAWTRectangle()
      Warning: Rectangle does not support coordinates larger than Integer.MAX_VALUE,
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • x

      public double x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public double y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • isFull

      public boolean isFull()
      Returns the value of the isFull record component.
      Returns:
      the value of the isFull record component