Package com.helger.base.dimension
Class SizeFloat
java.lang.Object
com.helger.base.dimension.SizeFloat
- All Implemented Interfaces:
IHasDimensionFloat,IHasHeightFloat,IHasWidthFloat
This class represents an object having width and height.
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionSizeFloat(float dWidth, float dHeight) Constructor with width and height.SizeFloat(@NonNull IHasDimensionFloat aObj) Constructor copying from an existing float dimension object.SizeFloat(@NonNull IHasDimensionInt aObj) Constructor copying from an existing int dimension object.SizeFloat(@NonNull IHasDimensionLong aObj) Constructor copying from an existing long dimension object. -
Method Summary
Modifier and TypeMethodDescriptionboolean@NonNull SizeFloatgetAdded(@NonNull IHasDimensionFloat aToAdd) Get a new size with the dimensions of the provided float dimension added.@NonNull SizeFloatgetAdded(@NonNull IHasDimensionInt aToAdd) Get a new size with the dimensions of the provided int dimension added.@NonNull SizeFloatgetBestMatchingSize(float dMaxWidth, float dMaxHeight) Return the scaled width and height relative to a maximum size.float@NonNull SizeFloatgetScaledToHeight(float dNewHeight) Get a new size that is scaled to the specified height, keeping the aspect ratio.@NonNull SizeFloatgetScaledToWidth(float dNewWidth) Get a new size that is scaled to the specified width, keeping the aspect ratio.@NonNull SizeFloatgetSubtracted(@NonNull IHasDimensionFloat aToSubtract) Get a new size with the dimensions of the provided float dimension subtracted.@NonNull SizeFloatgetSubtracted(@NonNull IHasDimensionInt aToSubtract) Get a new size with the dimensions of the provided int dimension subtracted.floatgetWidth()inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.dimension.IHasDimensionFloat
isLandscape, isPortrait, isQuadratic
-
Constructor Details
-
SizeFloat
Constructor copying from an existing int dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeFloat
Constructor copying from an existing long dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeFloat
Constructor copying from an existing float dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeFloat
public SizeFloat(@Nonnegative float dWidth, @Nonnegative float dHeight) Constructor with width and height.- Parameters:
dWidth- The width. Must be ≥ 0.dHeight- The height. Must be ≥ 0.
-
-
Method Details
-
getWidth
@Nonnegative public float getWidth()- Specified by:
getWidthin interfaceIHasWidthFloat- Returns:
- The width of an object
-
getHeight
@Nonnegative public float getHeight()- Specified by:
getHeightin interfaceIHasHeightFloat- Returns:
- The height of an object
-
getBestMatchingSize
@CheckReturnValue public @NonNull SizeFloat getBestMatchingSize(@Nonnegative float dMaxWidth, @Nonnegative float dMaxHeight) Return the scaled width and height relative to a maximum size.- Parameters:
dMaxWidth- Maximum width. Must be > 0.dMaxHeight- Maximum height. Must be > 0.- Returns:
- An array with 2 elements, where the first element is the width, and the second is the height.
-
getScaledToWidth
Get a new size that is scaled to the specified width, keeping the aspect ratio.- Parameters:
dNewWidth- The new width. Must be > 0.- Returns:
- A new
SizeFloatwith the scaled dimensions. Nevernull.
-
getScaledToHeight
Get a new size that is scaled to the specified height, keeping the aspect ratio.- Parameters:
dNewHeight- The new height. Must be > 0.- Returns:
- A new
SizeFloatwith the scaled dimensions. Nevernull.
-
getAdded
Get a new size with the dimensions of the provided int dimension added.- Parameters:
aToAdd- The dimension to add. May not benull.- Returns:
- A new
SizeFloat. Nevernull.
-
getAdded
Get a new size with the dimensions of the provided float dimension added.- Parameters:
aToAdd- The dimension to add. May not benull.- Returns:
- A new
SizeFloat. Nevernull.
-
getSubtracted
Get a new size with the dimensions of the provided int dimension subtracted.- Parameters:
aToSubtract- The dimension to subtract. May not benull.- Returns:
- A new
SizeFloat. Nevernull.
-
getSubtracted
Get a new size with the dimensions of the provided float dimension subtracted.- Parameters:
aToSubtract- The dimension to subtract. May not benull.- Returns:
- A new
SizeFloat. Nevernull.
-
equals
-
hashCode
public int hashCode() -
toString
-