Packages

 

com.aspose.cad

Class Rectangle



  • public class Rectangle
    extends com.aspose.ms.lang.Struct<Rectangle>

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

    • Constructor Summary

      Constructors 
      Constructor and Description
      Rectangle() 
      Rectangle(int x, int y, int width, int height)
      Initializes a new instance of the com.aspose.cad.Rectangle object with the specified location and size.
      Rectangle(Point location, Size size)
      Initializes a new instance of the com.aspose.cad.Rectangle object with the specified location and size.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static Rectangle ceiling(RectangleF value)
      Converts the specified com.aspose.cad.RectangleF object to a com.aspose.cad.Rectangle object by rounding the com.aspose.cad.RectangleF values to the next higher integer values.
      Object clone() 
      Rectangle Clone() 
      void CloneTo(Rectangle that) 
      boolean contains(int x, int y)
      Determines if the specified point is contained within this com.aspose.cad.Rectangle object.
      boolean contains(Point point)
      Determines if the specified point is contained within this com.aspose.cad.Rectangle object.
      boolean contains(Rectangle rect)
      Determines if the rectangular region represented by rect is entirely contained within this com.aspose.cad.Rectangle object.
      boolean equals(Object obj)
      Tests whether obj is a com.aspose.cad.Rectangle object with the same location and size of this com.aspose.cad.Rectangle object.
      static Rectangle fromLeftTopRightBottom(int left, int top, int right, int bottom)
      Creates a com.aspose.cad.Rectangle object with the specified edge locations.
      static Rectangle fromPoints(Point point1, Point point2)
      Creates a new Rectangle from two points specified.
      int getBottom()
      Gets the y-coordinate that is the sum of the com.aspose.cad.Rectangle.Y and com.aspose.cad.Rectangle.Height property values of this com.aspose.cad.Rectangle object.
      static Rectangle getEmpty()
      Gets a new instance of the rectangle object that has com.aspose.cad.Rectangle.X, com.aspose.cad.Rectangle.Y, com.aspose.cad.Rectangle.Width and com.aspose.cad.Rectangle.Height values set to zero.
      int getHeight()
      Gets the height of this com.aspose.cad.Rectangle object.
      int getLeft()
      Gets the x-coordinate of the left edge of this com.aspose.cad.Rectangle object.
      Point getLocation()
      Gets the coordinates of the upper-left corner of this com.aspose.cad.Rectangle object.
      int getRight()
      Gets the x-coordinate that is the sum of com.aspose.cad.Rectangle.X and com.aspose.cad.Rectangle.Width property values of this com.aspose.cad.Rectangle object.
      Size getSize()
      Gets or sets the size of this com.aspose.cad.Rectangle.
      int getTop()
      Gets the y-coordinate of the top edge of this com.aspose.cad.Rectangle object.
      int getWidth()
      Gets the width of this com.aspose.cad.Rectangle object.
      int getX()
      Gets the x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      int getY()
      Gets the y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      int hashCode()
      Returns the hash code for this com.aspose.cad.Rectangle object.
      void inflate(int width, int height)
      Inflates this com.aspose.cad.Rectangle by the specified amount.
      static Rectangle inflate(Rectangle rect, int x, int y)
      Creates and returns an inflated copy of the specified com.aspose.cad.Rectangle object.
      void inflate(Size size)
      Inflates this com.aspose.cad.Rectangle by the specified amount.
      void intersect(Rectangle rect)
      Replaces this com.aspose.cad.Rectangle with the intersection of itself and the specified com.aspose.cad.Rectangle.
      static Rectangle intersect(Rectangle a, Rectangle b)
      Returns a third com.aspose.cad.Rectangle object that represents the intersection of two other com.aspose.cad.Rectangle objects.
      boolean intersectsWith(Rectangle rect)
      Determines if this rectangle intersects with rect.
      boolean isEmpty()
      Gets a value indicating whether all numeric properties of this com.aspose.cad.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 com.aspose.cad.Rectangle objects have equal location and size.
      static boolean op_Inequality(Rectangle left, Rectangle right)
      Tests whether two com.aspose.cad.Rectangle objects differ in location or size.
      static Rectangle round(RectangleF value)
      Converts the specified com.aspose.cad.RectangleF to a com.aspose.cad.Rectangle by rounding the com.aspose.cad.RectangleF values to the nearest integer values.
      void setBottom(int value)
      Sets the y-coordinate that is the sum of the com.aspose.cad.Rectangle.Y and com.aspose.cad.Rectangle.Height property values of this com.aspose.cad.Rectangle object.
      void setHeight(int value)
      Sets the height of this com.aspose.cad.Rectangle object.
      void setLeft(int value)
      Sets the x-coordinate of the left edge of this com.aspose.cad.Rectangle object.
      void setLocation(Point value)
      Sets the coordinates of the upper-left corner of this com.aspose.cad.Rectangle object.
      void setRight(int value)
      Sets the x-coordinate that is the sum of com.aspose.cad.Rectangle.X and com.aspose.cad.Rectangle.Width property values of this com.aspose.cad.Rectangle object.
      void setSize(Size value)
      Sets the size of this com.aspose.cad.Rectangle.
      void setTop(int value)
      Sets the y-coordinate of the top edge of this com.aspose.cad.Rectangle object.
      void setWidth(int value)
      Sets the width of this com.aspose.cad.Rectangle object.
      void setX(int value)
      Sets the x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      void setY(int value)
      Sets the y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      String toString()
      Converts the attributes of this com.aspose.cad.Rectangle to a human-readable string.
      static Rectangle truncate(RectangleF value)
      Converts the specified com.aspose.cad.RectangleF to a com.aspose.cad.Rectangle by truncating the com.aspose.cad.RectangleF values.
      static Rectangle union(Rectangle a, Rectangle b)
      Gets a com.aspose.cad.Rectangle object that contains the union of two com.aspose.cad.Rectangle objects.
    • Constructor Detail

      • Rectangle

        public Rectangle()
      • Rectangle

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

        Initializes a new instance of the com.aspose.cad.Rectangle object 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 com.aspose.cad.Rectangle object with the specified location and size.

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

      • getEmpty

        public static Rectangle getEmpty()

        Gets a new instance of the rectangle object that has com.aspose.cad.Rectangle.X, com.aspose.cad.Rectangle.Y, com.aspose.cad.Rectangle.Width and com.aspose.cad.Rectangle.Height values set to zero.

        Returns:
        a new instance of the Rectangle
      • getLocation

        public Point getLocation()

        Gets the coordinates of the upper-left corner of this com.aspose.cad.Rectangle object.

        Returns:
        A com.aspose.imaging.Point that represents the upper-left corner of this com.aspose.cad.Rectangle object.
      • setLocation

        public void setLocation(Point value)

        Sets the coordinates of the upper-left corner of this com.aspose.cad.Rectangle object.

        Parameters:
        value - A com.aspose.cad.Point that represents the upper-left corner of this com.aspose.cad.Rectangle object.
      • getSize

        public Size getSize()

        Gets or sets the size of this com.aspose.cad.Rectangle.

        Returns:
        A com.aspose.cad.Size that represents the width and height of this com.aspose.cad.Rectangle object.
      • setSize

        public void setSize(Size value)

        Sets the size of this com.aspose.cad.Rectangle.

        Parameters:
        value - A com.aspose.cad.Size that represents the width and height of this com.aspose.cad.Rectangle object.
      • getX

        public int getX()

        Gets the x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.

        Returns:
        The x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      • setX

        public void setX(int value)

        Sets the x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      • getY

        public int getY()

        Gets the y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.

        Returns:
        The y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      • setY

        public void setY(int value)

        Sets the y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
      • getWidth

        public int getWidth()

        Gets the width of this com.aspose.cad.Rectangle object.

        Returns:
        The width of this com.aspose.cad.Rectangle object.
      • setWidth

        public void setWidth(int value)

        Sets the width of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The width
      • getHeight

        public int getHeight()

        Gets the height of this com.aspose.cad.Rectangle object.

        Returns:
        The height of this com.aspose.cad.Rectangle object.
      • setHeight

        public void setHeight(int value)

        Sets the height of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The height
      • getLeft

        public int getLeft()

        Gets the x-coordinate of the left edge of this com.aspose.cad.Rectangle object.

        Returns:
        The x-coordinate of the left edge of this com.aspose.cad.Rectangle object.
      • setLeft

        public void setLeft(int value)

        Sets the x-coordinate of the left edge of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The x-coordinate of the left edge of this com.aspose.cad.Rectangle object.
      • getTop

        public int getTop()

        Gets the y-coordinate of the top edge of this com.aspose.cad.Rectangle object.

        Returns:
        The y-coordinate of the top edge of this com.aspose.cad.Rectangle object.
      • setTop

        public void setTop(int value)

        Sets the y-coordinate of the top edge of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The y-coordinate of the top edge of this com.aspose.cad.Rectangle object.
      • getRight

        public int getRight()

        Gets the x-coordinate that is the sum of com.aspose.cad.Rectangle.X and com.aspose.cad.Rectangle.Width property values of this com.aspose.cad.Rectangle object.

        Returns:
        The x-coordinate that is the sum of com.aspose.cad.Rectangle.X and com.aspose.cad.Rectangle.Width of this com.aspose.cad.Rectangle.
      • setRight

        public void setRight(int value)

        Sets the x-coordinate that is the sum of com.aspose.cad.Rectangle.X and com.aspose.cad.Rectangle.Width property values of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The x-coordinate that is the sum of com.aspose.cad.Rectangle.X and com.aspose.cad.Rectangle.Width of this com.aspose.cad.Rectangle.
      • getBottom

        public int getBottom()

        Gets the y-coordinate that is the sum of the com.aspose.cad.Rectangle.Y and com.aspose.cad.Rectangle.Height property values of this com.aspose.cad.Rectangle object.

        Returns:
        The y-coordinate that is the sum of com.aspose.cad.Rectangle.Y and com.aspose.cad.Rectangle.Height of this com.aspose.cad.Rectangle.
      • setBottom

        public void setBottom(int value)

        Sets the y-coordinate that is the sum of the com.aspose.cad.Rectangle.Y and com.aspose.cad.Rectangle.Height property values of this com.aspose.cad.Rectangle object.

        Parameters:
        value - The y-coordinate that is the sum of com.aspose.cad.Rectangle.Y and com.aspose.cad.Rectangle.Height of this com.aspose.cad.Rectangle.
      • isEmpty

        public boolean isEmpty()

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

        Returns:
        This property returns true if the com.aspose.cad.Rectangle.Width, com.aspose.cad.Rectangle.Height, com.aspose.cad.Rectangle.X, and com.aspose.cad.Rectangle.Y properties of this com.aspose.cad.Rectangle all have values of zero; otherwise, false.
      • fromPoints

        public static Rectangle fromPoints(Point point1,
                                           Point point2)

        Creates a new Rectangle from two points specified. Two verticales 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.
      • ceiling

        public static Rectangle ceiling(RectangleF value)

        Converts the specified com.aspose.cad.RectangleF object to a com.aspose.cad.Rectangle object by rounding the com.aspose.cad.RectangleF values to the next higher integer values.

        Parameters:
        value - The com.aspose.cad.RectangleF object to be converted.
        Returns:
        Returns a com.aspose.cad.Rectangle.
      • truncate

        public static Rectangle truncate(RectangleF value)

        Converts the specified com.aspose.cad.RectangleF to a com.aspose.cad.Rectangle by truncating the com.aspose.cad.RectangleF values.

        Parameters:
        value - The com.aspose.cad.RectangleF to be converted.
        Returns:
        A new com.aspose.cad.Rectangle.
      • round

        public static Rectangle round(RectangleF value)

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

        Parameters:
        value - The com.aspose.cad.RectangleF to be converted.
        Returns:
        A new com.aspose.cad.Rectangle.
      • inflate

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

        Creates and returns an inflated copy of the specified com.aspose.cad.Rectangle object. The copy is inflated by the specified amount. The original com.aspose.cad.Rectangle object remains unmodified.

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

        public static Rectangle intersect(Rectangle a,
                                          Rectangle b)

        Returns a third com.aspose.cad.Rectangle object that represents the intersection of two other com.aspose.cad.Rectangle objects. If there is no intersection, an empty com.aspose.cad.Rectangle is returned.

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

        public static Rectangle union(Rectangle a,
                                      Rectangle b)

        Gets a com.aspose.cad.Rectangle object that contains the union of two com.aspose.cad.Rectangle objects.

        Parameters:
        a - A first rectangle to union.
        b - A second rectangle to union.
        Returns:
        A com.aspose.cad.Rectangle object that bounds the union of the two com.aspose.cad.Rectangle objects.
      • op_Equality

        public static boolean op_Equality(Rectangle left,
                                          Rectangle right)

        Tests whether two com.aspose.cad.Rectangle objects have equal location and size.

        Parameters:
        left - The com.aspose.cad.Rectangle object that is to the left of the equality operator.
        right - The com.aspose.cad.Rectangle object that is to the right of the equality operator.
        Returns:
        This operator returns true if the two com.aspose.cad.Rectangle objects have equal com.aspose.cad.Rectangle.X, com.aspose.cad.Rectangle.Y, com.aspose.cad.Rectangle.Width, and com.aspose.cad.Rectangle.Height properties.
      • op_Inequality

        public static boolean op_Inequality(Rectangle left,
                                            Rectangle right)

        Tests whether two com.aspose.cad.Rectangle objects differ in location or size.

        Parameters:
        left - The com.aspose.cad.Rectangle object that is to the left of the inequality operator.
        right - The com.aspose.cad.Rectangle object that is to the right of the inequality operator.
        Returns:
        This operator returns true if any of the com.aspose.cad.Rectangle.X, com.aspose.cad.Rectangle.Y, com.aspose.cad.Rectangle.Width or com.aspose.cad.Rectangle.Height properties of the two com.aspose.cad.Rectangle objects are unequal; otherwise false.
      • fromLeftTopRightBottom

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

        Creates a com.aspose.cad.Rectangle object with the specified edge locations.

        Parameters:
        left - The x-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
        top - The y-coordinate of the upper-left corner of this com.aspose.cad.Rectangle object.
        right - The x-coordinate of the lower-right corner of this com.aspose.cad.Rectangle object.
        bottom - The y-coordinate of the lower-right corner of this com.aspose.cad.Rectangle object.
        Returns:
        The new com.aspose.cad.Rectangle that this method creates.
      • contains

        public boolean contains(int x,
                                int y)

        Determines if the specified point is contained within this com.aspose.cad.Rectangle object.

        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 com.aspose.cad.Rectangle object; otherwise false.
      • contains

        public boolean contains(Point point)

        Determines if the specified point is contained within this com.aspose.cad.Rectangle object.

        Parameters:
        point - The com.aspose.imaging.Point to test.
        Returns:
        This method returns true if the point represented by point is contained within this com.aspose.cad.Rectangle object; otherwise false.
      • contains

        public boolean contains(Rectangle rect)

        Determines if the rectangular region represented by rect is entirely contained within this com.aspose.cad.Rectangle object.

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

        public void inflate(int width,
                            int height)

        Inflates this com.aspose.cad.Rectangle by the specified amount.

        Parameters:
        width - The amount to inflate this com.aspose.cad.Rectangle horizontally.
        height - The amount to inflate this com.aspose.cad.Rectangle vertically.
      • inflate

        public void inflate(Size size)

        Inflates this com.aspose.cad.Rectangle by the specified amount.

        Parameters:
        size - The amount to inflate this rectangle.
      • intersect

        public void intersect(Rectangle rect)

        Replaces this com.aspose.cad.Rectangle with the intersection of itself and the specified com.aspose.cad.Rectangle.

        Parameters:
        rect - The com.aspose.cad.Rectangle with which to intersect.
      • 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.
      • offset

        public void offset(Point pos)

        Adjusts the location of this rectangle by the specified amount.

        Parameters:
        pos - Amount to offset the location.
      • 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.
      • normalize

        public void normalize()

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

      • equals

        public boolean equals(Object obj)

        Tests whether obj is a com.aspose.cad.Rectangle object with the same location and size of this com.aspose.cad.Rectangle object.

        Overrides:
        equals in class Object
        Parameters:
        obj - The object to test.
        Returns:
        This method returns true if obj is a com.aspose.cad.Rectangle object and its com.aspose.cad.Rectangle.X, com.aspose.cad.Rectangle.Y, com.aspose.cad.Rectangle.Width, and com.aspose.cad.Rectangle.Height properties are equal to the corresponding properties of this com.aspose.cad.Rectangle object; otherwise, false.
      • hashCode

        public int hashCode()

        Returns the hash code for this com.aspose.cad.Rectangle object.

        Overrides:
        hashCode in class Object
        Returns:
        An integer that represents the hash code for this rectangle.
      • toString

        public String toString()

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

        Overrides:
        toString in class Object
        Returns:
        A string that contains the position, width, and height of this com.aspose.cad.Rectangle object.
      • CloneTo

        public void CloneTo(Rectangle that)
        Specified by:
        CloneTo in class com.aspose.ms.System.ValueType<Rectangle>
      • Clone

        public Rectangle Clone()
        Specified by:
        Clone in class com.aspose.ms.System.ValueType<Rectangle>