objectdraw
Class Rectangular

java.lang.Object
  extended by objectdraw.Drawable
      extended by objectdraw.Drawable2D
          extended by objectdraw.Resizable2D
              extended by objectdraw.Rectangular
All Implemented Interfaces:
Serializable, Drawable2DInterface, DrawableInterface, Resizable2DInterface
Direct Known Subclasses:
Arc, Oval, Rect, RoundedRect

abstract class Rectangular
extends Resizable2D
implements Resizable2DInterface

Rectangular is an abstract class that can be specialized to a drawable two-dimensional object.

Version:
1.1.1 released February 2005 version 1.1 removed shape and replaced with origin, width, and height

Field Summary
protected  double height
          The rectangle's height.
protected  double width
          The rectangle's width.
protected  double x
          The upper left corner of the rectangle.
protected  double y
          The upper left corner of the rectangle.
 
Fields inherited from class objectdraw.Drawable
canvasContent, color, shown
 
Constructor Summary
Rectangular(double x, double y, double width, double height)
          Creates a new Rect object.
Rectangular(Location origin, double width, double height)
          Creates a new Rect object.
Rectangular(Location p0, Location p1)
          Creates a new Rect object.
 
Method Summary
(package private)  Bounds getBounds()
          Retrieves the bounding rectangle of the object.
 double getHeight()
          Get the height of a graphical object
 double getWidth()
          Get the width of a graphical object
(package private)  void setBounds(Bounds b)
           
 void setHeight(double height)
          Sets the height of the object's bounding rectangle
 void setSize(double width, double height)
          Sets the width and height of the rectangle bounding the object.
 void setWidth(double width)
          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, clearCanvasContent, getCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setCanvasContent, 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, getCanvas, getColor, hide, isHidden, move, moveTo, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show
 

Field Detail

height

protected double height
The rectangle's height.


width

protected double width
The rectangle's width.


x

protected double x
The upper left corner of the rectangle.


y

protected double y
The upper left corner of the rectangle.

Constructor Detail

Rectangular

public Rectangular(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.

Rectangular

public Rectangular(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.

Rectangular

public Rectangular(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

Bounds getBounds()
Retrieves the bounding rectangle of the object.

Specified by:
getBounds in class Drawable2D
Returns:
the bounding rectangle

getHeight

public double getHeight()
Description copied from interface: Drawable2DInterface
Get the height of a graphical object

Specified by:
getHeight in interface Drawable2DInterface
Specified by:
getHeight in class Drawable2D
Returns:
the height of the object's bounding rectangle

getWidth

public double getWidth()
Description copied from interface: Drawable2DInterface
Get the width of a graphical object

Specified by:
getWidth in interface Drawable2DInterface
Specified by:
getWidth in class Drawable2D
Returns:
the width of the object's bounding rectangle

setBounds

void setBounds(Bounds b)
Specified by:
setBounds in class Resizable2D

setHeight

public void setHeight(double height)
Description copied from interface: Resizable2DInterface
Sets the height of the object's bounding rectangle

Specified by:
setHeight in interface Resizable2DInterface
Specified by:
setHeight in class Resizable2D
Parameters:
height - the new height of the bounding rectangle

setSize

public void setSize(double width,
                    double height)
Description copied from interface: Resizable2DInterface
Sets the width and height of the rectangle bounding the object.

Specified by:
setSize in interface Resizable2DInterface
Specified by:
setSize in class Resizable2D
Parameters:
width - the new width of the bounding rectangle
height - the new height of the bounding rectangle

setWidth

public void setWidth(double width)
Description copied from interface: Resizable2DInterface
Sets the width of the object's bounding rectangle

Specified by:
setWidth in interface Resizable2DInterface
Specified by:
setWidth in class Resizable2D
Parameters:
width - the new width of the bounding rectangle