Package com.helger.base.dimension
Class SizeDouble
java.lang.Object
com.helger.base.dimension.SizeDouble
- All Implemented Interfaces:
IHasDimensionDouble,IHasHeightDouble,IHasWidthDouble
This class represents an object having width and height.
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionSizeDouble(double dWidth, double dHeight) Constructor with width and height.SizeDouble(@NonNull IHasDimensionDouble aObj) Constructor copying from an existing double dimension object.SizeDouble(@NonNull IHasDimensionFloat aObj) Constructor copying from an existing float dimension object.SizeDouble(@NonNull IHasDimensionInt aObj) Constructor copying from an existing int dimension object.SizeDouble(@NonNull IHasDimensionLong aObj) Constructor copying from an existing long dimension object. -
Method Summary
Modifier and TypeMethodDescriptionboolean@NonNull SizeDoublegetAdded(@NonNull IHasDimensionDouble aToAdd) Get a new size with the dimensions of the provided double dimension added.@NonNull SizeDoublegetAdded(@NonNull IHasDimensionFloat aToAdd) Get a new size with the dimensions of the provided float dimension added.@NonNull SizeDoublegetAdded(@NonNull IHasDimensionInt aToAdd) Get a new size with the dimensions of the provided int dimension added.@NonNull SizeDoublegetBestMatchingSize(double dMaxWidth, double dMaxHeight) Return the scaled width and height relative to a maximum size.double@NonNull SizeDoublegetScaledToHeight(double dNewHeight) Get a new size that is scaled to the specified height, keeping the aspect ratio.@NonNull SizeDoublegetScaledToWidth(double dNewWidth) Get a new size that is scaled to the specified width, keeping the aspect ratio.@NonNull SizeDoublegetSubtracted(@NonNull IHasDimensionDouble aToSubtract) Get a new size with the dimensions of the provided double dimension subtracted.@NonNull SizeDoublegetSubtracted(@NonNull IHasDimensionFloat aToSubtract) Get a new size with the dimensions of the provided float dimension subtracted.@NonNull SizeDoublegetSubtracted(@NonNull IHasDimensionInt aToSubtract) Get a new size with the dimensions of the provided int dimension subtracted.doublegetWidth()inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.dimension.IHasDimensionDouble
isLandscape, isPortrait, isQuadratic
-
Constructor Details
-
SizeDouble
Constructor copying from an existing int dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeDouble
Constructor copying from an existing long dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeDouble
Constructor copying from an existing float dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeDouble
Constructor copying from an existing double dimension object.- Parameters:
aObj- The dimension object to copy from. May not benull.
-
SizeDouble
public SizeDouble(@Nonnegative double dWidth, @Nonnegative double dHeight) Constructor with width and height.- Parameters:
dWidth- The width. Must be ≥ 0.dHeight- The height. Must be ≥ 0.
-
-
Method Details
-
getWidth
@Nonnegative public double getWidth()- Specified by:
getWidthin interfaceIHasWidthDouble- Returns:
- The width of an object
-
getHeight
@Nonnegative public double getHeight()- Specified by:
getHeightin interfaceIHasHeightDouble- Returns:
- The height of an object
-
getBestMatchingSize
@CheckReturnValue public @NonNull SizeDouble getBestMatchingSize(@Nonnegative double dMaxWidth, @Nonnegative double 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
SizeDoublewith 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
SizeDoublewith 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
SizeDouble. 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
SizeDouble. Nevernull.
-
getAdded
Get a new size with the dimensions of the provided double dimension added.- Parameters:
aToAdd- The dimension to add. May not benull.- Returns:
- A new
SizeDouble. 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
SizeDouble. 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
SizeDouble. Nevernull.
-
getSubtracted
@CheckReturnValue public @NonNull SizeDouble getSubtracted(@NonNull IHasDimensionDouble aToSubtract) Get a new size with the dimensions of the provided double dimension subtracted.- Parameters:
aToSubtract- The dimension to subtract. May not benull.- Returns:
- A new
SizeDouble. Nevernull.
-
equals
-
hashCode
public int hashCode() -
toString
-