Ratio
Inheritance: java.lang.Object
All Implemented Interfaces: com.groupdocs.editor.htmlcss.css.datatypes.ICssDataType
public class Ratio implements ICssDataType
Represents a “ratio” CSS data type, which is used for describing aspect ratios in media queries and for raster images by denoting the proportion between two unitless values called “numerator” and “denominator”. Immutable struct.
https://developer.mozilla.org/en-US/docs/Web/CSS/ratio
Constructors
Constructor | Description |
---|---|
Ratio() |
Fields
Field | Description |
---|---|
Single | Single default ratio 1/1 |
Methods
Method | Description |
---|---|
getNumerator() | Returns a numerator of this ratio |
getDenominator() | Returns a denominator of this ratio |
calculate() | Calculates and returns this ratio as a single floating point number |
getInverseRatio() | Generates and returns an inverse (reciprocal) ratio for this ratio |
serializeDefault() | Serializes this ratio to the string and returns it |
toString() | Returns a string representation of this ratio; same as “SerializeDefault()” |
isDefault() | Determines whether this ratio has default value or is a “1/1” (Single) |
deepClone() | Returns a full copy of this ratio |
equals(Ratio other) | Determines whether this instance is equal with specified “Ratio” instance |
equals(Object other) | Determines whether this instance is equal with specified uncasted object, which presumably is another “Ratio” instance |
op_Equality(Ratio left, Ratio right) | Compares two ratios and returns a boolean indicating if the two do match. |
op_Inequality(Ratio left, Ratio right) | Compares two ratios and returns a boolean indicating if the two do not match. |
hashCode() | Returns a hashcode for this instance, which cannot be changed during its lifetime |
create(int numerator, int denominator) | Creates and returns one Ratio instance from specified numerator and denominator |
Ratio()
public Ratio()
Single
public static final Ratio Single
Single default ratio 1/1
getNumerator()
public final int getNumerator()
Returns a numerator of this ratio
Returns: int
getDenominator()
public final int getDenominator()
Returns a denominator of this ratio
Returns: int
calculate()
public final double calculate()
Calculates and returns this ratio as a single floating point number
Returns: double - Floating-point number with double precision
getInverseRatio()
public final Ratio getInverseRatio()
Generates and returns an inverse (reciprocal) ratio for this ratio
Returns: Ratio - New Ratio instance, that is an inverse ratio for this one
serializeDefault()
public final String serializeDefault()
Serializes this ratio to the string and returns it
Returns: java.lang.String - String in “numerator/denominator” format
toString()
public String toString()
Returns a string representation of this ratio; same as “SerializeDefault()”
Returns: java.lang.String - String in “numerator/denominator” format
isDefault()
public final boolean isDefault()
Determines whether this ratio has default value or is a “1/1” (Single)
Returns: boolean
deepClone()
public final Ratio deepClone()
Returns a full copy of this ratio
Returns: Ratio - New Ratio instance, that is a full and deep copy of this one
equals(Ratio other)
public final boolean equals(Ratio other)
Determines whether this instance is equal with specified “Ratio” instance
Parameters:
Parameter | Type | Description |
---|---|---|
other | Ratio | Other Ratio instance to check on equality with this |
Returns: boolean - True if are equal, false if are unequal
equals(Object other)
public boolean equals(Object other)
Determines whether this instance is equal with specified uncasted object, which presumably is another “Ratio” instance
Parameters:
Parameter | Type | Description |
---|---|---|
other | java.lang.Object | Other System.Object instance, that is presumably of Ratio type, to check on equality with this |
Returns: boolean - True if are equal, false if are unequal
op_Equality(Ratio left, Ratio right)
public static boolean op_Equality(Ratio left, Ratio right)
Compares two ratios and returns a boolean indicating if the two do match.
Parameters:
Parameter | Type | Description |
---|---|---|
left | Ratio | The first ratio to use. |
right | Ratio | The second ratio to use. |
Returns: boolean - True if both ratios are equal, otherwise false.
op_Inequality(Ratio left, Ratio right)
public static boolean op_Inequality(Ratio left, Ratio right)
Compares two ratios and returns a boolean indicating if the two do not match.
Parameters:
Parameter | Type | Description |
---|---|---|
left | Ratio | The first ratio to use. |
right | Ratio | The second ratio to use. |
Returns: boolean - True if both ratios are not equal, otherwise false.
hashCode()
public int hashCode()
Returns a hashcode for this instance, which cannot be changed during its lifetime
Returns: int - Signed 4-byte integer, that is immutable for this instance
create(int numerator, int denominator)
public static Ratio create(int numerator, int denominator)
Creates and returns one Ratio instance from specified numerator and denominator
Parameters:
Parameter | Type | Description |
---|---|---|
numerator | int | Numerator for the ratio. Should be a strictly positive integer number. |
denominator | int | Denominator for the ratio. Should be a strictly positive integer number. |
Returns: Ratio - New Ratio instance