csa120.shape
Class Rectangle

java.lang.Object
  extended bycsa120.shape.Shape
      extended bycsa120.shape.FillableShape
          extended bycsa120.shape.Rectangle
All Implemented Interfaces:
Drawable, FillableShapeOrGroup, ShapeOrGroup
Direct Known Subclasses:
Square

public class Rectangle
extends FillableShape

A Rectangle is a subclass of a FillableShape. The 'location' point inherited from Shape will be interpreted as the center of the rectangle.


Field Summary
protected  int height
          The height of the rectangle, measured in pixels.
protected  int width
          The width of the rectangle, measured in pixels.
 
Fields inherited from class csa120.shape.FillableShape
fillColor, filled
 
Fields inherited from class csa120.shape.Shape
borderColor, borderThickness, depth, location
 
Constructor Summary
Rectangle(int w, int h)
          Constructor for objects of class Rectangle
 
Method Summary
 void draw(Graphics2D g)
          Draws the Rectangle on the given Graphics2D object.
 void draw(Graphics2D g, int deltaX, int deltaY)
          Draws the Rectangle on the given Graphics2D object, with additional offset as given.
 int getHeight()
          Returns current height of rectangle
 int getWidth()
          Returns current width of rectangle
 void setHeight(int newHeight)
          Sets height of rectangle
 void setWidth(int newWidth)
          Sets width of rectangle
 
Methods inherited from class csa120.shape.FillableShape
getFillColor, getFilled, setFillColor, setFillColor, setFilled
 
Methods inherited from class csa120.shape.Shape
getBorderColor, getBorderThickness, getDepth, getLocation, move, setBorderColor, setBorderColor, setBorderThickness, setDepth, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface csa120.shape.ShapeOrGroup
move, setBorderColor, setBorderColor, setBorderThickness, setDepth
 
Methods inherited from interface csa120.shape.Drawable
getDepth
 

Field Detail

width

protected int width
The width of the rectangle, measured in pixels.


height

protected int height
The height of the rectangle, measured in pixels.

Constructor Detail

Rectangle

public Rectangle(int w,
                 int h)
Constructor for objects of class Rectangle

Parameters:
w - original width
h - original height
Method Detail

setWidth

public void setWidth(int newWidth)
Sets width of rectangle

Parameters:
newWidth - the new value

getWidth

public int getWidth()
Returns current width of rectangle

Returns:
the width

setHeight

public void setHeight(int newHeight)
Sets height of rectangle

Parameters:
newHeight - the new value

getHeight

public int getHeight()
Returns current height of rectangle

Returns:
the height

draw

public void draw(Graphics2D g)
Draws the Rectangle on the given Graphics2D object.

Specified by:
draw in interface Drawable
Specified by:
draw in class Shape
Parameters:
g - the Graphics2D object upon which to draw

draw

public void draw(Graphics2D g,
                 int deltaX,
                 int deltaY)
Draws the Rectangle on the given Graphics2D object, with additional offset as given.

Specified by:
draw in interface Drawable
Specified by:
draw in class Shape
Parameters:
g - the Graphics2D object upon which to draw
deltaX - additional offset to be considered
deltaY - additional offest to be considered