Class Line

All Implemented Interfaces:
Drawer, ElementSplit, RenderPrepare

public class Line extends CanvasBase
OFDRW 线条元素,用于快速构建一条线条。

若需要绘制复杂图形,请使用 Canvas 对象,并提供 Drawer实现,在Drawer中使用绘制上下文绘制。

若绘制简单矩形,可以使用 Div 对象设置边框 实现。

Since:
2024-5-27 18:50:52
Author:
张炳恒
  • Constructor Details

    • Line

      public Line(Double width, Double height)
      线对象
      Parameters:
      width - 画线区域的宽度,单位:毫米mm
      height - 画线区域高度,单位:毫米mm
    • Line

      public Line(double x, double y, double w, double h)
      线对象
      Parameters:
      x - 画线区域左上角的x坐标,单位:毫米mm
      y - 画线区域左上角的y坐标,单位:毫米mm
      w - 画线区域的宽度,单位:毫米mm
      h - 画线区域高度,单位:毫米mm
  • Method Details

    • getBeginPoint

      public double[] getBeginPoint()
      获取线的起始点
      Returns:
      线的起始点坐标 [x, y],可能为NULL。
    • setBeginPoint

      public Line setBeginPoint(double[] beginPoint)
      设置线的起始点
      Parameters:
      beginPoint - 线的起始点在画布上的坐标 [x, y]
      Returns:
      this
    • setBeginPoint

      public Line setBeginPoint(double beginX, double beginY)
      设置线的起始点
      Parameters:
      beginX - 线的起始点在画布上的x坐标,单位:毫米mm
      beginY - 线的起始点在画布上的y坐标,单位:毫米mm
      Returns:
      this
    • getEndPoint

      public double[] getEndPoint()
      获取线的结束点
      Returns:
      线的结束点坐标 [x, y],可能为NULL。
    • setEndPoint

      public Line setEndPoint(double[] endPoint)
      设置线的结束点
      Parameters:
      endPoint - 线的结束点在画布上的坐标 [x, y]
      Returns:
      this
    • setEndPoint

      public Line setEndPoint(double endX, double endY)
      设置线的结束点
      Parameters:
      endX - 线的结束点在画布上的x坐标,单位:毫米mm
      endY - 线的结束点在画布上的y坐标,单位:毫米mm
      Returns:
      this
    • getLineColor

      public String getLineColor()
      获取线的颜色
      Returns:
      线的颜色 格式:#000000、rgb(0,0,0)、rgba(0,0,0,1)、black
    • setLineColor

      public Line setLineColor(String lineColor)
      设置线的颜色
      Parameters:
      lineColor - 线的颜色,格式:#000000、rgb(0,0,0)、rgba(0,0,0,1)、black
      Returns:
      this
    • getLineWidth

      public double getLineWidth()
      获取线的宽度
      Returns:
      线的宽度
    • setLineWidth

      public Line setLineWidth(double lineWidth)
      设置线的宽度
      Parameters:
      lineWidth - 线的宽度,单位 毫米mm
      Returns:
      this
    • getLineOpacity

      public double getLineOpacity()
      获取线的透明度
      Returns:
      线的透明度 [0,1]
    • setLineOpacity

      public Line setLineOpacity(double lineOpacity)
      设置线的透明度
      Parameters:
      lineOpacity - 线的透明度,范围 [0,1]
      Returns:
      this
    • draw

      public void draw(DrawContext ctx) throws IOException
      线条绘制器
      Parameters:
      ctx - 绘制上下文
      Throws:
      IOException - 绘制异常