JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Member Functions | Static Public Member Functions
Rectangle< ValueType > Class Template Reference

Manages a rectangle and allows geometric operations to be performed on it. More...

List of all members.

Public Member Functions

 Rectangle () noexcept
 Creates a rectangle of zero size.
 Rectangle (const Rectangle &other) noexcept
 Creates a copy of another rectangle.
 Rectangle (const ValueType initialX, const ValueType initialY, const ValueType width, const ValueType height) noexcept
 Creates a rectangle with a given position and size.
 Rectangle (const ValueType width, const ValueType height) noexcept
 Creates a rectangle with a given size, and a position of (0, 0).
 Rectangle (const Point< ValueType > &corner1, const Point< ValueType > &corner2) noexcept
 Creates a Rectangle from the positions of two opposite corners.
Rectangleoperator= (const Rectangle &other) noexcept
 ~Rectangle () noexcept
 Destructor.
bool isEmpty () const noexcept
 Returns true if the rectangle's width and height are both zero or less.
ValueType getX () const noexcept
 Returns the x co-ordinate of the rectangle's left-hand-side.
ValueType getY () const noexcept
 Returns the y co-ordinate of the rectangle's top edge.
ValueType getWidth () const noexcept
 Returns the width of the rectangle.
ValueType getHeight () const noexcept
 Returns the height of the rectangle.
ValueType getRight () const noexcept
 Returns the x co-ordinate of the rectangle's right-hand-side.
ValueType getBottom () const noexcept
 Returns the y co-ordinate of the rectangle's bottom edge.
ValueType getCentreX () const noexcept
 Returns the x co-ordinate of the rectangle's centre.
ValueType getCentreY () const noexcept
 Returns the y co-ordinate of the rectangle's centre.
Point< ValueType > getCentre () const noexcept
 Returns the centre point of the rectangle.
ValueType getAspectRatio (const bool widthOverHeight=true) const noexcept
 Returns the aspect ratio of the rectangle's width / height.
const Point< ValueType > & getPosition () const noexcept
 Returns the rectangle's top-left position as a Point.
void setPosition (const Point< ValueType > &newPos) noexcept
 Changes the position of the rectangle's top-left corner (leaving its size unchanged).
void setPosition (const ValueType newX, const ValueType newY) noexcept
 Changes the position of the rectangle's top-left corner (leaving its size unchanged).
const Point< ValueType > & getTopLeft () const noexcept
 Returns the rectangle's top-left position as a Point.
Point< ValueType > getTopRight () const noexcept
 Returns the rectangle's top-right position as a Point.
Point< ValueType > getBottomLeft () const noexcept
 Returns the rectangle's bottom-left position as a Point.
Point< ValueType > getBottomRight () const noexcept
 Returns the rectangle's bottom-right position as a Point.
void setSize (const ValueType newWidth, const ValueType newHeight) noexcept
 Changes the rectangle's size, leaving the position of its top-left corner unchanged.
void setBounds (const ValueType newX, const ValueType newY, const ValueType newWidth, const ValueType newHeight) noexcept
 Changes all the rectangle's co-ordinates.
void setX (const ValueType newX) noexcept
 Changes the rectangle's X coordinate.
void setY (const ValueType newY) noexcept
 Changes the rectangle's Y coordinate.
void setWidth (const ValueType newWidth) noexcept
 Changes the rectangle's width.
void setHeight (const ValueType newHeight) noexcept
 Changes the rectangle's height.
Rectangle withX (const ValueType newX) const noexcept
 Returns a rectangle which has the same size and y-position as this one, but with a different x-position.
Rectangle withY (const ValueType newY) const noexcept
 Returns a rectangle which has the same size and x-position as this one, but with a different y-position.
Rectangle withPosition (const ValueType newX, const ValueType newY) const noexcept
 Returns a rectangle with the same size as this one, but a new position.
Rectangle withPosition (const Point< ValueType > &newPos) const noexcept
 Returns a rectangle with the same size as this one, but a new position.
