Package io.guise.framework.geometry
Class Dimensions
- java.lang.Object
-
- io.guise.framework.geometry.Dimensions
-
public class Dimensions extends java.lang.Object
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
Fields Modifier and Type Field Description static Dimensions
ZERO_DIMENSIONS
A convenience dimensions of zero pixel size.
-
Constructor Summary
Constructors Constructor Description Dimensions(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Dimensions
constrain(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
equals(java.lang.Object object)
Extent
getDepth()
Extent
getHeight()
Extent
getWidth()
int
hashCode()
boolean
isEmpty()
java.lang.String
toString()
-
-
-
Field Detail
-
ZERO_DIMENSIONS
public static final Dimensions ZERO_DIMENSIONS
A convenience dimensions of zero pixel size.
-
-
Constructor Detail
-
Dimensions
public Dimensions(double width, double height, Unit unit)
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:
java.lang.NullPointerException
- if the given unit isnull
.
-
Dimensions
public Dimensions(double width, Unit widthUnit, double height, Unit heightUnit)
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:
java.lang.NullPointerException
- if the given width unit and/or height unit isnull
.
-
Dimensions
public Dimensions(double width, double height, double depth, Unit unit)
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:
java.lang.NullPointerException
- if the given unit isnull
.
-
Dimensions
public Dimensions(Extent width, Extent height)
Width and height extent constructor with a default depth of zero pixels.- Parameters:
width
- The width extent.height
- The height extent.- Throws:
java.lang.NullPointerException
- if the given width, and/or height isnull
.java.lang.IllegalArgumentException
- if the degree of any extent is not1
.
-
Dimensions
public Dimensions(Extent width, Extent height, Extent depth)
Width, height, and depth extent constructor.- Parameters:
width
- The width extent.height
- The height extent.depth
- The depth extent.- Throws:
java.lang.NullPointerException
- if the given width, height, and/or depth isnull
.java.lang.IllegalArgumentException
- if the degree of any extent is not1
.
-
-
Method Detail
-
getWidth
public Extent getWidth()
- Returns:
- The width extent.
-
getHeight
public Extent getHeight()
- Returns:
- The height extent.
-
getDepth
public Extent getDepth()
- Returns:
- The depth extent.
-
isEmpty
public boolean isEmpty()
- Returns:
true
if all extents of the dimensions are zero.- See Also:
Extent.isEmpty()
-
constrain
public Dimensions constrain(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. This implementation currently only supports two dimensions.- Parameters:
constrainingDimensions
- The outer constraining dimensions.- Returns:
- A dimension representing the constrained dimension.
- Throws:
java.lang.NullPointerException
- if the given constraining dimensions isnull
.java.lang.IllegalArgumentException
- if the given constraining dimensions use different units than these dimensions.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
This implementation returns whether the object is another dimensions with identical width, height, and depth.
- Overrides:
equals
in classjava.lang.Object
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-