com.aspose.imaging
Class Rectangle

java.lang.Object
  extended by 
      extended by com.aspose.imaging.Rectangle

public class Rectangle
extends

Stores a set of four integers that represent the location and size of a rectangle.


Constructor Summary
Rectangle()
           
Rectangle(int x, int y, int width, int height)
           Initializes a new instance of the Rectangle structure with the specified location and size.
Rectangle(Point location, Size size)
           Initializes a new instance of the Rectangle structure with the specified location and size.
 
Method Summary
static Rectangle ceiling(RectangleF value)
           Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.
 java.lang.Object clone()
           
 Rectangle Clone()
           
 void CloneTo(Rectangle that)
           
 boolean contains(int x, int y)
           Determines if the specified point is contained within this Rectangle structure.
 boolean contains(Point point)
           Determines if the specified point is contained within this Rectangle structure.
 boolean contains(Rectangle rect)
           Determines if the rectangular region represented by rect is entirely contained within this Rectangle structure.
 boolean equals(java.lang.Object obj)
           Tests whether obj is a Rectangle structure with the same location and size of this Rectangle structure.
static boolean equals(Rectangle obj1, Rectangle obj2)
           
static Rectangle fromLeftTopRightBottom(int left, int top, int right, int bottom)
           Creates a Rectangle structure with the specified edge locations.
static Rectangle fromPoints(Point point1, Point point2)
           Creates a new Rectangle froms two points specified.
 int getBottom()
           Gets the y-coordinate that is the sum of the Rectangle.Y and Rectangle.Height property values of this Rectangle structure.
static Rectangle getEmpty()
           Gets a new instance of the Rectangle structure that has Rectangle.X, Rectangle.Y, Rectangle.Width and Rectangle.Height values set to zero.
 int getHeight()
           Gets the height of this Rectangle structure.
 int getLeft()
           Gets the x-coordinate of the left edge of this Rectangle structure.
 Point getLocation()
           Gets the coordinates of the upper-left corner of this Rectangle structure.
 int getRight()
           Gets the x-coordinate that is the sum of Rectangle.X and Rectangle.Width property values of this Rectangle structure.
 Size getSize()
           Gets the size of this Rectangle.
 int getTop()
           Gets the y-coordinate of the top edge of this Rectangle structure.
 int getWidth()
           Gets the width of this Rectangle structure.
 int getX()
           Gets the x-coordinate of the upper-left corner of this Rectangle structure.
 int getY()
           Gets the y-coordinate of the upper-left corner of this Rectangle structure.
 int hashCode()
           Returns the hash code for this Rectangle structure.
 void inflate(int width, int height)
           Inflates this Rectangle by the specified amount.
static Rectangle inflate(Rectangle rect, int x, int y)
           Creates and returns an inflated copy of the specified Rectangle structure.
 void inflate(Size size)
           Inflates this Rectangle by the specified amount.
 void intersect(Rectangle rect)
           Replaces this Rectangle with the intersection of itself and the specified Rectangle.
static Rectangle intersect(Rectangle a, Rectangle b)
           Returns a third Rectangle structure that represents the intersection of two other Rectangle structures.
 boolean intersectsWith(Rectangle rect)
           Determines if this rectangle intersects with rect.
 boolean isEmpty()
           Gets a value indicating whether all numeric properties of this Rectangle have values of zero.
 void normalize()
           Normalizes the rectangle by making it's width and height positive, left less than right and top less than bottom.
 void offset(int x, int y)
           Adjusts the location of this rectangle by the specified amount.
 void offset(Point pos)
           Adjusts the location of this rectangle by the specified amount.
static boolean op_Equality(Rectangle left, Rectangle right)
           Tests whether two Rectangle structures have equal location and size.
static boolean op_Inequality(Rectangle left, Rectangle right)
           Tests whether two Rectangle structures differ in location or size.
