pythagoras.i

## Class Rectangle

• ### Field Summary

Fields
Modifier and Type Field and Description
`int` `height`
The height of the rectangle.
`int` `width`
The width of the rectangle.
`int` `x`
The x-coordinate of the rectangle's upper left corner.
`int` `y`
The y-coordinate of the rectangle's upper left corner.
• ### Fields inherited from interface pythagoras.i.IRectangle

`OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP`
• ### Constructor Summary

Constructors
Constructor and Description
`Rectangle()`
Constructs a rectangle at (0,0) and with dimensions (0,0).
`Rectangle(IDimension d)`
Constructs a rectangle with upper-left corner at (0,0) and the supplied dimensions.
```Rectangle(int x, int y, int width, int height)```
Constructs a rectangle with the specified upper-left corner and dimensions.
`Rectangle(IPoint p)`
Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
```Rectangle(IPoint p, IDimension d)```
Constructs a rectangle with upper-left corner at the supplied point and with the supplied dimensions.
`Rectangle(IRectangle r)`
Constructs a rectangle with bounds equal to the supplied rectangle.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` ```add(int px, int py)```
Expands the bounds of this rectangle to contain the specified point.
`void` `add(IPoint p)`
Expands the bounds of this rectangle to contain the supplied point.
`void` `add(IRectangle r)`
Expands the bounds of this rectangle to contain the supplied rectangle.
`void` ```grow(int dx, int dy)```
Grows the bounds of this rectangle by the specified amount (i.e.
`int` `height()`
Returns the height of the framing rectangle.
`void` ```setBounds(int x, int y, int width, int height)```
Sets the bounds of this rectangle to the specified bounds.
`void` `setBounds(IRectangle r)`
Sets the bounds of this rectangle to those of the supplied rectangle.
`void` ```setLocation(int x, int y)```
Sets the upper-left corner of this rectangle to the specified point.
`void` `setLocation(IPoint p)`
Sets the upper-left corner of this rectangle to the supplied point.
`void` `setSize(IDimension d)`
Sets the size of this rectangle to the supplied dimensions.
`void` ```setSize(int width, int height)```
Sets the size of this rectangle to the specified dimensions.
`void` ```translate(int mx, int my)```
Translates the upper-left corner of this rectangle by the specified amount.
`int` `width()`
Returns the width of the framing rectangle.
`int` `x()`
Returns the x-coordinate of the upper-left corner of the framing rectangle.
`int` `y()`
Returns the y-coordinate of the upper-left corner of the framing rectangle.
• ### Methods inherited from class pythagoras.i.AbstractRectangle

`bounds, bounds, clone, contains, contains, contains, contains, equals, hashCode, intersection, intersection, intersects, intersects, isEmpty, location, location, maxX, maxY, minX, minY, outcode, outcode, size, size, toString, union`
• ### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### x

`public int x`
The x-coordinate of the rectangle's upper left corner.
• #### y

`public int y`
The y-coordinate of the rectangle's upper left corner.
• #### width

`public int width`
The width of the rectangle.
• #### height

`public int height`
The height of the rectangle.
• ### Constructor Detail

• #### Rectangle

`public Rectangle()`
Constructs a rectangle at (0,0) and with dimensions (0,0).
• #### Rectangle

`public Rectangle(IPoint p)`
Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
• #### Rectangle

`public Rectangle(IDimension d)`
Constructs a rectangle with upper-left corner at (0,0) and the supplied dimensions.
• #### Rectangle

```public Rectangle(IPoint p,
IDimension d)```
Constructs a rectangle with upper-left corner at the supplied point and with the supplied dimensions.
• #### Rectangle

```public Rectangle(int x,
int y,
int width,
int height)```
Constructs a rectangle with the specified upper-left corner and dimensions.
• #### Rectangle

`public Rectangle(IRectangle r)`
Constructs a rectangle with bounds equal to the supplied rectangle.
• ### Method Detail

• #### setLocation

```public void setLocation(int x,
int y)```
Sets the upper-left corner of this rectangle to the specified point.
• #### setLocation

`public void setLocation(IPoint p)`
Sets the upper-left corner of this rectangle to the supplied point.
• #### setSize

```public void setSize(int width,
int height)```
Sets the size of this rectangle to the specified dimensions.
• #### setSize

`public void setSize(IDimension d)`
Sets the size of this rectangle to the supplied dimensions.
• #### setBounds

```public void setBounds(int x,
int y,
int width,
int height)```
Sets the bounds of this rectangle to the specified bounds.
• #### setBounds

`public void setBounds(IRectangle r)`
Sets the bounds of this rectangle to those of the supplied rectangle.
• #### grow

```public void grow(int dx,
int dy)```
Grows the bounds of this rectangle by the specified amount (i.e. the upper-left corner moves by the specified amount in the negative x and y direction and the width and height grow by twice the specified amount).
• #### translate

```public void translate(int mx,
int my)```
Translates the upper-left corner of this rectangle by the specified amount.

```public void add(int px,
int py)```
Expands the bounds of this rectangle to contain the specified point.

`public void add(IPoint p)`
Expands the bounds of this rectangle to contain the supplied point.

`public void add(IRectangle r)`
Expands the bounds of this rectangle to contain the supplied rectangle.
• #### x

`public int x()`
Description copied from interface: `IRectangle`
Returns the x-coordinate of the upper-left corner of the framing rectangle.
Specified by:
`x` in interface `IRectangle`
• #### y

`public int y()`
Description copied from interface: `IRectangle`
Returns the y-coordinate of the upper-left corner of the framing rectangle.
Specified by:
`y` in interface `IRectangle`
• #### width

`public int width()`
Description copied from interface: `IRectangle`
Returns the width of the framing rectangle.
Specified by:
`width` in interface `IRectangle`
• #### height

`public int height()`
Description copied from interface: `IRectangle`
Returns the height of the framing rectangle.
Specified by:
`height` in interface `IRectangle`