Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class Rectangle

    java.lang.Object
      Rectangle

All Implemented Interfaces:
  Shape

    public class Rectangle

extends Object
implements Shape

Constructor Summary
`Rectangle()` Constructs an empty rectangle.
`Rectangle(double x, double y, double width, double height)` Constructs a rectangle.

Method Summary
`void` | `draw()` Shows this shape on the canvas.
`double` | `getHeight()` Gets the height of this rectangle.
`double` | `getWidth()` Gets the width of this rectangle.
`double` | `getX()` Gets the leftmost x-position of this rectangle.
`double` | `getY()` Gets the topmost y-position of this rectangle.
`void` | `grow(double dw, double dh)` Resizes this rectangle both horizontally and vertically.
`void` | `paintShape(Graphics2D g2)` Paints the shape
`void` | `setDrawColor(Color newColor)` Sets the color for drawing the outline of this rectangle.
`void` | `setFillColor(Color newColor)` Sets the color for filling the interior of this rectangle.
`void` | `translate(double dx, double dy)` Moves this rectangle by a given amount.

Methods inherited from class
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Rectangle

    public Rectangle()

  Constructs an empty rectangle.

### Rectangle

    public Rectangle(double x,
                     double y,
                     double width,
                     double height)

  Constructs a rectangle.

  Parameters:
    `x` - the leftmost x-coordinate
    `y` - the topmost y-coordinate
    `width` - the width
    `height` - the height

Method Detail

### draw

    public void draw()

  Shows this shape on the canvas.

### getHeight

    public double getHeight()

  Gets the height of this rectangle.

  Specified by:
    `getHeight` in interface `Shape`
  Returns:
    the height

### getWidth

    public double getWidth()

  Gets the width of this rectangle.

  Specified by:
    `getWidth` in interface `Shape`
  Returns:
    the width

### getX

    public double getX()

  Gets the leftmost x-position of this rectangle.

  Specified by:
    `getX` in interface `Shape`
  Returns:
    the leftmost x-position

### getY

    public double getY()

  Gets the topmost y-position of this rectangle.

  Specified by:
    `getY` in interface `Shape`
  Returns:
    the topmost y-position

### grow

    public void grow(double dw,
                     double dh)

  Resizes this rectangle both horizontally and vertically.

  Parameters:
    `dw` - the amount by which to resize the width on each side
    `dw` - the amount by which to resize the height on each side

### paintShape

    public void paintShape(Graphics2D g2)

  Description copied from interface: `Shape`
  Paints the shape

  Specified by:
    `paintShape` in interface `Shape`
  Parameters:
    `g2` - the graphics object

### setDrawColor

    public void setDrawColor(Color newColor)

  Sets the color for drawing the outline of this rectangle.

  Parameters:
    `newColor` - the new draw color

### setFillColor

    public void setFillColor(Color newColor)

  Sets the color for filling the interior of this rectangle.

  Parameters:
    `newColor` - the new fill color

### translate

    public void translate(double dx,
                          double dy)

  Moves this rectangle by a given amount.

  Parameters:
    `dx` - the amount by which to move in x-direction
    `dy` - the amount by which to move in y-direction

Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD