Package io.wcm.handler.media.format
Class Ratio
- java.lang.Object
-
- io.wcm.handler.media.format.Ratio
-
@ProviderType public final class Ratio extends java.lang.ObjectCompare ratios with tolerance.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleget(double width, double height)Get ratio from width/height.static doubleget(long width, long height)Get ratio from width/height.static doubleget(@NotNull Dimension dimension)Get ratio from width/height.static booleanmatches(double first, double second)Checks if both given ratio values are the same within the bounds of theMediaFormatHandler.RATIO_TOLERANCE.static booleanmatches(@NotNull MediaFormat first, @NotNull MediaFormat second)Checks if the ratios of both given media formats are the same within the bounds of theMediaFormatHandler.RATIO_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 theMediaFormatHandler.RATIO_TOLERANCE.- Parameters:
first- First ratiosecond- 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 theMediaFormatHandler.RATIO_TOLERANCE. If one or both of the media formats do not have a ratio set, the method returns false.- Parameters:
first- First ratiosecond- Second ratio- Returns:
- If ratio matches.
-
get
public static double get(double width, double height)Get ratio from width/height.- Parameters:
width- Widthheight- 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- Widthheight- 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)
-
-