pythagoras.f

## Class Rectangle

• ### Field Summary

Fields
Modifier and Type Field and Description
`float` `height`
The height of the rectangle.
`float` `width`
The width of the rectangle.
`float` `x`
The x-coordinate of the rectangle's upper left corner.
`float` `y`
The y-coordinate of the rectangle's upper left corner.
• ### Fields inherited from interface pythagoras.f.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(float x, float y, float width, float height)```
Constructs a rectangle with the specified upper-left corner and dimensions.
`Rectangle(IDimension d)`
Constructs a rectangle with upper-left corner at (0,0) and the supplied dimensions.
`Rectangle(IRectangle r)`
Constructs a rectangle with bounds equal to the supplied rectangle.
`Rectangle(XY p)`
Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
```Rectangle(XY p, IDimension d)```
Constructs a rectangle with upper-left corner at the supplied point and with the supplied dimensions.
• ### Method Summary

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

`clone, contains, contains, equals, hashCode, intersection, intersection, intersects, intersectsLine, intersectsLine, location, location, outcode, outcode, pathIterator, pathIterator, size, size, toString, union`
• ### Methods inherited from class pythagoras.f.RectangularShape

`bounds, bounds, center, centerX, centerY, contains, contains, frame, frame, intersects, isEmpty, max, maxX, maxY, min, minX, minY, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal`
• ### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface pythagoras.f.IRectangularShape

`center, centerX, centerY, frame, frame, max, maxX, maxY, min, minX, minY`
• ### Methods inherited from interface pythagoras.f.IShape

`bounds, bounds, contains, contains, intersects, isEmpty`
• ### Field Detail

• #### x

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

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

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

`public float 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(XY 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(XY p,
IDimension d)```
Constructs a rectangle with upper-left corner at the supplied point and with the supplied dimensions.
• #### Rectangle

```public Rectangle(float x,
float y,
float width,
float 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(float x,
float y)```
Sets the upper-left corner of this rectangle to the specified point.
• #### setLocation

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

```public void setSize(float width,
float 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(float x,
float y,
float width,
float 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(float dx,
float 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(float mx,
float my)```
Translates the upper-left corner of this rectangle by the specified amount.

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

`public void add(XY 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 float x()`
Description copied from interface: `IRectangularShape`
Returns the x-coordinate of the upper-left corner of the framing rectangle.
Specified by:
`x` in interface `IRectangularShape`
• #### y

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

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

`public float height()`
Description copied from interface: `IRectangularShape`
Returns the height of the framing rectangle.
Specified by:
`height` in interface `IRectangularShape`
• #### setFrame

```public void setFrame(float x,
float y,
float width,
float height)```
Description copied from class: `RectangularShape`
Sets the location and size of the framing rectangle of this shape to the specified values.
Specified by:
`setFrame` in class `RectangularShape`