objectdraw
Class Bounds

java.lang.Object
  extended by objectdraw.Bounds

 class Bounds
extends Object

Bounds is a non-drawable bounding rectangle in the real plane.

Version:
1.1.1 released February 2005

Constructor Summary
Bounds(double x, double y, double width, double height)
          Constructs a new Bounds object.
Bounds(Location location, double width, double height)
          Constructs a new Bounds object.
 
Method Summary
 boolean contains(Location point)
          Determines if a point is contained by the object.
 double getHeight()
          Retrieves the bounding rectangle's height.
 Location getLocation()
          Retrieves the location of the bounding rectangle's upper left corner.
 double getWidth()
          Retrieves the bounding rectangle's width.
 double getX()
          Retrieves the x coordinate of the bounding rectangle's upper left corner.
 double getY()
          Retrieves the y coordinate of the bounding rectangle's upper left corner.
 boolean intersects(Bounds b)
          Determines if another Bounds object intersects this one.
 void setDimensions(double width, double height)
          Sets the rectangle's width and height.
 void setHeight(double height)
          Sets the bounding rectangle's height.
 void setLocation(double x, double y)
          Sets a new location for the upper left corner of the bounding rectangle.
 void setLocation(Location point)
          Sets a new location for the upper left corner of the bounding rectangle.
 void setWidth(double width)
          Sets the bounding rectangle's width.
 Rectangle toRectangle()
          Retrieves a Rectangle representation of the object.
 String toString()
          Retrieves a string representation of the object.
 void translate(double dx, double dy)
          Translates the rectangle by the given increments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bounds

public Bounds(double x,
              double y,
              double width,
              double height)
Constructs a new Bounds object.

Parameters:
x - the x coordinate of the rectangle's left edge
y - the y coordinate of the rectangle's upper edge
width - the rectangle's width
height - the rectangle's height

Bounds

public Bounds(Location location,
              double width,
              double height)
Constructs a new Bounds object.

Parameters:
location - the upper left corner of the rectangle
width - the width of the rectangle
height - the height of the rectangle
Method Detail

contains

public boolean contains(Location point)
Determines if a point is contained by the object.

Parameters:
point - is the point to check
Returns:
true if point is contained in the object; false otherwise.

getHeight

public double getHeight()
Retrieves the bounding rectangle's height.

Returns:
bounding rectangle's height

getLocation

public Location getLocation()
Retrieves the location of the bounding rectangle's upper left corner.

Returns:
location of the bounding rectangle's upper left corner

getWidth

public double getWidth()
Retrieves the bounding rectangle's width.

Returns:
bounding rectangle's width

getX

public double getX()
Retrieves the x coordinate of the bounding rectangle's upper left corner.

Returns:
x-coordinate of the bounding rectangle's upper left corner

getY

public double getY()
Retrieves the y coordinate of the bounding rectangle's upper left corner.

Returns:
y-coordinate of the bounding rectangle's upper left corner

intersects

public boolean intersects(Bounds b)
Determines if another Bounds object intersects this one.

Parameters:
b - another bounding rectangle
Returns:
true if b intersects this one; false otherwise.

setDimensions

public void setDimensions(double width,
                          double height)
Sets the rectangle's width and height.

Parameters:
width - is the new width desired
height - is the new height desired

setHeight

public void setHeight(double height)
Sets the bounding rectangle's height.

Parameters:
height - the new height desired

setLocation

public void setLocation(double x,
                        double y)
Sets a new location for the upper left corner of the bounding rectangle.

Parameters:
x - the x coordinate of the new location.
y - the y coordinate of the new location.

setLocation

public void setLocation(Location point)
Sets a new location for the upper left corner of the bounding rectangle.

Parameters:
point - new location for the upper left corner of the bounding rectangle

setWidth

public void setWidth(double width)
Sets the bounding rectangle's width.

Parameters:
width - the new width desired

toRectangle

public Rectangle toRectangle()
Retrieves a Rectangle representation of the object.

Returns:
Rectangle representation of the object

toString

public String toString()
Retrieves a string representation of the object.

Overrides:
toString in class Object
Returns:
string representation of the object

translate

public void translate(double dx,
                      double dy)
Translates the rectangle by the given increments.

Parameters:
dx - is the amount to shift the rectangle in the x direction
dy - is the amount to shift the rectangle in the y direction