static Rectangle round(RectangleF value)
           Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.
 void setBottom(int value)
           Sets the y-coordinate that is the sum of the Rectangle.Y and Rectangle.Height property values of this Rectangle structure.
 void setHeight(int value)
           Sets the height of this Rectangle structure.
 void setLeft(int value)
           Sets the x-coordinate of the left edge of this Rectangle structure.
 void setLocation(Point value)
           Sets the coordinates of the upper-left corner of this Rectangle structure.
 void setRight(int value)
           Sets the x-coordinate that is the sum of Rectangle.X and Rectangle.Width property values of this Rectangle structure.
 void setSize(Size value)
           Sets the size of this Rectangle.
 void setTop(int value)
           Sets the y-coordinate of the top edge of this Rectangle structure.
 void setWidth(int value)
           Sets the width of this Rectangle structure.
 void setX(int value)
           Sets the x-coordinate of the upper-left corner of this Rectangle structure.
 void setY(int value)
           Sets the y-coordinate of the upper-left corner of this Rectangle structure.
 java.lang.String toString()
           Converts the attributes of this Rectangle to a human-readable string.
static Rectangle truncate(RectangleF value)
           Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.
static Rectangle union(Rectangle a, Rectangle b)
           Gets a Rectangle structure that contains the union of two Rectangle structures.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rectangle

public Rectangle()

Rectangle

public Rectangle(int x,
                 int y,
                 int width,
                 int height)

Initializes a new instance of the Rectangle structure with the specified location and size.

Parameters:
x - The x-coordinate of the upper-left corner of the rectangle.
y - The y-coordinate of the upper-left corner of the rectangle.
width - The width of the rectangle.
height - The height of the rectangle.

Rectangle

public Rectangle(Point location,
                 Size size)

Initializes a new instance of the Rectangle structure with the specified location and size.

Parameters:
location - A Point that represents the upper-left corner of the rectangular region.
size - A Size that represents the width and height of the rectangular region.
Method Detail

ceiling

public static Rectangle ceiling(RectangleF value)

Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.

Parameters:
value - The RectangleF structure to be converted.
Returns:
Returns a Rectangle.

clone

public java.lang.Object clone()

Clone

public Rectangle Clone()

CloneTo

public void CloneTo(Rectangle that)

contains

public boolean contains(int x,
                        int y)

Determines if the specified point is contained within this Rectangle structure.

Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
This method returns true if the point defined by x and y is contained within this Rectangle structure; otherwise false.

contains

public boolean contains(Point point)

Determines if the specified point is contained within this Rectangle structure.

Parameters:
point - The Point to test.
Returns:
This method returns true if the point represented by point is contained within this Rectangle structure; otherwise false.

contains

public boolean contains(Rectangle rect)

Determines if the rectangular region represented by rect is entirely contained within this Rectangle structure.

Parameters:
rect - The Rectangle to test.
Returns:
This method returns true if the rectangular region represented by rect is entirely contained within this Rectangle structure; otherwise false.

equals

public boolean equals(java.lang.Object obj)

Tests whether obj is a Rectangle structure with the same location and size of this Rectangle structure.

Parameters:
obj - The System.Object to test.
Returns:
This method returns true if obj is a Rectangle structure and its Rectangle.X, Rectangle.Y, Rectangle.Width, and Rectangle.Height properties are equal to the corresponding properties of this Rectangle structure; otherwise, false.

equals

public static boolean equals(Rectangle obj1,
                             Rectangle obj2)

fromLeftTopRightBottom

public static Rectangle fromLeftTopRightBottom(int left,
                                               int top,
                                               int right,
                                               int bottom)

Creates a Rectangle structure with the specified edge locations.

Parameters:
left - The x-coordinate of the upper-left corner of this Rectangle structure.
top - The y-coordinate of the upper-left corner of this Rectangle structure.
right - The x-coordinate of the lower-right corner of this Rectangle structure.
bottom - The y-coordinate of the lower-right corner of this Rectangle structure.
Returns:
The new Rectangle that this method creates.

fromPoints

