pythagoras.d

## Class Rectangle

• ### Field Summary

Fields
Modifier and Type Field and Description
`double` `height`
The height of the rectangle.
`double` `width`
The width of the rectangle.
`double` `x`
The x-coordinate of the rectangle's upper left corner.
`double` `y`
The y-coordinate of the rectangle's upper left corner.
• ### Fields inherited from interface pythagoras.d.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(double x, double y, double width, double 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(double px, double 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(double dx, double dy)```
Grows the bounds of this rectangle by the specified amount (i.e.
`double` `height()`
Returns the height of the framing rectangle.
`void` ```setBounds(double x, double y, double width, double 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(double x, double y, double width, double height)```
Sets the location and size of the framing rectangle of this shape to the specified values.
`void` ```setLocation(double x, double 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(double width, double 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(double mx, double my)```
Translates the upper-left corner of this rectangle by the specified amount.
`double` `width()`
Returns the width of the framing rectangle.
`double` `x()`
Returns the x-coordinate of the upper-left corner of the framing rectangle.
`double` `y()`
Returns the y-coordinate of the upper-left corner of the framing rectangle.
• ### Methods inherited from class pythagoras.d.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.d.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.d.IRectangularShape

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

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

• #### x

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

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

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

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

```public void add(double px,
double 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 double 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 double 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 double width()`
Description copied from interface: `IRectangularShape`
Returns the width of the framing rectangle.
Specified by:
`width` in interface `IRectangularShape`
• #### height

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

```public void setFrame(double x,
double y,
double width,
double 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`