Rectangle withZeroOrigin () const noexcept
 Returns a rectangle whose size is the same as this one, but whose top-left position is (0, 0).
Rectangle withWidth (const ValueType newWidth) const noexcept
 Returns a rectangle which has the same position and height as this one, but with a different width.
Rectangle withHeight (const ValueType newHeight) const noexcept
 Returns a rectangle which has the same position and width as this one, but with a different height.
Rectangle withSize (const ValueType newWidth, const ValueType newHeight) const noexcept
 Returns a rectangle with the same position as this one, but a new size.
void setLeft (const ValueType newLeft) noexcept
 Moves the x position, adjusting the width so that the right-hand edge remains in the same place.
Rectangle withLeft (const ValueType newLeft) const noexcept
 Returns a new rectangle with a different x position, but the same right-hand edge as this one.
void setTop (const ValueType newTop) noexcept
 Moves the y position, adjusting the height so that the bottom edge remains in the same place.
Rectangle withTop (const ValueType newTop) const noexcept
 Returns a new rectangle with a different y position, but the same bottom edge as this one.
void setRight (const ValueType newRight) noexcept
 Adjusts the width so that the right-hand edge of the rectangle has this new value.
Rectangle withRight (const ValueType newRight) const noexcept
 Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one.
void setBottom (const ValueType newBottom) noexcept
 Adjusts the height so that the bottom edge of the rectangle has this new value.
Rectangle withBottom (const ValueType newBottom) const noexcept
 Returns a new rectangle with a different bottom edge position, but the same top edge as this one.
void translate (const ValueType deltaX, const ValueType deltaY) noexcept
 Moves the rectangle's position by adding amount to its x and y co-ordinates.
Rectangle translated (const ValueType deltaX, const ValueType deltaY) const noexcept
 Returns a rectangle which is the same as this one moved by a given amount.
Rectangle operator+ (const Point< ValueType > &deltaPosition) const noexcept
 Returns a rectangle which is the same as this one moved by a given amount.
Rectangleoperator+= (const Point< ValueType > &deltaPosition) noexcept
 Moves this rectangle by a given amount.
Rectangle operator- (const Point< ValueType > &deltaPosition) const noexcept
 Returns a rectangle which is the same as this one moved by a given amount.
Rectangleoperator-= (const Point< ValueType > &deltaPosition) noexcept
 Moves this rectangle by a given amount.
void expand (const ValueType deltaX, const ValueType deltaY) noexcept
 Expands the rectangle by a given amount.
Rectangle expanded (const ValueType deltaX, const ValueType deltaY) const noexcept
 Returns a rectangle that is larger than this one by a given amount.
void reduce (const ValueType deltaX, const ValueType deltaY) noexcept
 Shrinks the rectangle by a given amount.
Rectangle reduced (const ValueType deltaX, const ValueType deltaY) const noexcept
 Returns a rectangle that is smaller than this one by a given amount.
Rectangle removeFromTop (const ValueType amountToRemove) noexcept
 Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Rectangle removeFromLeft (const ValueType amountToRemove) noexcept
 Removes a strip from the left-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Rectangle removeFromRight (ValueType amountToRemove) noexcept
 Removes a strip from the right-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
Rectangle removeFromBottom (ValueType amountToRemove) noexcept
 Removes a strip from the bottom of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.
bool operator== (const Rectangle &other) const noexcept
 Returns true if the two rectangles are identical.
bool operator!= (const Rectangle &other) const noexcept
 Returns true if the two rectangles are not identical.
bool contains (const ValueType xCoord, const ValueType yCoord) const noexcept
 Returns true if this co-ordinate is inside the rectangle.
bool contains (const Point< ValueType > &point) const noexcept
 Returns true if this co-ordinate is inside the rectangle.
bool contains (const Rectangle &other) const noexcept
 Returns true if this other rectangle is completely inside this one.
Point< ValueType > getConstrainedPoint (const Point< ValueType > &point) const noexcept
 Returns the nearest point to the specified point that lies within this rectangle.
