Microsoft.Xna.Framework
Class Rectangle

java.lang.Object
  extended by System.ValueType
      extended by Microsoft.Xna.Framework.Rectangle
All Implemented Interfaces:
IEquatable<Rectangle>

public final class Rectangle
extends ValueType
implements IEquatable<Rectangle>

Defines a rectangle.

Author:
Halofreak1990

Field Summary
static Rectangle Empty
          Returns a Rectangle with all of its values set to zero.
 int Height
          Specifies the height of the rectangle.
 int Width
          Specifies the width of the rectangle.
 int X
          Specifies the x-coordinate of the rectangle.
 int Y
          Specifies the y-coordinate of the rectangle.
 
Constructor Summary
Rectangle()
          Initializes a new instance of Rectangle.
Rectangle(int x, int y, int width, int height)
          Initializes a new instance of Rectangle.
 
Method Summary
 int Bottom()
          Returns the y-coordinate of the bottom of the rectangle.
 Point Center()
          Gets the Point that specifies the center of the rectangle.
 boolean Contains(int x, int y)
          Determines whether this Rectangle contains a specified point represented by its x- and y-coordinates.
 boolean Contains(Point value)
          Determines whether this Rectangle contains a specified Point.
 void Contains(Point value, boolean result)
          Determines whether this Rectangle contains a specified Point.
 boolean Contains(Rectangle value)
          Determines whether this Rectangle entirely contains a specified Rectangle.
 void Contains(Rectangle value, boolean result)
          Determines whether this Rectangle entirely contains a specified Rectangle.
 boolean equals(java.lang.Object obj)
          Determines whether the specified Object is equal to the current instance.
 boolean Equals(Rectangle other)
          Determines whether the specified Object is equal to the Rectangle.
 int GetHashCode()
          Gets the hash code for this object.
 Point getLocation()
          Gets the upper-left value of the Rectangle.
 void Inflate(int horizontalAmount, int verticalAmount)
          Pushes the edges of the Rectangle out by the horizontal and vertical values specified.
static Rectangle Intersect(Rectangle value1, Rectangle value2)
          Creates a Rectangle defining the area where one rectangle overlaps with another rectangle.
static void Intersect(Rectangle value1, Rectangle value2, Rectangle result)
          Creates a Rectangle defining the area where one rectangle overlaps with another rectangle.
 boolean Intersects(Rectangle value)
          Determines whether a specified Rectangle intersects with this Rectangle.
 void Intersects(Rectangle value, boolean result)
          Determines whether a specified Rectangle intersects with this Rectangle.
 boolean IsEmpty()
          Gets a value that indicates whether the Rectangle is empty.
 int Left()
          Returns the x-coordinate of the left side of the rectangle.
 void Offset(int offsetX, int offsetY)
          Changes the position of the Rectangle.
 void Offset(Point amount)
          Changes the position of the Rectangle.
 int Right()
          Returns the x-coordinate of the right side of the rectangle.
 void setLocation(Point newLocation)
          Sets the upper-left value of the Rectangle.
 int Top()
          Returns the y-coordinate of the top of the rectangle.
 java.lang.String toString()
          Retrieves a string representation of the current object.
static Rectangle Union(Rectangle value1, Rectangle value2)
          Creates a new Rectangle that exactly contains two other rectangles.
static void Union(Rectangle value1, Rectangle value2, Rectangle result)
          Creates a new Rectangle that exactly contains two other rectangles.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Empty

public static final Rectangle Empty
Returns a Rectangle with all of its values set to zero.


Height

public int Height
Specifies the height of the rectangle.


Width

public int Width
Specifies the width of the rectangle.


X

public int X
Specifies the x-coordinate of the rectangle.


Y

public int Y
Specifies the y-coordinate of the rectangle.

Constructor Detail

Rectangle

public Rectangle(int x,
                 int y,
                 int width,
                 int height)
Initializes a new instance of Rectangle.

Parameters:
x - The x-coordinate of the rectangle.
y - The y-coordinate of the rectangle.
width - Width of the rectangle.
height - Height of the rectangle.

Rectangle

public Rectangle()
Initializes a new instance of Rectangle.

Method Detail

Bottom

public int Bottom()
Returns the y-coordinate of the bottom of the rectangle.


Center

public Point Center()
Gets the Point that specifies the center of the rectangle.


IsEmpty

public boolean IsEmpty()
Gets a value that indicates whether the Rectangle is empty.


Left

public int Left()
Returns the x-coordinate of the left side of the rectangle.