public static Rectangle fromPoints(Point point1,
                                   Point point2)

Creates a new Rectangle froms two points specified. Two verticles of the created Rectangle will be equal to the passed point1 and point2. These would be typically the opposite vertices.

Parameters:
point1 - The first Point for the new rectangle.
point2 - The second Point for the new rectangle.
Returns:
A newly created Rectangle.

getBottom

public int getBottom()

Gets the y-coordinate that is the sum of the Rectangle.Y and Rectangle.Height property values of this Rectangle structure.

Value: The y-coordinate that is the sum of Rectangle.Y and Rectangle.Height of this Rectangle.


getEmpty

public static Rectangle getEmpty()

Gets a new instance of the Rectangle structure that has Rectangle.X, Rectangle.Y, Rectangle.Width and Rectangle.Height values set to zero.


getHeight

public int getHeight()

Gets the height of this Rectangle structure.

Returns:
The height of this Rectangle structure.

getLeft

public int getLeft()

Gets the x-coordinate of the left edge of this Rectangle structure.

Value: The x-coordinate of the left edge of this Rectangle structure.


getLocation

public Point getLocation()

Gets the coordinates of the upper-left corner of this Rectangle structure.

Value: A Point that represents the upper-left corner of this Rectangle structure.


getRight

public int getRight()

Gets the x-coordinate that is the sum of Rectangle.X and Rectangle.Width property values of this Rectangle structure.

Value: The x-coordinate that is the sum of Rectangle.X and Rectangle.Width of this Rectangle.


getSize

public Size getSize()

Gets the size of this Rectangle.

Value: A Size that represents the width and height of this Rectangle structure.


getTop

public int getTop()

Gets the y-coordinate of the top edge of this Rectangle structure.

Value: The y-coordinate of the top edge of this Rectangle structure.


getWidth

public int getWidth()

Gets the width of this Rectangle structure.

Returns:
The width of this Rectangle structure.

getX

public int getX()

Gets the x-coordinate of the upper-left corner of this Rectangle structure.

Value: The x-coordinate of the upper-left corner of this Rectangle structure.


getY

public int getY()

Gets the y-coordinate of the upper-left corner of this Rectangle structure.

Value: The y-coordinate of the upper-left corner of this Rectangle structure.


hashCode

public int hashCode()

Returns the hash code for this Rectangle structure.

Returns:
An integer that represents the hash code for this rectangle.

inflate

public void inflate(int width,
                    int height)

Inflates this Rectangle by the specified amount.

Parameters:
width - The amount to inflate this Rectangle horizontally.
height - The amount to inflate this Rectangle vertically.

inflate

public static Rectangle inflate(Rectangle rect,
                                int x,
                                int y)

Creates and returns an inflated copy of the specified Rectangle structure. The copy is inflated by the specified amount. The original Rectangle structure remains unmodified.

Parameters:
rect - The Rectangle with which to start. This rectangle is not modified.
x - The amount to inflate this Rectangle horizontally.
y - The amount to inflate this Rectangle vertically.
Returns:
The inflated Rectangle.

inflate

public void inflate(Size size)

Inflates this Rectangle by the specified amount.

Parameters:
size - The amount to inflate this rectangle.

intersect

public void intersect(Rectangle rect)

Replaces this Rectangle with the intersection of itself and the specified Rectangle.

Parameters:
rect - The Rectangle with which to intersect.

intersect

public static Rectangle intersect(Rectangle a,
                                  Rectangle b)

Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.

Parameters:
a - A first rectangle to intersect.
b - A second rectangle to intersect.
Returns:
A Rectangle that represents the intersection of a and b.

intersectsWith

public boolean intersectsWith(Rectangle rect)

Determines if this rectangle intersects with rect.

Parameters:
rect - The rectangle to test.
Returns:
This method returns true if there is any intersection, otherwise false.

isEmpty

public boolean isEmpty()

Gets a value indicating whether all numeric properties of this Rectangle have values of zero.