bool intersects (const Rectangle &other) const noexcept
 Returns true if any part of another rectangle overlaps this one.
Rectangle getIntersection (const Rectangle &other) const noexcept
 Returns the region that is the overlap between this and another rectangle.
bool intersectRectangle (ValueType &otherX, ValueType &otherY, ValueType &otherW, ValueType &otherH) const noexcept
 Clips a rectangle so that it lies only within this one.
Rectangle getUnion (const Rectangle &other) const noexcept
 Returns the smallest rectangle that contains both this one and the one passed-in.
bool enlargeIfAdjacent (const Rectangle &other) noexcept
 If this rectangle merged with another one results in a simple rectangle, this will set this rectangle to the result, and return true.
bool reduceIfPartlyContainedIn (const Rectangle &other) noexcept
 If after removing another rectangle from this one the result is a simple rectangle, this will set this object's bounds to be the result, and return true.
Rectangle transformed (const AffineTransform &transform) const noexcept
 Returns the smallest rectangle that can contain the shape created by applying a transform to this rectangle.
Rectangle< int > getSmallestIntegerContainer () const noexcept
 Returns the smallest integer-aligned rectangle that completely contains this one.
Rectangle< float > toFloat () const noexcept
 Casts this rectangle to a Rectangle<float>.
String toString () const
 Creates a string describing this rectangle.

Static Public Member Functions

static Rectangle leftTopRightBottom (const ValueType left, const ValueType top, const ValueType right, const ValueType bottom) noexcept
 Creates a Rectangle from a set of left, right, top, bottom coordinates.
static Rectangle findAreaContainingPoints (const Point< ValueType > *const points, const int numPoints) noexcept
 Returns the smallest Rectangle that can contain a set of points.
static bool intersectRectangles (ValueType &x1, ValueType &y1, ValueType &w1, ValueType &h1, const ValueType x2, const ValueType y2, const ValueType w2, const ValueType h2) noexcept
 Static utility to intersect two sets of rectangular co-ordinates.
static Rectangle fromString (const String &stringVersion)
 Parses a string containing a rectangle's details.

Detailed Description

template<typename ValueType>
class Rectangle< ValueType >

Manages a rectangle and allows geometric operations to be performed on it.

See also:
RectangleList, Path, Line, Point

Constructor & Destructor Documentation

template<typename ValueType>
Rectangle< ValueType >::Rectangle ( )
template<typename ValueType>
Rectangle< ValueType >::Rectangle ( const Rectangle< ValueType > &  other)

Creates a copy of another rectangle.

template<typename ValueType>
Rectangle< ValueType >::Rectangle ( const ValueType  initialX,
const ValueType  initialY,
const ValueType  width,
const ValueType  height 
)

Creates a rectangle with a given position and size.

template<typename ValueType>
Rectangle< ValueType >::Rectangle ( const ValueType  width,
const ValueType  height 
)

Creates a rectangle with a given size, and a position of (0, 0).

template<typename ValueType>
Rectangle< ValueType >::Rectangle ( const Point< ValueType > &  corner1,
const Point< ValueType > &  corner2 
)

Creates a Rectangle from the positions of two opposite corners.

template<typename ValueType>
Rectangle< ValueType >::~Rectangle ( )

Destructor.


Member Function Documentation

template<typename ValueType>
static Rectangle Rectangle< ValueType >::leftTopRightBottom ( const ValueType  left,
const ValueType  top,
const ValueType  right,
const ValueType  bottom 
) [static]

Creates a Rectangle from a set of left, right, top, bottom coordinates.

The right and bottom values must be larger than the left and top ones, or the resulting rectangle will have a negative size.

template<typename ValueType>
Rectangle& Rectangle< ValueType >::operator= ( const Rectangle< ValueType > &  other)
template<typename ValueType>
bool Rectangle< ValueType >::isEmpty ( ) const

Returns true if the rectangle's width and height are both zero or less.

Referenced by Rectangle< int >::getUnion().

