Class Ratio


  • @ProviderType
    public final class Ratio
    extends java.lang.Object
    Compare ratios with tolerance.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double get​(double width, double height)
      Get ratio from width/height.
      static double get​(long width, long height)
      Get ratio from width/height.
      static double get​(@NotNull Dimension dimension)
      Get ratio from width/height.
      static boolean matches​(double first, double second)
      Checks if both given ratio values are the same within the bounds of the MediaFormatHandler.RATIO_TOLERANCE.
      static boolean matches​(@NotNull MediaFormat first, @NotNull MediaFormat second)
      Checks if the ratios of both given media formats are the same within the bounds of the MediaFormatHandler.RATIO_TOLERANCE.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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)