getLocation

public Point getLocation()
Gets the upper-left value of the Rectangle.


setLocation

public void setLocation(Point newLocation)
Sets the upper-left value of the Rectangle.

Parameters:
newLocation - The new location of the upper-left value of the Rectangle.

Right

public int Right()
Returns the x-coordinate of the right side of the rectangle.


Top

public int Top()
Returns the y-coordinate of the top of the rectangle.


Contains

public boolean Contains(Point value)
Determines whether this Rectangle contains a specified Point.

Parameters:
value - The Point to evaluate.

Contains

public boolean Contains(Rectangle value)
Determines whether this Rectangle entirely contains a specified Rectangle.

Parameters:
value - The Rectangle to evaluate.

Contains

public void Contains(Rectangle value,
                     boolean result)
Determines whether this Rectangle entirely contains a specified Rectangle.

Parameters:
value - The Rectangle to evaluate.
result - [OutAttribute] On exit, is true if this Rectangle entirely contains the specified Rectangle, or false if not.

Contains

public boolean Contains(int x,
                        int y)
Determines whether this Rectangle contains a specified point represented by its x- and y-coordinates.

Parameters:
x - The x-coordinate of the specified point.
y - The y-coordinate of the specified point.

Contains

public void Contains(Point value,
                     boolean result)
Determines whether this Rectangle contains a specified Point.

Parameters:
value - The Point to evaluate.
result - [OutAttribute] true if the specified Point is contained within this Rectangle; false otherwise.

equals

public boolean equals(java.lang.Object obj)
Determines whether the specified Object is equal to the current instance.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to compare with the current Ray.

Equals

public boolean Equals(Rectangle other)
Determines whether the specified Object is equal to the Rectangle.

Specified by:
Equals in interface IEquatable<Rectangle>
Parameters:
other - The Object to compare with the current Rectangle.
Returns:
true if the current object is equal to the other parameter; otherwise, false.

GetHashCode

public int GetHashCode()
Gets the hash code for this object.


Inflate

public void Inflate(int horizontalAmount,
                    int verticalAmount)
Pushes the edges of the Rectangle out by the horizontal and vertical values specified.

Parameters:
horizontalAmount - Value to push the sides out by.
verticalAmount - Value to push the top and bottom out by.

Intersect

public static Rectangle Intersect(Rectangle value1,
                                  Rectangle value2)
Creates a Rectangle defining the area where one rectangle overlaps with another rectangle.

Parameters:
value1 - The first Rectangle to compare.
value2 - The second Rectangle to compare.
Returns:

Intersect

public static void Intersect(Rectangle value1,
                             Rectangle value2,
                             Rectangle result)
Creates a Rectangle defining the area where one rectangle overlaps with another rectangle.

Parameters:
value1 - The first Rectangle to compare.
value2 - The second Rectangle to compare.
result - [OutAttribute] The area where the two first parameters overlap.

Intersects

public boolean Intersects(Rectangle value)
Determines whether a specified Rectangle intersects with this Rectangle.

Parameters:
value - The Rectangle to evaluate.
Returns:
true if the specified Rectangle intersects with this one; false otherwise.

Intersects

public void Intersects(Rectangle value,
                       boolean result)
Determines whether a specified Rectangle intersects with this Rectangle.

Parameters:
value - The Rectangle to evaluate
result - [OutAttribute] true if the specified Rectangle intersects with this one; false otherwise.

Offset

public void Offset(Point amount)
Changes the position of the Rectangle.

Parameters:
amount - The values to adjust the position of the Rectangle by.

Offset

public void Offset(int offsetX,
                   int offsetY)
Changes the position of the Rectangle.

Parameters:
offsetX - Change in the x-position.
offsetY - Change in the y-position.

toString

public java.lang.String toString()
Retrieves a string representation of the current object.

Overrides:
toString in class java.lang.Object
Returns:
String that represents the object.

Union

public static Rectangle Union(Rectangle value1,
                              Rectangle value2)
Creates a new Rectangle that exactly contains two other rectangles.

Parameters:
value1 - The first Rectangle to contain.
value2 - The second Rectangle to contain.

Union

public static void Union(Rectangle value1,
                         Rectangle value2,
                         Rectangle result)
Creates a new Rectangle that exactly contains two other rectangles.

Parameters:
value1 - The first Rectangle to contain.
value2 - The second Rectangle to contain.
result - [OutAttribute] The Rectangle that must be the union of the first two rectangles.