template<typename ValueType>
ValueType Rectangle< ValueType >::getX ( ) const

Returns the x co-ordinate of the rectangle's left-hand-side.

Referenced by Path::addRectangle(), Path::addRoundedRectangle(), RectanglePlacement::appliedTo(), and Justification::appliedToRectangle().

template<typename ValueType>
ValueType Rectangle< ValueType >::getY ( ) const

Returns the y co-ordinate of the rectangle's top edge.

Referenced by Path::addRectangle(), and Path::addRoundedRectangle().

template<typename ValueType>
ValueType Rectangle< ValueType >::getWidth ( ) const

Returns the width of the rectangle.

Referenced by Path::addRectangle(), and Path::addRoundedRectangle().

template<typename ValueType>
ValueType Rectangle< ValueType >::getHeight ( ) const

Returns the height of the rectangle.

Referenced by Path::addRectangle(), and Path::addRoundedRectangle().

template<typename ValueType>
ValueType Rectangle< ValueType >::getRight ( ) const

Returns the x co-ordinate of the rectangle's right-hand-side.

Referenced by Rectangle< int >::enlargeIfAdjacent().

template<typename ValueType>
ValueType Rectangle< ValueType >::getBottom ( ) const

Returns the y co-ordinate of the rectangle's bottom edge.

Referenced by Rectangle< int >::enlargeIfAdjacent().

template<typename ValueType>
ValueType Rectangle< ValueType >::getCentreX ( ) const

Returns the x co-ordinate of the rectangle's centre.

template<typename ValueType>
ValueType Rectangle< ValueType >::getCentreY ( ) const

Returns the y co-ordinate of the rectangle's centre.

template<typename ValueType>
Point<ValueType> Rectangle< ValueType >::getCentre ( ) const

Returns the centre point of the rectangle.

template<typename ValueType>
ValueType Rectangle< ValueType >::getAspectRatio ( const bool  widthOverHeight = true) const

Returns the aspect ratio of the rectangle's width / height.

If widthOverHeight is true, it returns width / height; if widthOverHeight is false, it returns height / width.

template<typename ValueType>
const Point<ValueType>& Rectangle< ValueType >::getPosition ( ) const

Returns the rectangle's top-left position as a Point.

template<typename ValueType>
void Rectangle< ValueType >::setPosition ( const Point< ValueType > &  newPos)

Changes the position of the rectangle's top-left corner (leaving its size unchanged).

template<typename ValueType>
void Rectangle< ValueType >::setPosition ( const ValueType  newX,
const ValueType  newY 
)

Changes the position of the rectangle's top-left corner (leaving its size unchanged).

template<typename ValueType>
const Point<ValueType>& Rectangle< ValueType >::getTopLeft ( ) const

Returns the rectangle's top-left position as a Point.

template<typename ValueType>
Point<ValueType> Rectangle< ValueType >::getTopRight ( ) const

Returns the rectangle's top-right position as a Point.

template<typename ValueType>
Point<ValueType> Rectangle< ValueType >::getBottomLeft ( ) const

Returns the rectangle's bottom-left position as a Point.

template<typename ValueType>
Point<ValueType> Rectangle< ValueType >::getBottomRight ( ) const

Returns the rectangle's bottom-right position as a Point.

template<typename ValueType>
void Rectangle< ValueType >::setSize ( const ValueType  newWidth,
const ValueType  newHeight 
)

Changes the rectangle's size, leaving the position of its top-left corner unchanged.

template<typename ValueType>
void Rectangle< ValueType >::setBounds ( const ValueType  newX,
const ValueType  newY,
const ValueType  newWidth,
const ValueType  newHeight 
)

Changes all the rectangle's co-ordinates.

Referenced by Rectangle< int >::expand().

template<typename ValueType>
void Rectangle< ValueType >::setX ( const ValueType  newX)

Changes the rectangle's X coordinate.

template<typename ValueType>
void Rectangle< ValueType >::setY ( const ValueType  newY)

Changes the rectangle's Y coordinate.

