[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

Rectangle

Class Rectangle

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

public class Rectangle extends Object
表示由左上角和大小定义的矩形。

此类存储矩形的 x 坐标、y 坐标、宽度和高度。使用它可以在处理布局、绘图或定位 API 时描述矩形区域。


 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)
    创建具有指定位置和大小的矩形对象的构造函数。
  • Method Summary

    Modifier and Type
    Method
    Description
    final double
    获取此矩形的高度。
    final double
    获取此矩形的宽度。
    final double
    获取此矩形左上角的 x 坐标。
    final double
    获取此矩形左上角的 y 坐标。
    final void
    setHeight(double value)
    设置此矩形的高度。
    final void
    setWidth(double value)
    设置此矩形的宽度。
    final void
    setX(double value)
    设置此矩形左上角的 x 坐标。
    final void
    setY(double value)
    设置此矩形左上角的 y 坐标。

    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)
      创建具有指定位置和大小的矩形对象的构造函数。

      使用矩形左上角的 x 坐标和 y 坐标以及指定的宽度和高度初始化矩形。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       
      Parameters:
      x - 矩形左上角的 x 坐标。
      y - 矩形左上角的 y 坐标。
      width - 矩形的宽度。
      height - 矩形的高度。
  • Method Details

    • getX

      public final double getX()
      获取此矩形左上角的 x 坐标。

      使用此方法可以在不更改矩形大小的情况下检索矩形的水平位置。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double x = rectangle.getX();
       
      Returns:
      矩形左上角的 x 坐标。
    • setX

      public final void setX(double value)
      设置此矩形左上角的 x 坐标。

      使用此方法可更新矩形的水平位置,而不更改其大小。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setX(40.0);
       
      Parameters:
      value - 矩形左上角的 x 坐标。
    • getY

      public final double getY()
      获取此矩形左上角的 y 坐标。

      使用此方法可以在不更改矩形大小的情况下检索矩形的垂直位置。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double y = rectangle.getY();
       
      Returns:
      矩形左上角的 y 坐标。
    • setY

      public final void setY(double value)
      设置此矩形左上角的 y 坐标。

      使用此方法可更新矩形的垂直位置,而不更改其大小。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setY(40.0);
       
      Parameters:
      value - 矩形左上角的 y 坐标。
    • getWidth

      public final double getWidth()
      获取此矩形的宽度。

      使用此方法可获取矩形的水平尺寸,而不更改其 x 坐标、y 坐标或高度。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double width = rectangle.getWidth();
       
      Returns:
      矩形的宽度。
    • setWidth

      public final void setWidth(double value)
      设置此矩形的宽度。

      使用此方法可更新矩形的水平尺寸,而不更改其 x 坐标、y 坐标或高度。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setWidth(160.0);
       
      Parameters:
      value - 矩形的宽度。
    • getHeight

      public final double getHeight()
      获取此矩形的高度。

      返回创建矩形时指定的高度值,或上次通过 setHeight(double) 更新的高度值。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       double height = rectangle.getHeight();
       
      Returns:
      此矩形的高度。
    • setHeight

      public final void setHeight(double value)
      设置此矩形的高度。

      使用此方法可更新矩形的高度,而不更改其 x 坐标、y 坐标或宽度。

      
       Rectangle rectangle = new Rectangle(10, 20, 120, 80);
       rectangle.setHeight(100.0);
       
      Parameters:
      value - 此矩形的高度。