com.guiseframework.geometry
Class Rectangle

java.lang.Object
  extended by com.guiseframework.geometry.Rectangle

public class Rectangle
extends java.lang.Object

A rectangle on a plane.

Author:
Garret Wilson

Field Summary
static Rectangle EMPTY_RECTANGLE
          A predefined rectangle with zero size on the zero plane.
 
Constructor Summary
Rectangle(double x, double y, double width, double height)
          Two-dimensional primitive pixel coordinates and dimensions constructor.
Rectangle(double x, double y, double z, double width, double height)
          Primitive pixel coordinates and dimensions constructor.
Rectangle(double x, double y, double z, double width, double height, Unit unit)
          Primitive coordinates, dimensions, and unit constructor.
Rectangle(double x, double y, double width, double height, Unit unit)
          Two-dimensional primitive coordinates, dimensions, and unit constructor.
Rectangle(Extent x, Extent y, Extent width, Extent height)
          Two-dimensional coordinates and dimensions constructor.
Rectangle(Extent x, Extent y, Extent z, Extent width, Extent height)
          Coordinates and dimensions constructor.
Rectangle(Point position, Dimensions size)
          Position and size constructor.
 
Method Summary
 boolean equals(java.lang.Object object)
          Indicates whether some other object is "equal to" this one.
 Point getPosition()
           
 Dimensions getSize()
           
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_RECTANGLE

public static final Rectangle EMPTY_RECTANGLE
A predefined rectangle with zero size on the zero plane.

Constructor Detail

Rectangle

public Rectangle(double x,
                 double y,
                 double width,
                 double height)
Two-dimensional primitive pixel coordinates and dimensions constructor.

Parameters:
x - The X coordinate.
y - The Y coordinate.
width - The width of the rectangle
height - The height of the rectangle.

Rectangle

public Rectangle(double x,
                 double y,
                 double z,
                 double width,
                 double height)
Primitive pixel coordinates and dimensions constructor.

Parameters:
x - The X coordinate.
y - The Y coordinate.
z - The Z coordinate.
width - The width of the rectangle
height - The height of the rectangle.

Rectangle

public Rectangle(double x,
                 double y,
                 double width,
                 double height,
                 Unit unit)
Two-dimensional primitive coordinates, dimensions, and unit constructor.

Parameters:
x - The X coordinate.
y - The Y coordinate.
width - The width of the rectangle
height - The height of the rectangle.
unit - The unit in which the point is measured.

Rectangle

public Rectangle(double x,
                 double y,
                 double z,
                 double width,
                 double height,
                 Unit unit)
Primitive coordinates, dimensions, and unit constructor.

Parameters:
x - The X coordinate.
y - The Y coordinate.
z - The Z coordinate.
width - The width of the rectangle
height - The height of the rectangle.
unit - The unit in which the point is measured.

Rectangle

public Rectangle(Extent x,
                 Extent y,
                 Extent width,
                 Extent height)
Two-dimensional coordinates and dimensions constructor.

Parameters:
x - The X coordinate.
y - The Y coordinate.
width - The width of the rectangle
height - The height of the rectangle.

Rectangle

public Rectangle(Extent x,
                 Extent y,
                 Extent z,
                 Extent width,
                 Extent height)
Coordinates and dimensions constructor.

Parameters:
x - The X coordinate.
y - The Y coordinate.
z - The Z coordinate.
width - The width of the rectangle
height - The height of the rectangle.

Rectangle

public Rectangle(Point position,
                 Dimensions size)
Position and size constructor.

Parameters:
position - The position of the upper-left corner of the rectangle.
size - The size of the rectangle, which is guaranteed to have zero depth.
Throws:
java.lang.NullPointerException - if the position and/or size is null.
java.lang.IllegalArgumentException - if the size has a non-zero depth.
Method Detail

getPosition

public Point getPosition()
Returns:
The position of the upper-left corner of the rectangle.

getSize

public Dimensions getSize()
Returns:
The size of the rectangle, which is guaranteed to have zero depth.

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 rectangle with equivalent position and size.

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.