template<typename ValueType>
void Rectangle< ValueType >::setWidth ( const ValueType  newWidth)

Changes the rectangle's width.

template<typename ValueType>
void Rectangle< ValueType >::setHeight ( const ValueType  newHeight)

Changes the rectangle's height.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withX ( const ValueType  newX) const

Returns a rectangle which has the same size and y-position as this one, but with a different x-position.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withY ( const ValueType  newY) const

Returns a rectangle which has the same size and x-position as this one, but with a different y-position.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withPosition ( const ValueType  newX,
const ValueType  newY 
) const

Returns a rectangle with the same size as this one, but a new position.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withPosition ( const Point< ValueType > &  newPos) const

Returns a rectangle with the same size as this one, but a new position.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withZeroOrigin ( ) const

Returns a rectangle whose size is the same as this one, but whose top-left position is (0, 0).

template<typename ValueType>
Rectangle Rectangle< ValueType >::withWidth ( const ValueType  newWidth) const

Returns a rectangle which has the same position and height as this one, but with a different width.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withHeight ( const ValueType  newHeight) const

Returns a rectangle which has the same position and width as this one, but with a different height.

template<typename ValueType>
Rectangle Rectangle< ValueType >::withSize ( const ValueType  newWidth,
const ValueType  newHeight 
) const

Returns a rectangle with the same position as this one, but a new size.

template<typename ValueType>
void Rectangle< ValueType >::setLeft ( const ValueType  newLeft)

Moves the x position, adjusting the width so that the right-hand edge remains in the same place.

If the x is moved to be on the right of the current right-hand edge, the width will be set to zero.

See also:
withLeft

Referenced by ResizableBorderComponent::Zone::resizeRectangleBy().

template<typename ValueType>
Rectangle Rectangle< ValueType >::withLeft ( const ValueType  newLeft) const

Returns a new rectangle with a different x position, but the same right-hand edge as this one.

If the new x is beyond the right of the current right-hand edge, the width will be set to zero.

See also:
setLeft
template<typename ValueType>
void Rectangle< ValueType >::setTop ( const ValueType  newTop)

Moves the y position, adjusting the height so that the bottom edge remains in the same place.

If the y is moved to be below the current bottom edge, the height will be set to zero.

See also:
withTop
template<typename ValueType>
Rectangle Rectangle< ValueType >::withTop ( const ValueType  newTop) const

Returns a new rectangle with a different y position, but the same bottom edge as this one.

If the new y is beyond the bottom of the current rectangle, the height will be set to zero.

See also:
setTop
template<typename ValueType>
void Rectangle< ValueType >::setRight ( const ValueType  newRight)

Adjusts the width so that the right-hand edge of the rectangle has this new value.

If the new right is below the current X value, the X will be pushed down to match it.

See also:
getRight, withRight
template<typename ValueType>
Rectangle Rectangle< ValueType >::withRight ( const ValueType  newRight) const

Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one.

If the new right edge is below the current left-hand edge, the width will be set to zero.

See also:
setRight
template<typename ValueType>
void Rectangle< ValueType >::setBottom ( const ValueType  newBottom)

Adjusts the height so that the bottom edge of the rectangle has this new value.

If the new bottom is lower than the current Y value, the Y will be pushed down to match it.

See also:
getBottom, withBottom
template<typename ValueType>
Rectangle Rectangle< ValueType >::withBottom ( const ValueType  newBottom) const

Returns a new rectangle with a different bottom edge position, but the same top edge as this one.

If the new y is beyond the bottom of the current rectangle, the height will be set to zero.

See also:
setBottom
template<typename ValueType>
void Rectangle< ValueType >::translate ( const ValueType  deltaX,
const ValueType  deltaY 
)

Moves the rectangle's position by adding amount to its x and y co-ordinates.

template<typename ValueType>
Rectangle Rectangle< ValueType >::translated ( const ValueType  deltaX,
const ValueType  deltaY 
) const

Returns a rectangle which is the same as this one moved by a given amount.

