Record Class ScaleConstraint
java.lang.Object
java.lang.Record
is.galia.image.ScaleConstraint
A scale-constrained image can be thought of as a virtually downscaled
source image. In contrast to a Scale
, the dimensions of a
scale-constrained image appear (to the client) to be the dimensions
resulting from the constraint, so any scaling-related operations expressed
by the client are relative to the scale-constrained image.
Scale constraints are used for providing access to limited-resolution versions of images depending on authorization status. An unauthorized client may only be able to access a 1/2 scaled image, for example.
Scale constraints are expressed as fractions, mainly in order to avoid repeating decimals, which would make for URIs that are hard to canonicalize.
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a no-op (1:1) constraint.ScaleConstraint
(long numerator, long denominator) ScaleConstraint
(Rational rational) Creates an instance of aScaleConstraint
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.getConstrainedSize
(Size fullSize) getResultingSize
(Size fullSize) boolean
final int
hashCode()
Returns a hash code value for this object.rational()
Returns the value of therational
record component.reduced()
toMap()
toString()
Returns a string representation of this record class.
-
Constructor Details
-
ScaleConstraint
Creates an instance of aScaleConstraint
record class.- Parameters:
rational
- the value for therational
record component
-
ScaleConstraint
public ScaleConstraint()Initializes a no-op (1:1) constraint. -
ScaleConstraint
public ScaleConstraint(long numerator, long denominator) - Parameters:
numerator
- Scale numerator.denominator
- Scale denominator.- Throws:
IllegalArgumentException
- if the numerator or denominator is not positive or if the numerator is greater than the denominator.
-
-
Method Details
-
getConstrainedSize
-
reduced
- Returns:
- Instance reduced to lowest terms.
-
getResultingSize
-
hasEffect
public boolean hasEffect()- Returns:
- Whether the instance's
numerator
anddenominator
are unequal.
-
toMap
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
rational
Returns the value of therational
record component.- Returns:
- the value of the
rational
record component
-