com.guiseframework.geometry
Class Extent

java.lang.Object
  extended by com.guiseframework.geometry.Extent
All Implemented Interfaces:
java.lang.Comparable<Extent>

public class Extent
extends java.lang.Object
implements java.lang.Comparable<Extent>

A measurement such as a length, area, or volume. All zero extents are considered equal, regardless of the unit of measurement. For this implementation only extents of the same unit and degree should be compared, although consistent, if inaccurate, values will still be obtained otherwise.

Author:
Garret Wilson

Field Summary
static Extent ZERO_EXTENT1
          A convenience one-dimensional extent of zero pixels.
 
Constructor Summary
Extent(double value)
          Value constructor for a one-dimensional pixel extent.
Extent(double value, Unit unit)
          Value and unit constructor with a degree of one.
Extent(double value, Unit unit, int degree)
          Value, unit, and degree constructor.
 
Method Summary
 int compareTo(Extent extent)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object object)
          Indicates whether some other object is "equal to" this one.
 int getDegree()
           
 Unit getUnit()
           
 double getValue()
           
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO_EXTENT1

public static final Extent ZERO_EXTENT1
A convenience one-dimensional extent of zero pixels.

Constructor Detail

Extent

public Extent(double value)
Value constructor for a one-dimensional pixel extent.

Parameters:
value - The value of the extent.

Extent

public Extent(double value,
              Unit unit)
Value and unit constructor with a degree of one.

Parameters:
value - The value of the extent.
unit - The unit with which the extent is measured.
Throws:
java.lang.NullPointerException - if the given unit is null.

Extent

public Extent(double value,
              Unit unit,
              int degree)
Value, unit, and degree constructor.

Parameters:
value - The value of the extent.
unit - The unit with which the extent is measured.
degree - The degree of dimensions of the measurement.
Throws:
java.lang.NullPointerException - if the given unit is null.
java.lang.IllegalArgumentException - if the degree is non-positive.
Method Detail

getValue

public double getValue()
Returns:
The value of the extent.

getUnit

public Unit getUnit()
Returns:
The unit with which the extent is measured.

getDegree

public int getDegree()
Returns:
The degree of dimensions of the measurement.

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 extent with identical value, unit, and degree, ignoring the unit if the value is zero.

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.

compareTo

public int compareTo(Extent extent)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. This implementation is meant to compare extents of identical units; non-identical units will be compared by unit ordinal. This implementation is meant to compare extents of identical degrees; non-identical degrees will be compared by degrees.

Specified by:
compareTo in interface java.lang.Comparable<Extent>
Parameters:
extent - The object to be compared.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this extent.


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