template<typename ValueType>
Rectangle Rectangle< ValueType >::operator+ ( const Point< ValueType > &  deltaPosition) const

Returns a rectangle which is the same as this one moved by a given amount.

template<typename ValueType>
Rectangle& Rectangle< ValueType >::operator+= ( const Point< ValueType > &  deltaPosition)

Moves this rectangle by a given amount.

template<typename ValueType>
Rectangle Rectangle< ValueType >::operator- ( const Point< ValueType > &  deltaPosition) const

Returns a rectangle which is the same as this one moved by a given amount.

template<typename ValueType>
Rectangle& Rectangle< ValueType >::operator-= ( const Point< ValueType > &  deltaPosition)

Moves this rectangle by a given amount.

template<typename ValueType>
void Rectangle< ValueType >::expand ( const ValueType  deltaX,
const ValueType  deltaY 
)

Expands the rectangle by a given amount.

Effectively, its new size is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2).

See also:
expanded, reduce, reduced

Referenced by Rectangle< int >::reduce().

template<typename ValueType>
Rectangle Rectangle< ValueType >::expanded ( const ValueType  deltaX,
const ValueType  deltaY 
) const

Returns a rectangle that is larger than this one by a given amount.

Effectively, the rectangle returned is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2).

See also:
expand, reduce, reduced

Referenced by Rectangle< int >::reduced().

template<typename ValueType>
void Rectangle< ValueType >::reduce ( const ValueType  deltaX,
const ValueType  deltaY 
)

Shrinks the rectangle by a given amount.

Effectively, its new size is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).

See also:
reduced, expand, expanded
template<typename ValueType>
Rectangle Rectangle< ValueType >::reduced ( const ValueType  deltaX,
const ValueType  deltaY 
) const

Returns a rectangle that is smaller than this one by a given amount.

Effectively, the rectangle returned is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).

See also:
reduce, expand, expanded
template<typename ValueType>
Rectangle Rectangle< ValueType >::removeFromTop ( const ValueType  amountToRemove)

Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 100, 300, 50) and leave this rectangle as (100, 150, 300, 250).

If amountToRemove is greater than the height of this rectangle, it'll be clipped to that value.

template<typename ValueType>
Rectangle Rectangle< ValueType >::removeFromLeft ( const ValueType  amountToRemove)

Removes a strip from the left-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 100, 50, 300) and leave this rectangle as (150, 100, 250, 300).

If amountToRemove is greater than the width of this rectangle, it'll be clipped to that value.

template<typename ValueType>
Rectangle Rectangle< ValueType >::removeFromRight ( ValueType  amountToRemove)

Removes a strip from the right-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (250, 100, 50, 300) and leave this rectangle as (100, 100, 250, 300).

If amountToRemove is greater than the width of this rectangle, it'll be clipped to that value.

template<typename ValueType>
Rectangle Rectangle< ValueType >::removeFromBottom ( ValueType  amountToRemove)

Removes a strip from the bottom of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 250, 300, 50) and leave this rectangle as (100, 100, 300, 250).

If amountToRemove is greater than the height of this rectangle, it'll be clipped to that value.

template<typename ValueType>
bool Rectangle< ValueType >::operator== ( const Rectangle< ValueType > &  other) const

Returns true if the two rectangles are identical.

template<typename ValueType>
bool Rectangle< ValueType >::operator!= ( const Rectangle< ValueType > &  other) const

Returns true if the two rectangles are not identical.

template<typename ValueType>
bool Rectangle< ValueType >::contains ( const ValueType  xCoord,
const ValueType  yCoord 
) const

Returns true if this co-ordinate is inside the rectangle.

template<typename ValueType>
bool Rectangle< ValueType >::contains ( const Point< ValueType > &  point) const

Returns true if this co-ordinate is inside the rectangle.

template<typename ValueType>
bool Rectangle< ValueType >::contains ( const Rectangle< ValueType > &  other) const

Returns true if this other rectangle is completely inside this one.

