Class Rectangle

    • Constructor Detail

      • Rectangle

        public Rectangle()
      • Rectangle

        public Rectangle​(int x,
                         int y,
                         int width,
                         int height)
    • Method Detail

      • set

        public final Rectangle set​(int x,
                                   int y,
                                   int width,
                                   int height)
      • setX

        public final Rectangle setX​(int x)
      • setY

        public final Rectangle setY​(int y)
      • setWidth

        public final Rectangle setWidth​(int width)
      • setHeight

        public final Rectangle setHeight​(int height)
      • union

        public final Rectangle union​(List<RectangleImmutable> rectangles)
        Description copied from interface: RectangleImmutable
        Calculates the union of the given rectangles, stores it in this instance and returns this instance.
        Specified by:
        union in interface RectangleImmutable
        Parameters:
        rectangles - given list of rectangles
        Returns:
        this instance holding the union of given rectangles.
      • coverage

        public final float coverage​(RectangleImmutable r)
        Description copied from interface: RectangleImmutable
        Returns the coverage of given rectangle w/ this this one, i.e. between 0.0 and 1.0.

        Coverage is computed by:

            isect = this.intersection(r);
            coverage = area( isect ) / area( this ) ;
         

        Specified by:
        coverage in interface RectangleImmutable
      • scale

        public final Rectangle scale​(int sx,
                                     int sy)
        Scale this instance's components, i.e. multiply them by the given scale factors.
        Parameters:
        sx - scale factor for x
        sy - scale factor for y
        Returns:
        this instance for scaling
      • scale

        public final Rectangle scale​(float sx,
                                     float sy)
        Scale this instance's components, i.e. multiply them by the given scale factors (rounded).
        Parameters:
        sx - scale factor for x
        sy - scale factor for y
        Returns:
        this instance for scaling
      • scaleInv

        public final Rectangle scaleInv​(int sx,
                                        int sy)
        Inverse scale this instance's components, i.e. divide them by the given scale factors.
        Parameters:
        sx - inverse scale factor for x
        sy - inverse scale factor for y
        Returns:
        this instance for scaling
      • scaleInv

        public final Rectangle scaleInv​(float sx,
                                        float sy)
        Inverse scale this instance's components, i.e. divide them by the given scale factors (rounded).
        Parameters:
        sx - inverse scale factor for x
        sy - inverse scale factor for y
        Returns:
        this instance for scaling
      • equals

        public boolean equals​(Object obj)
        Description copied from interface: RectangleImmutable
        Checks whether two rect objects are equal. Two instances of Rectangle are equal if the four integer values of the fields y, x, height, and width are all equal.
        Specified by:
        equals in interface RectangleImmutable
        Overrides:
        equals in class Object
        Returns:
        true if the two rectangles are equal; otherwise false.