public class Paragraph extends Div<Paragraph>
绘制行为详见渲染器:ParagraphRender
| Constructor and Description |
|---|
Paragraph()
创建一个段落对象
|
Paragraph(Double width,
Double height)
创建一个固定大小段落对象
|
Paragraph(double x,
double y,
double width,
double height)
创建绝对定位段落对象
|
Paragraph(double x,
double y,
double width,
double height,
String text,
double fontSize)
创建绝对定位段落对象
|
Paragraph(String text)
新建一个段落对象
|
Paragraph(String text,
Double defaultFontSize)
新建一个段落对象,并指定文字大小
|
Paragraph(String text,
Double defaultFontSize,
Font defaultFont)
新建一个段落对象,并指定文字大小和字体
|
Paragraph(String text,
Font defaultFont)
新建一个段落对象,并指定字体
|
box, copyTo, getBackgroundColor, getBorder, getBorderBottom, getBorderColor, getBorderDash, getBorderLeft, getBorderRight, getBorderTop, getClear, getDisplay, getFloat, getHeight, getLayer, getLeft, getMargin, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getOnRenderFinish, getOpacity, getPadding, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPosition, getRight, getTop, getWidth, getX, getY, heightPlus, isBlockElement, isIntegrity, isNoBorder, isPlaceholder, onRenderFinish, placeholder, placeholder, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBorder, setBorderBottom, setBorderColor, setBorderColor, setBorderColor, setBorderDash, setBorderLeft, setBorderRight, setBorderTop, setBox, setClear, setDisplay, setFloat, setHeight, setIntegrity, setLayer, setLeft, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setOpacity, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddingTop, setPlaceholder, setPosition, setRight, setTop, setWidth, setX, setXY, setY, split, toString, widthPluspublic Paragraph(Double width, Double height)
width - 内容宽度height - 内容高度public Paragraph()
注意如果不主动对 Paragraph 设置宽度,那么Paragraph
会独占整个段,并且与段具有相同宽度,也就是页面宽度,
在需要更加细致盒式的布局时 请设置Div.setClear(Clear)
并设置段落宽度 Div.setWidth(Double)。
public Paragraph(double x,
double y,
double width,
double height)
x - 固定布局的盒式模型左上角X坐标y - 固定布局的盒式模型左上角y坐标width - 宽度height - 高度public Paragraph(double x,
double y,
double width,
double height,
String text,
double fontSize)
x - 固定布局的盒式模型左上角X坐标y - 固定布局的盒式模型左上角y坐标width - 宽度height - 高度text - 文本内容fontSize - 字号public Paragraph(String text)
如果在指定段落中文字大小建议使用Paragraph(java.lang.String, java.lang.Double)
text - 文字内容public Paragraph(String text, Double defaultFontSize)
text - 文字内容defaultFontSize - 默认字体大小。public Paragraph(String text, Double defaultFontSize, Font defaultFont)
text - 文字内容defaultFontSize - 默认字体大小defaultFont - 默认字体public Paragraph add(String text)
文字样式使用span默认字体样式
text - 文本内容public Double getLineSpace()
public Font getDefaultFont()
public Paragraph setDefaultFont(Font defaultFont, boolean refreshBeforeAdd)
注意:在设置 defaultFont 之前被添加的内容,不会在调用 defaultFont 方法后而改变,除非指定 refreshBeforeAdd=true
defaultFont - 默认字体refreshBeforeAdd - 是否对之前add的text内容应用这个字体public Double getFontSize()
public Paragraph setFontSize(Double defaultFontSize)
如果加入的文字没有设置大小,那么默认使用该值。
注意:该操作不会对段落内已经存在的文字生效, 因此在添加文字之后,在调用该方法,原有的文字大小不会变换。
defaultFontSize - 默认字体大小public Paragraph setFontSize(Double defaultFontSize, boolean refreshBeforeAdd)
如果加入的文字没有设置大小,那么默认使用该值。
注意:该操作不会对段落内已经存在的文字生效, 因此在添加文字之后,在调用该方法,原有的文字大小不会变换。 你可以指定 refreshBeforeAdd=true 来使之前添加的内容也生效。
defaultFontSize - 默认字体大小refreshBeforeAdd - 是否刷新之前添加的内容public LinkedList<Span> getContents()
public LinkedList<TxtLineBlock> getLines()
public Integer getFirstLineIndent()
public Paragraph setFirstLineIndent(Integer firstLineIndent)
默认不缩进
firstLineIndent - 缩进字符数null或0表示不缩进public Double getFirstLineIndentWidth()
该方法仅在已经设置了首行缩进数值的情况下才会返还正确的数值,否则返还null
public Paragraph setFirstLineIndentWidth(double firstLineIndentWidth)
firstLineIndentWidth - 首行缩进数值(单位:mm)public Paragraph clearFirstLineIndent()
public Paragraph setTextAlign(TextAlign textAlign)
默认为左浮动
textAlign - 浮动方向public TextAlign getTextAlign()
默认为左浮动
public Rectangle doPrepare(Double widthLimit)
该方法主要有渲染器调用,请勿主动调用该方法,除非你知道你在做什么。
doPrepare in interface RenderPreparedoPrepare in class Div<Paragraph>widthLimit - 宽度限制public <T extends Div> Div[] contentSplitAdjust(double sHeight, T div1, T div2)
Div根据分割高度调整两个克隆元素,达成分割元素的效果
contentSplitAdjust in class Div<Paragraph>T - Div子类泛型参数sHeight - 分割内容的高度div1 - 克隆元素1div2 - 克隆元素2public Paragraph clone()
public String elementType()
关联渲染器:ParagraphRender
elementType in class Div<Paragraph>Copyright © 2026. All rights reserved.