Class PdfRectangle

java.lang.Object
cloud.opencode.base.pdf.content.PdfRectangle
All Implemented Interfaces:
PdfElement

public final class PdfRectangle extends Object implements PdfElement
PDF Rectangle Element - Rectangle graphic PDF 矩形元素 - 矩形图形

Features | 主要功能:

  • Rectangle with position and size - 带位置和大小的矩形
  • Stroke and fill color configuration - 描边和填充颜色配置
  • Rounded corner support - 圆角支持

Usage Examples | 使用示例:

PdfRectangle rect = PdfRectangle.of(100, 500, 200, 100)
    .fillColor(PdfColor.LIGHT_GRAY)
    .strokeColor(PdfColor.BLACK)
    .cornerRadius(5f);

Security | 安全性:

  • Thread-safe: No — mutable builder pattern - 线程安全: 否 — 可变构建器模式
  • Null-safe: No — callers must ensure non-null values - 空值安全: 否 — 调用方需确保非空值
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      public static PdfRectangle of(float x, float y, float width, float height)
      Creates a rectangle 创建矩形
      Parameters:
      x - x coordinate | x 坐标
      y - y coordinate | y 坐标
      width - width | 宽度
      height - height | 高度
      Returns:
      PdfRectangle instance | PdfRectangle 实例
    • builder

      public static PdfRectangle builder()
      Creates a rectangle builder 创建矩形构建器
      Returns:
      new PdfRectangle instance | 新 PdfRectangle 实例
    • position

      public PdfRectangle position(float x, float y)
    • size

      public PdfRectangle size(float width, float height)
    • strokeColor

      public PdfRectangle strokeColor(PdfColor color)
    • fillColor

      public PdfRectangle fillColor(PdfColor color)
    • strokeWidth

      public PdfRectangle strokeWidth(float width)
    • cornerRadius

      public PdfRectangle cornerRadius(float radius)
    • getX

      public float getX()
      Description copied from interface: PdfElement
      Gets the x coordinate of this element 获取元素的 x 坐标
      Specified by:
      getX in interface PdfElement
      Returns:
      x coordinate | x 坐标
    • getY

      public float getY()
      Description copied from interface: PdfElement
      Gets the y coordinate of this element 获取元素的 y 坐标
      Specified by:
      getY in interface PdfElement
      Returns:
      y coordinate | y 坐标
    • getWidth

      public float getWidth()
    • getHeight

      public float getHeight()
    • getStrokeColor

      public PdfColor getStrokeColor()
    • getFillColor

      public PdfColor getFillColor()
    • getStrokeWidth

      public float getStrokeWidth()
    • getCornerRadius

      public float getCornerRadius()
    • isFilled

      public boolean isFilled()