template<typename ValueType>
Point<ValueType> Rectangle< ValueType >::getConstrainedPoint ( const Point< ValueType > &  point) const

Returns the nearest point to the specified point that lies within this rectangle.

template<typename ValueType>
bool Rectangle< ValueType >::intersects ( const Rectangle< ValueType > &  other) const

Returns true if any part of another rectangle overlaps this one.

template<typename ValueType>
Rectangle Rectangle< ValueType >::getIntersection ( const Rectangle< ValueType > &  other) const

Returns the region that is the overlap between this and another rectangle.

If the two rectangles don't overlap, the rectangle returned will be empty.

template<typename ValueType>
bool Rectangle< ValueType >::intersectRectangle ( ValueType &  otherX,
ValueType &  otherY,
ValueType &  otherW,
ValueType &  otherH 
) const

Clips a rectangle so that it lies only within this one.

This is a non-static version of intersectRectangles(). Returns false if the two regions didn't overlap.

template<typename ValueType>
Rectangle Rectangle< ValueType >::getUnion ( const Rectangle< ValueType > &  other) const

Returns the smallest rectangle that contains both this one and the one passed-in.

If either this or the other rectangle are empty, they will not be counted as part of the resulting region.

template<typename ValueType>
bool Rectangle< ValueType >::enlargeIfAdjacent ( const Rectangle< ValueType > &  other)

If this rectangle merged with another one results in a simple rectangle, this will set this rectangle to the result, and return true.

Returns false and does nothing to this rectangle if the two rectangles don't overlap, or if they form a complex region.

template<typename ValueType>
bool Rectangle< ValueType >::reduceIfPartlyContainedIn ( const Rectangle< ValueType > &  other)

If after removing another rectangle from this one the result is a simple rectangle, this will set this object's bounds to be the result, and return true.

Returns false and does nothing to this rectangle if the two rectangles don't overlap, or if removing the other one would form a complex region.

template<typename ValueType>
Rectangle Rectangle< ValueType >::transformed ( const AffineTransform transform) const

Returns the smallest rectangle that can contain the shape created by applying a transform to this rectangle.

This should only be used on floating point rectangles.

template<typename ValueType>
Rectangle<int> Rectangle< ValueType >::getSmallestIntegerContainer ( ) const

Returns the smallest integer-aligned rectangle that completely contains this one.

This is only relevent for floating-point rectangles, of course.

See also:
toFloat()
template<typename ValueType>
static Rectangle Rectangle< ValueType >::findAreaContainingPoints ( const Point< ValueType > *const  points,
const int  numPoints 
) [static]

Returns the smallest Rectangle that can contain a set of points.

template<typename ValueType>
Rectangle<float> Rectangle< ValueType >::toFloat ( ) const

Casts this rectangle to a Rectangle<float>.

Obviously this is mainly useful for rectangles that use integer types.

See also:
getSmallestIntegerContainer
template<typename ValueType>
static bool Rectangle< ValueType >::intersectRectangles ( ValueType &  x1,
ValueType &  y1,
ValueType &  w1,
ValueType &  h1,
const ValueType  x2,
const ValueType  y2,
const ValueType  w2,
const ValueType  h2 
) [static]

Static utility to intersect two sets of rectangular co-ordinates.

Returns false if the two regions didn't overlap.

See also:
intersectRectangle
template<typename ValueType>
String Rectangle< ValueType >::toString ( ) const

Creates a string describing this rectangle.

The string will be of the form "x y width height", e.g. "100 100 400 200".

Coupled with the fromString() method, this is very handy for things like storing rectangles (particularly component positions) in XML attributes.

See also:
fromString
template<typename ValueType>
static Rectangle Rectangle< ValueType >::fromString ( const String stringVersion) [static]

Parses a string containing a rectangle's details.

The string should contain 4 integer tokens, in the form "x y width height". They can be comma or whitespace separated.

This method is intended to go with the toString() method, to form an easy way of saving/loading rectangles as strings.

See also:
toString

The documentation for this class was generated from the following file: