[]
        
(Showing Draft Content)

Rectangle

Class Rectangle

java.lang.Object
com.grapecity.documents.excel.Rectangle

public class Rectangle extends Object
Represents a rectangle defined by an upper-left corner and a size.

This class stores the x-coordinate, y-coordinate, width, and height of a rectangle. Use it to describe rectangular areas when working with layout, drawing, or positioning APIs.


 Rectangle rectangle = new Rectangle(10, 20, 120, 80);
 double x = rectangle.getX();
 double y = rectangle.getY();
 double width = rectangle.getWidth();
 double height = rectangle.getHeight();
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rectangle(double x, double y, double width, double height)
    Constructor that creates a rectangle object with the specified position and size.
  • Method Summary

    Modifier and Type
    Method
    Description
    final double
    Gets the height of this rectangle.
    final double
    Gets the width of this rectangle.
    final double
    Gets the x-coordinate of the upper-left corner of this rectangle.
    final double
    Gets the y-coordinate of the upper-left corner of this rectangle.
    final void
    setHeight(double value)
    Sets the height of this rectangle.
    final void
    setWidth(double value)
    Sets the width of this rectangle.
    final void
    setX(double value)
    Sets the x-coordinate of the upper-left corner of this rectangle.
    final void
    setY(double value)
    Sets the y-coordinate of the upper-left corner of this rectangle.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Rectangle

      public Rectangle(double x, double y, double width, double height)
      Constructor that creates a rectangle object with the specified position and size.

      Initializes the rectangle using the x-coordinate and y-coordinate of its upper-left corner, together with the specified width and height.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       
      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.
  • Method Details

    • getX

      public final double getX()
      Gets the x-coordinate of the upper-left corner of this rectangle.

      Use this method to retrieve the rectangle's horizontal position without changing its size.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double x = rectangle.getX();
       
      Returns:
      The x-coordinate of the upper-left corner of the rectangle.
    • setX

      public final void setX(double value)
      Sets the x-coordinate of the upper-left corner of this rectangle.

      Use this method to update the rectangle's horizontal position without changing its size.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setX(40.0);
       
      Parameters:
      value - The x-coordinate of the upper-left corner of the rectangle.
    • getY

      public final double getY()
      Gets the y-coordinate of the upper-left corner of this rectangle.

      Use this method to retrieve the rectangle's vertical position without changing its size.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double y = rectangle.getY();
       
      Returns:
      The y-coordinate of the upper-left corner of the rectangle.
    • setY

      public final void setY(double value)
      Sets the y-coordinate of the upper-left corner of this rectangle.

      Use this method to update the rectangle's vertical position without changing its size.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setY(40.0);
       
      Parameters:
      value - The y-coordinate of the upper-left corner of the rectangle.
    • getWidth

      public final double getWidth()
      Gets the width of this rectangle.

      Use this method to retrieve the rectangle's horizontal size without changing its x-coordinate, y-coordinate, or height.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double width = rectangle.getWidth();
       
      Returns:
      The width of the rectangle.
    • setWidth

      public final void setWidth(double value)
      Sets the width of this rectangle.

      Use this method to update the rectangle's horizontal size without changing its x-coordinate, y-coordinate, or height.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setWidth(160.0);
       
      Parameters:
      value - The width of the rectangle.
    • getHeight

      public final double getHeight()
      Gets the height of this rectangle.

      Returns the height value specified when the rectangle is created or last updated by setHeight(double).

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double height = rectangle.getHeight();
       
      Returns:
      The height of this rectangle.
    • setHeight

      public final void setHeight(double value)
      Sets the height of this rectangle.

      Use this method to update the rectangle's height without changing its x-coordinate, y-coordinate, or width.

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setHeight(100.0);
       
      Parameters:
      value - The height of this rectangle.