Class Size

    • Field Detail

      • width

        public final int width
      • height

        public final int height
    • Constructor Detail

      • Size

        public Size​(int width,
                    int height)
    • Method Detail

      • rotate

        public Size rotate()
        Swap width and height.
        Returns:
        a new Size with swapped width and height
      • scale

        public Size scale​(int n,
                          int d)
        Scale by n / d.
        Parameters:
        n - numerator
        d - denominator
        Returns:
        the scaled size
      • scaleFit

        public Size scaleFit​(Size into)
        Scales the dimensions so that it fits entirely inside the parent.One of width or height will fit exactly. Aspect ratio is preserved.
        Parameters:
        into - the parent to fit into
        Returns:
        the scaled size
      • scaleCrop

        public Size scaleCrop​(Size into)
        Scales the size so that both dimensions will be greater than or equal to the corresponding dimension of the parent. One of width or height will fit exactly. Aspect ratio is preserved.
        Parameters:
        into - the parent to fit into
        Returns:
        the scaled size
      • fitsIn

        public boolean fitsIn​(Size other)
        Checks if both dimensions of the other size are at least as large as this size.
        Parameters:
        other - the size to compare with
        Returns:
        true if this size fits into the other size
      • compareTo

        public int compareTo​(@NonNull
                             Size other)
        Default sort order is ascending by size.
        Specified by:
        compareTo in interface Comparable<Size>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object