Value: This property returns true if the Rectangle.Width, Rectangle.Height, Rectangle.X, and Rectangle.Y properties of this Rectangle all have values of zero; otherwise, false.


normalize

public void normalize()

Normalizes the rectangle by making it's width and height positive, left less than right and top less than bottom.


offset

public void offset(int x,
                   int y)

Adjusts the location of this rectangle by the specified amount.

Parameters:
x - The horizontal offset.
y - The vertical offset.

offset

public void offset(Point pos)

Adjusts the location of this rectangle by the specified amount.

Parameters:
pos - Amount to offset the location.

op_Equality

public static boolean op_Equality(Rectangle left,
                                  Rectangle right)

Tests whether two Rectangle structures have equal location and size.

Parameters:
left - The Rectangle structure that is to the left of the equality operator.
right - The Rectangle structure that is to the right of the equality operator.
Returns:
This operator returns true if the two Rectangle structures have equal Rectangle.X, Rectangle.Y, Rectangle.Width, and Rectangle.Height properties.

op_Inequality

public static boolean op_Inequality(Rectangle left,
                                    Rectangle right)

Tests whether two Rectangle structures differ in location or size.

Parameters:
left - The Rectangle structure that is to the left of the inequality operator.
right - The Rectangle structure that is to the right of the inequality operator.
Returns:
This operator returns true if any of the Rectangle.X, Rectangle.Y, Rectangle.Width or Rectangle.Height properties of the two Rectangle structures are unequal; otherwise false.

round

public static Rectangle round(RectangleF value)

Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.

Parameters:
value - The RectangleF to be converted.
Returns:
A new Rectangle.

setBottom

public void setBottom(int value)

Sets the y-coordinate that is the sum of the Rectangle.Y and Rectangle.Height property values of this Rectangle structure.

Value: The y-coordinate that is the sum of Rectangle.Y and Rectangle.Height of this Rectangle.


setHeight

public void setHeight(int value)

Sets the height of this Rectangle structure.


setLeft

public void setLeft(int value)

Sets the x-coordinate of the left edge of this Rectangle structure.

Value: The x-coordinate of the left edge of this Rectangle structure.


setLocation

public void setLocation(Point value)

Sets the coordinates of the upper-left corner of this Rectangle structure.

Value: A Point that represents the upper-left corner of this Rectangle structure.


setRight

public void setRight(int value)

Sets the x-coordinate that is the sum of Rectangle.X and Rectangle.Width property values of this Rectangle structure.

Value: The x-coordinate that is the sum of Rectangle.X and Rectangle.Width of this Rectangle.


setSize

public void setSize(Size value)

Sets the size of this Rectangle.

Value: A Size that represents the width and height of this Rectangle structure.


setTop

public void setTop(int value)

Sets the y-coordinate of the top edge of this Rectangle structure.

Value: The y-coordinate of the top edge of this Rectangle structure.


setWidth

public void setWidth(int value)

Sets the width of this Rectangle structure.


setX

public void setX(int value)

Sets the x-coordinate of the upper-left corner of this Rectangle structure.

Value: The x-coordinate of the upper-left corner of this Rectangle structure.


setY

public void setY(int value)

Sets the y-coordinate of the upper-left corner of this Rectangle structure.

Value: The y-coordinate of the upper-left corner of this Rectangle structure.


toString

public java.lang.String toString()

Converts the attributes of this Rectangle to a human-readable string.

Returns:
A string that contains the position, width, and height of this Rectangle structure.

truncate

public static Rectangle truncate(RectangleF value)

Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.

Parameters:
value - The RectangleF to be converted.
Returns:
A new Rectangle.

union

public static Rectangle union(Rectangle a,
                              Rectangle b)

Gets a Rectangle structure that contains the union of two Rectangle structures.

Parameters:
a - A first rectangle to union.
b - A second rectangle to union.
Returns:
A Rectangle structure that bounds the union of the two Rectangle structures.