objectdraw
Class Rect

java.lang.Object
  |
  +--objectdraw.Drawable
        |
        +--objectdraw.Drawable2D
              |
              +--objectdraw.Resizable2D
                    |
                    +--objectdraw.Rect
All Implemented Interfaces:
Drawable2DInterface, DrawableInterface, Resizable2DInterface, java.io.Serializable
Direct Known Subclasses:
FilledArc, FilledOval, FilledRect, FilledRoundedRect, FramedArc, FramedOval, FramedRect, FramedRoundedRect

public class Rect
extends Resizable2D

Rect is an implementation of a resizable, 2d, drawable rectangle object.

See Also:
Serialized Form

Field Summary
protected  double height
          The rectangle's height.
protected  Location origin
          The upper left corner of the rectangle.
protected  double width
          The rectangle's width.
 
Fields inherited from class objectdraw.Drawable
canvas, canvasContent, color, DEBUGGING, shown
 
Constructor Summary
Rect(double x, double y, double width, double height)
          Creates a new Rect object.
Rect(Location origin, double width, double height)
          Creates a new Rect object.
Rect(Location p0, Location p1)
          Creates a new Rect object.
 
Method Summary
 Bounds getBounds()
          Retrieves the bounding rectangle of the object.
 double getHeight()
          Gets the height of the object's bounding rectangle
 double getWidth()
          Gets the width of the object's bounding rectangle
 void setBounds(Bounds b)
          Sets the rectangle's bounding rectangle.
 void setHeight(double dist)
          Sets the height of the object's bounding rectangle
 void setWidth(double dist)
          Sets the width of the object's bounding rectangle
 
Methods inherited from class objectdraw.Resizable2D
move, moveTo
 
Methods inherited from class objectdraw.Drawable2D
contains, draw, getLocation, getX, getY, overlaps
 
Methods inherited from class objectdraw.Drawable
addToCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, setStateChanged, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface objectdraw.Drawable2DInterface
getLocation, getX, getY, overlaps
 
Methods inherited from interface objectdraw.DrawableInterface
addToCanvas, contains, draw, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show
 

Field Detail

origin

protected Location origin
The upper left corner of the rectangle.

width

protected double width
The rectangle's width.

height

protected double height
The rectangle's height.
Constructor Detail

Rect

public Rect(Location origin,
            double width,
            double height)
Creates a new Rect object.
Parameters:
origin - the upper left corner of the bounding rectangle.
width - the width of the bounding rectangle.
height - the height of the bounding rectangle.
c - the canvas in which the object is created.

Rect

public Rect(double x,
            double y,
            double width,
            double height)
Creates a new Rect object.
Parameters:
x - coordinate of the upper left corner of the bounding rectangle.
y - coordinate of the upper left corner of the bounding rectangle.
width - the width of the bounding rectangle.
height - the height of the bounding rectangle.
c - the canvas in which the object is created.

Rect

public Rect(Location p0,
            Location p1)
Creates a new Rect object.
Parameters:
p0 - endpoint of a diagonal of the rectangle.
p1 - other diagonal endpoint.
c - the canvas in which the object is created.
Method Detail

getBounds

public Bounds getBounds()
Retrieves the bounding rectangle of the object.
Returns:
the bounding rectangle

setBounds

public void setBounds(Bounds b)
Sets the rectangle's bounding rectangle.
Parameters:
b - the bounding rectangle

setWidth

public void setWidth(double dist)
Sets the width of the object's bounding rectangle
Parameters:
dist - the new width

setHeight

public void setHeight(double dist)
Sets the height of the object's bounding rectangle
Parameters:
dist - the new height

getWidth

public double getWidth()
Gets the width of the object's bounding rectangle

getHeight

public double getHeight()
Gets the height of the object's bounding rectangle
Overrides:
getHeight in class Drawable2D
Following copied from class: objectdraw.Drawable2D
Returns:
the height of the object's bounding rectangle