Package io.guise.framework.geometry
Class Dimensions
java.lang.Object
io.guise.framework.geometry.Dimensions
A measurement of an object's width, height, and depth along the X, Y, and Z dimensions, respectively.
Dimensions of zero dimensions are considered equal regardless of the units involved.
- Author:
- Garret Wilson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Dimensions
A convenience dimensions of zero pixel size. -
Constructor Summary
ConstructorDescriptionDimensions
(double width, double height, double depth, Unit unit) Width, height, and depth unit constructor.Dimensions
(double width, double height, Unit unit) Width and height unit constructor with a depth of one.Dimensions
(double width, Unit widthUnit, double height, Unit heightUnit) Width unit and height unit constructor with a depth of one.Dimensions
(Extent width, Extent height) Width and height extent constructor with a default depth of zero pixels.Dimensions
(Extent width, Extent height, Extent depth) Width, height, and depth extent constructor. -
Method Summary
Modifier and TypeMethodDescriptionconstrain
(Dimensions constrainingDimensions) Constrains these inner dimensions within the given outer dimensions by scaling these dimensions so that no part lies outside the given outer dimensiona.boolean
getDepth()
getWidth()
int
hashCode()
boolean
isEmpty()
final String
toString()
-
Field Details
-
ZERO_DIMENSIONS
A convenience dimensions of zero pixel size.
-
-
Constructor Details
-
Dimensions
Width and height unit constructor with a depth of one.- Parameters:
width
- The width.height
- The height.unit
- The unit with which the extent is measured.- Throws:
NullPointerException
- if the given unit isnull
.
-
Dimensions
Width unit and height unit constructor with a depth of one.- Parameters:
width
- The width.widthUnit
- The unit with which the width is measured.height
- The height.heightUnit
- The unit with which the height is measured.- Throws:
NullPointerException
- if the given width unit and/or height unit isnull
.
-
Dimensions
Width, height, and depth unit constructor.- Parameters:
width
- The width.height
- The height.depth
- The depth.unit
- The unit with which the extent is measured.- Throws:
NullPointerException
- if the given unit isnull
.
-
Dimensions
Width and height extent constructor with a default depth of zero pixels.- Parameters:
width
- The width extent.height
- The height extent.- Throws:
NullPointerException
- if the given width, and/or height isnull
.IllegalArgumentException
- if the degree of any extent is not1
.
-
Dimensions
Width, height, and depth extent constructor.- Parameters:
width
- The width extent.height
- The height extent.depth
- The depth extent.- Throws:
NullPointerException
- if the given width, height, and/or depth isnull
.IllegalArgumentException
- if the degree of any extent is not1
.
-
-
Method Details
-
getWidth
- Returns:
- The width extent.
-
getHeight
- Returns:
- The height extent.
-
getDepth
- Returns:
- The depth extent.
-
isEmpty
public boolean isEmpty()- Returns:
true
if all extents of the dimensions are zero.- See Also:
-
constrain
Constrains these inner dimensions within the given outer dimensions by scaling these dimensions so that no part lies outside the given outer dimensiona. This implementation currently only supports two dimensions.- Parameters:
constrainingDimensions
- The outer constraining dimensions.- Returns:
- A dimension representing the constrained dimension.
- Throws:
NullPointerException
- if the given constraining dimensions isnull
.IllegalArgumentException
- if the given constraining dimensions use different units than these dimensions.
-
hashCode
public int hashCode() -
equals
This implementation returns whether the object is another dimensions with identical width, height, and depth.
-
toString
-