Package com.journeyapps.barcodescanner
Class Size
- java.lang.Object
-
- com.journeyapps.barcodescanner.Size
-
- All Implemented Interfaces:
Comparable<Size>
public class Size extends Object implements Comparable<Size>
-
-
Constructor Summary
Constructors Constructor Description Size(int width, int height)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Size other)Default sort order is ascending by size.booleanequals(Object o)booleanfitsIn(Size other)Checks if both dimensions of the other size are at least as large as this size.inthashCode()Sizerotate()Swap width and height.Sizescale(int n, int d)Scale by n / d.SizescaleCrop(Size into)Scales the size so that both dimensions will be greater than or equal to the corresponding dimension of the parent.SizescaleFit(Size into)Scales the dimensions so that it fits entirely inside the parent.One of width or height will fit exactly.StringtoString()
-
-
-
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- numeratord- 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:
compareToin interfaceComparable<Size>
-
-