Class Ratio


  • @ProviderType
    public final class Ratio
    extends Object
    Compare ratios with tolerance.
    • Method Detail

      • matches

        public static boolean matches​(double first,
                                      double second)
        Checks if both given ratio values are the same within the bounds of the MediaFormatHandler.RATIO_TOLERANCE.
        Parameters:
        first - First ratio
        second - Second ratio
        Returns:
        If ratio matches.
      • matches

        public static boolean matches​(@NotNull
                                      @NotNull MediaFormat first,
                                      @NotNull
                                      @NotNull MediaFormat second)
        Checks if the ratios of both given media formats are the same within the bounds of the MediaFormatHandler.RATIO_TOLERANCE. If one or both of the media formats do not have a ratio set, the method returns false.
        Parameters:
        first - First ratio
        second - Second ratio
        Returns:
        If ratio matches.
      • get

        public static double get​(double width,
                                 double height)
        Get ratio from width/height.
        Parameters:
        width - Width
        height - Height
        Returns:
        Ratio (returns 0 when ratio is invalid)
      • get

        public static double get​(long width,
                                 long height)
        Get ratio from width/height.
        Parameters:
        width - Width
        height - Height
        Returns:
        Ratio (returns 0 when ratio is invalid)
      • get

        public static double get​(@NotNull
                                 @NotNull Dimension dimension)
        Get ratio from width/height.
        Parameters:
        dimension - Dimension
        Returns:
        Ratio (returns 0 when ratio is invalid)