Class Paragraph
- All Implemented Interfaces:
Block
An immutable paragraph: styled text plus the paragraph's own layout. Distances are in points.
Every with... method returns a copy that keeps the id, so the copy replaces the original in
a document:
Paragraph p = new Paragraph("p1", RichText.of("Hello")).withAlign(Paragraph.CENTER);
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal floatSpace below the paragraph.final StringOne ofLEFT,CENTER,RIGHTorJUSTIFY.final floatSpace above the paragraph.static final StringA bulleted list item.static final StringCentered text.final floatThe first line's indent relative toindent; negative for a hanging indent.final StringThe block id.final floatLeft indent.static final StringText stretched to both margins.final booleanWhether the paragraph stays on the page of the one that follows it.static final StringStart-aligned text.final floatLine spacing as a multiple of the single line height.final StringOne ofNO_LIST,BULLETorNUMBERED.final intThe list nesting level, from zero.final intThe number a numbered list restarts at, or zero to continue the previous list.static final StringNot a list item.static final StringA numbered list item.final booleanWhether a page break precedes the paragraph.static final StringEnd-aligned text.final floatThe right indent, in points.final StringThe named paragraph style (Normal,Heading1...Heading6,Title,Quote,Codeor an application's own).The tab stops, ordered by position; empty for the default stops every half inch.final RichTextThe paragraph's text. -
Constructor Summary
ConstructorsConstructorDescriptionANormalparagraph with default layout.Paragraph(String id, String style, String align, String list, int listLevel, int listStart, float before, float after, float indent, float lineSpacing, boolean pageBreak, boolean keepNext, RichText text) A paragraph with every attribute given. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwo paragraphs are equal when every attribute, the id included, is.inthashCode()A hash consistent withequals.intThe heading level: 1 to 6 forHeading1toHeading6, 1 forTitle, 0 otherwise.id()The block id.booleanWhether the paragraph is a heading, that is its style isHeading1toHeading6orTitle.The text without formatting.A copy with a different alignment.A copy with another id, used when a paragraph is duplicated.withIndent(float value) A copy with a different left indent.withIndents(float left, float first, float right) A copy with different indents.withKeepNext(boolean value) A copy with keep-with-next switched.A copy with different list membership.withListStart(int value) A copy whose numbered list restarts.withPageBreak(boolean value) A copy with the page break switched.withSpacing(float spaceBefore, float spaceAfter, float lines) A copy with different spacing.A copy with a different named style.A copy with different tab stops.A copy with different text.
-
Field Details
-
LEFT
-
CENTER
-
RIGHT
-
JUSTIFY
-
NO_LIST
-
BULLET
-
NUMBERED
-
id
The block id. -
style
The named paragraph style (Normal,Heading1...Heading6,Title,Quote,Codeor an application's own). -
align
One ofLEFT,CENTER,RIGHTorJUSTIFY. -
list
One ofNO_LIST,BULLETorNUMBERED. -
listLevel
public final int listLevelThe list nesting level, from zero. -
listStart
public final int listStartThe number a numbered list restarts at, or zero to continue the previous list. -
before
public final float beforeSpace above the paragraph. -
after
public final float afterSpace below the paragraph. -
indent
public final float indentLeft indent. -
lineSpacing
public final float lineSpacingLine spacing as a multiple of the single line height. -
pageBreak
public final boolean pageBreakWhether a page break precedes the paragraph. -
keepNext
public final boolean keepNextWhether the paragraph stays on the page of the one that follows it. -
text
The paragraph's text. -
firstLine
public final float firstLineThe first line's indent relative toindent; negative for a hanging indent. -
rightIndent
public final float rightIndentThe right indent, in points. -
tabs
-
-
Constructor Details
-
Paragraph
-
Paragraph
public Paragraph(String id, String style, String align, String list, int listLevel, int listStart, float before, float after, float indent, float lineSpacing, boolean pageBreak, boolean keepNext, RichText text) A paragraph with every attribute given.
Parameters
-
id: the block id -
style: the named style -
align: the alignment -
list: the list kind -
listLevel: the list level, 0 to 8 -
listStart: the restart number, or zero -
before: space above -
after: space below -
indent: left indent -
lineSpacing: the line spacing multiple -
pageBreak: page break before -
keepNext: keep with next -
text: the text
-
-
-
Method Details
-
withIndents
A copy with different indents.
Parameters
-
left: the left indent -
first: the first line's indent relative toleft; negative hangs -
right: the right indent
Returns
the copy
-
-
withTabs
-
id
-
plainText
The text without formatting.
Returns
the characters
-
isHeading
public boolean isHeading()Whether the paragraph is a heading, that is its style is
Heading1toHeading6orTitle.Returns
true for a heading
-
headingLevel
public int headingLevel()The heading level: 1 to 6 for
Heading1toHeading6, 1 forTitle, 0 otherwise.Returns
the level
-
withText
-
withStyle
-
withAlign
-
withList
-
withListStart
A copy whose numbered list restarts.
Parameters
value: the first number, or zero to continue
Returns
the copy
-
withSpacing
A copy with different spacing.
Parameters
-
spaceBefore: space above -
spaceAfter: space below -
lines: the line spacing multiple
Returns
the copy
-
-
withIndent
A copy with a different left indent.
Parameters
value: the indent
Returns
the copy
-
withPageBreak
A copy with the page break switched.
Parameters
value: break before or not
Returns
the copy
-
withKeepNext
A copy with keep-with-next switched.
Parameters
value: keep or not
Returns
the copy
-
withId
-
equals
-
hashCode
-