com.guiseframework.geometry
Class Dimensions

java.lang.Object
  extended by com.guiseframework.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.

Author:
garret

Field Summary
static Dimensions ZERO_DIMENSIONS
          A convenience dimensions of zero pixel size.
 
Constructor Summary
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
 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)
          Indicates whether some other object is "equal to" this one.
 Extent getDepth()
           
 Extent getHeight()
           
 Extent getWidth()
           
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 is null.

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 is null.

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 is null.

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 is null.
java.lang.IllegalArgumentException - if the degree of any extent is not 1.

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 is null.
java.lang.IllegalArgumentException - if the degree of any extent is not 1.
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.

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 is null.
java.lang.IllegalArgumentException - if the given constraining dimensions use different units than these dimensions.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for the object.

equals

public boolean equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one. This implementation returns whether the object is another dimensions with identical width, height, and depth.

Overrides:
equals in class java.lang.Object
Parameters:
object - The reference object with which to compare.
Returns:
true if this object is equivalent to the given object.

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A string representation of the object.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.