public interface Text_To_FormattedText extends IsTransformer<String,Collection<StrBuilder>>
Swiss army knife for formatting text, with several options for alignments, formats, inserted characters, and variable width.
| Modifier and Type | Field and Description |
|---|---|
static int |
ALIGN_CENTER
Alignment option for centered text.
|
static int |
ALIGN_JUSTIFIED
Alignment option for justified text.
|
static int |
ALIGN_JUSTIFIED_LEFT
Alignment option for justified text, last line left aligned.
|
static int |
ALIGN_JUSTIFIED_RIGHT
Alignment option for justified text, last line right aligned.
|
static int |
ALIGN_LEFT
Alignment option for left aligned text.
|
static int |
ALIGN_RIGHT
Alignment option for right aligned text.
|
static int |
DEFAULT_CHARS_BETWEEN_DROPCAP_AND_TEXT
Characters to be used between the drop cap and the text, set to 3.
|
static IsCollectionStrategy<?,StrBuilder> |
DEFAULT_COLLECTION_STRATEGY
Default collection strategy for the returned collection, defaults to an array list strategy.
|
static int |
DEFAULT_FIRSTLINE_INDENTATION
Default first line indentation, set to 4.
|
static int |
DEFAULT_HANGING_INDENTATION
Default hanging indent, set to 4.
|
static char |
DEFAULT_INNER_WHITESPACE_CHARACTER
Default white space replacement character, set to ' '.
|
static char |
DEFAULT_LEFT_PADDING_CHARACTER
Default left padding character, set to ' '.
|
static int |
DEFAULT_LINES_AFTER_DROPCAP
Empty lines to be added after the drop cap, set to 1.
|
static char |
DEFAULT_RIGHT_PADDING_CHARACTER
Default right padding character, set to ' '.
|
static int |
DEFAULT_TEXT_WIDTH
The default width, set to 80.
|
static int |
FORMAT_DROPCAP
Format option for text using a dropped capital letter replacing the first character of the first word of the first sentence, requires a special library of those letters.
|
static int |
FORMAT_DROPCAP_WITH_PADDING
Format option for text with a dropped capital letter using a padding.
|
static int |
FORMAT_FIRST_LINE
Format option for text with the first line using an indentation.
|
static int |
FORMAT_FIRSTLINE_AND_HANGINGPARAGRAPH
Format option combining a first line indentation with a hanging paragraph.
|
static int |
FORMAT_HANGING_PARAGRAPH
Format option for text with all lines but the first line using an indentation (hanging paragraph).
|
static int |
FORMAT_NONE
Format option for no special formatting.
|
| Modifier and Type | Method and Description |
|---|---|
static Collection<StrBuilder> |
center(String text,
int textWidth)
Transforms text to centered lines.
|
static Collection<StrBuilder> |
center(String text,
int textWidth,
int format)
Transforms text to centered lines.
|
static Collection<StrBuilder> |
center(String text,
int textWidth,
int format,
Character padding)
Transforms text to centered lines.
|
static Collection<StrBuilder> |
center(String text,
int textWidth,
int format,
Character leftPadding,
Character rightPadding)
Transforms text to centered lines.
|
static Collection<StrBuilder> |
center(String text,
int textWidth,
int format,
Character leftPadding,
Character rightPadding,
Character innerWS)
Transforms text to centered lines.
|
static Collection<StrBuilder> |
center(String text,
int textWidth,
int format,
Character leftPadding,
Character rightPadding,
Character innerWS,
IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to centered lines.
|
static Text_To_FormattedText |
create(int textWidth,
int alignment,
int format,
Character leftPadding,
Character rightPadding,
Character innerWS,
int hangingIndentation,
int firstlineIndentation,
String[] dropCap,
int charsBetweenDroppcapAndText,
int linesAfterDropcap,
IsCollectionStrategy<?,StrBuilder> strategy)
Creates a new transformer.
|
default int |
getAlignment()
Returns the required alignment, defaults to
ALIGN_JUSTIFIED_LEFT. |
default int |
getCharsBetweenDroppcapAndText()
Returns the number of characters between a dropped capital letter and text lines, default to
DEFAULT_CHARS_BETWEEN_DROPCAP_AND_TEXT. |
default IsCollectionStrategy<?,StrBuilder> |
getCollectionStrategy()
Returns the collection strategy, defaults to
DEFAULT_COLLECTION_STRATEGY. |
String[] |
getDropCap()
Returns the dropped capital letter used if such format is required.
|
default int |
getFirstlineIndentation()
Returns the first line indentation, defaults to
DEFAULT_FIRSTLINE_INDENTATION. |
default int |
getFormat()
Returns the required format, defaults to
FORMAT_NONE. |
default int |
getHangingIndentation()
Returns the hanging paragraph indentation, defaults to
DEFAULT_HANGING_INDENTATION. |
default Character |
getInnerWsChar()
Returns the in-text whitespace character, defaults to
DEFAULT_INNER_WHITESPACE_CHARACTER. |
default Character |
getLeftPaddingChar()
Returns the left padding character, defaults to
DEFAULT_LEFT_PADDING_CHARACTER. |
default int |
getLinesAfterDropcap()
Returns the lines added after a dropped capital letter, defaults to
DEFAULT_LINES_AFTER_DROPCAP. |
default Character |
getRightPaddingChar()
Returns the right padding character, defaults to
DEFAULT_RIGHT_PADDING_CHARACTER. |
default int |
getTextWidth()
Returns the text width, defaults to
DEFAULT_TEXT_WIDTH. |
static Collection<StrBuilder> |
justified(String text,
int textWidth)
Transforms text to justified lines.
|
static Collection<StrBuilder> |
justified(String text,
int textWidth,
int format)
Transforms text to justified lines.
|
static Collection<StrBuilder> |
justified(String text,
int textWidth,
int format,
Character innerWS)
Transforms text to justified lines.
|
static Collection<StrBuilder> |
justified(String text,
int textWidth,
int format,
Character innerWS,
IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to justified lines.
|
static Collection<StrBuilder> |
justifiedLeft(String text,
int textWidth)
Transforms text to justified lines, last line being left aligned.
|
static Collection<StrBuilder> |
justifiedLeft(String text,
int textWidth,
int format)
Transforms text to justified lines, last line being left aligned.
|
static Collection<StrBuilder> |
justifiedLeft(String text,
int textWidth,
int format,
Character padding)
Transforms text to justified lines, last line being left aligned.
|
static Collection<StrBuilder> |
justifiedLeft(String text,
int textWidth,
int format,
Character padding,
Character innerWS)
Transforms text to justified lines, last line being left aligned.
|
static Collection<StrBuilder> |
justifiedLeft(String text,
int textWidth,
int format,
Character padding,
Character innerWS,
IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to justified lines, last line being left aligned.
|
static Collection<StrBuilder> |
justifiedRight(String text,
int textWidth)
Transforms text to justified lines, last line being right aligned.
|
static Collection<StrBuilder> |
justifiedRight(String text,
int textWidth,
int format)
Transforms text to justified lines, last line being right aligned.
|
static Collection<StrBuilder> |
justifiedRight(String text,
int textWidth,
int format,
Character padding)
Transforms text to justified lines, last line being right aligned.
|
static Collection<StrBuilder> |
justifiedRight(String text,
int textWidth,
int format,
Character padding,
Character innerWS)
Transforms text to justified lines, last line being right aligned.
|
static Collection<StrBuilder> |
justifiedRight(String text,
int textWidth,
int format,
Character padding,
Character innerWS,
IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to justified lines, last line being right aligned.
|
static Collection<StrBuilder> |
left(String text,
int textWidth)
Transforms text to left aligned lines.
|
static Collection<StrBuilder> |
left(String text,
int textWidth,
int format)
Transforms text to left aligned lines.
|
static Collection<StrBuilder> |
left(String text,
int textWidth,
int format,
Character padding)
Transforms text to left aligned lines.
|
static Collection<StrBuilder> |
left(String text,
int textWidth,
int format,
Character padding,
Character innerWS)
Transforms text to left aligned lines.
|
static Collection<StrBuilder> |
left(String text,
int textWidth,
int format,
Character padding,
Character innerWS,
IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to left aligned lines.
|
static Collection<StrBuilder> |
right(String text,
int textWidth)
Transforms text to right aligned lines.
|
static Collection<StrBuilder> |
right(String text,
int textWidth,
int format)
Transforms text to right aligned lines.
|
static Collection<StrBuilder> |
right(String text,
int textWidth,
int format,
Character padding)
Transforms text to right aligned lines.
|
static Collection<StrBuilder> |
right(String text,
int textWidth,
int format,
Character padding,
Character innerWS)
Transforms text to right aligned lines.
|
static Collection<StrBuilder> |
right(String text,
int textWidth,
int format,
Character padding,
Character innerWS,
IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to right aligned lines.
|
default Collection<StrBuilder> |
transform(StrBuilder sb)
Transforms a string builder to a collection using the main transform method.
|
default Collection<StrBuilder> |
transform(String s)
Transforms from one representation to another.
|
apply, transformstatic final int ALIGN_LEFT
Alignment option for left aligned text.
static final int ALIGN_CENTER
Alignment option for centered text.
static final int ALIGN_RIGHT
Alignment option for right aligned text.
static final int ALIGN_JUSTIFIED
Alignment option for justified text.
static final int ALIGN_JUSTIFIED_LEFT
Alignment option for justified text, last line left aligned.
static final int ALIGN_JUSTIFIED_RIGHT
Alignment option for justified text, last line right aligned.
static final int FORMAT_NONE
Format option for no special formatting.
static final int FORMAT_FIRST_LINE
Format option for text with the first line using an indentation.
static final int FORMAT_HANGING_PARAGRAPH
Format option for text with all lines but the first line using an indentation (hanging paragraph).
static final int FORMAT_FIRSTLINE_AND_HANGINGPARAGRAPH
Format option combining a first line indentation with a hanging paragraph.
static final int FORMAT_DROPCAP
Format option for text using a dropped capital letter replacing the first character of the first word of the first sentence, requires a special library of those letters.
static final int FORMAT_DROPCAP_WITH_PADDING
Format option for text with a dropped capital letter using a padding.
static final int DEFAULT_TEXT_WIDTH
The default width, set to 80.
static final char DEFAULT_LEFT_PADDING_CHARACTER
Default left padding character, set to ' '.
static final char DEFAULT_RIGHT_PADDING_CHARACTER
Default right padding character, set to ' '.
static final char DEFAULT_INNER_WHITESPACE_CHARACTER
Default white space replacement character, set to ' '.
static final int DEFAULT_HANGING_INDENTATION
Default hanging indent, set to 4.
static final int DEFAULT_FIRSTLINE_INDENTATION
Default first line indentation, set to 4.
static final int DEFAULT_CHARS_BETWEEN_DROPCAP_AND_TEXT
Characters to be used between the drop cap and the text, set to 3.
static final int DEFAULT_LINES_AFTER_DROPCAP
Empty lines to be added after the drop cap, set to 1.
static final IsCollectionStrategy<?,StrBuilder> DEFAULT_COLLECTION_STRATEGY
Default collection strategy for the returned collection, defaults to an array list strategy.
default int getAlignment()
Returns the required alignment, defaults to ALIGN_JUSTIFIED_LEFT.
default int getFormat()
Returns the required format, defaults to FORMAT_NONE.
default Character getInnerWsChar()
Returns the in-text whitespace character, defaults to DEFAULT_INNER_WHITESPACE_CHARACTER.
default Character getLeftPaddingChar()
Returns the left padding character, defaults to DEFAULT_LEFT_PADDING_CHARACTER.
default Character getRightPaddingChar()
Returns the right padding character, defaults to DEFAULT_RIGHT_PADDING_CHARACTER.
default int getTextWidth()
Returns the text width, defaults to DEFAULT_TEXT_WIDTH.
default IsCollectionStrategy<?,StrBuilder> getCollectionStrategy()
Returns the collection strategy, defaults to DEFAULT_COLLECTION_STRATEGY.
default int getHangingIndentation()
Returns the hanging paragraph indentation, defaults to DEFAULT_HANGING_INDENTATION.
default int getFirstlineIndentation()
Returns the first line indentation, defaults to DEFAULT_FIRSTLINE_INDENTATION.
default int getCharsBetweenDroppcapAndText()
Returns the number of characters between a dropped capital letter and text lines, default to DEFAULT_CHARS_BETWEEN_DROPCAP_AND_TEXT.
default int getLinesAfterDropcap()
Returns the lines added after a dropped capital letter, defaults to DEFAULT_LINES_AFTER_DROPCAP.
default Collection<StrBuilder> transform(StrBuilder sb)
Transforms a string builder to a collection using the main transform method.
sb - input string builder, cannot be nullString[] getDropCap()
Returns the dropped capital letter used if such format is required.
default Collection<StrBuilder> transform(String s)
TransformerTransforms from one representation to another.
transform in interface Transformer<String,Collection<StrBuilder>>s - input representationstatic Text_To_FormattedText create(int textWidth, int alignment, int format, Character leftPadding, Character rightPadding, Character innerWS, int hangingIndentation, int firstlineIndentation, String[] dropCap, int charsBetweenDroppcapAndText, int linesAfterDropcap, IsCollectionStrategy<?,StrBuilder> strategy)
Creates a new transformer.
textWidth - the text width (width of each line in the returned collection), should not be less than 1alignment - the option for text alignment, must be a valid optionformat - the option for text formatting, must be a valid optionleftPadding - character for padding on the left side of a line, can be null (then default is used)rightPadding - character for padding on the right side of a line, can be null (then default is used)innerWS - character for replacing whitespaces within a line (between first and last word), can be null (then default is used)hangingIndentation - indentation for a hanging paragraph format, 0 will result in default being usedfirstlineIndentation - indentation for the first line in the first line format, 0 will result in default being useddropCap - a dropped capital letter for dropped capital formats, should not be null if relevant format is setcharsBetweenDroppcapAndText - characters between the dropped capital letter and text, 0 will result in default being usedlinesAfterDropcap - lines added after the dropped capital letter with same indentation, 0 will result in default being usedstrategy - the collection strategy for the returned collection, null means use defaultstatic Collection<StrBuilder> left(String text, int textWidth)
Transforms text to left aligned lines.
text - the input texttextWidth - the width of each linestatic Collection<StrBuilder> left(String text, int textWidth, int format)
Transforms text to left aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textstatic Collection<StrBuilder> left(String text, int textWidth, int format, Character padding)
Transforms text to left aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding on the right sidestatic Collection<StrBuilder> left(String text, int textWidth, int format, Character padding, Character innerWS)
Transforms text to left aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding on the right sideinnerWS - character for replacing whitespaces in the textstatic Collection<StrBuilder> left(String text, int textWidth, int format, Character padding, Character innerWS, IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to left aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding on the right sideinnerWS - character for replacing whitespaces in the textstrategy - the strategy for the returned collectionstatic Collection<StrBuilder> center(String text, int textWidth)
Transforms text to centered lines.
text - the input texttextWidth - the width of each linestatic Collection<StrBuilder> center(String text, int textWidth, int format)
Transforms text to centered lines.
text - the input texttextWidth - the width of each lineformat - a format for the textstatic Collection<StrBuilder> center(String text, int textWidth, int format, Character padding)
Transforms text to centered lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - left and right padding characterstatic Collection<StrBuilder> center(String text, int textWidth, int format, Character leftPadding, Character rightPadding)
Transforms text to centered lines.
text - the input texttextWidth - the width of each lineformat - a format for the textleftPadding - left padding characterrightPadding - right padding characterstatic Collection<StrBuilder> center(String text, int textWidth, int format, Character leftPadding, Character rightPadding, Character innerWS)
Transforms text to centered lines.
text - the input texttextWidth - the width of each lineformat - a format for the textleftPadding - left padding characterrightPadding - right padding characterinnerWS - character for replacing whitespaces in the textstatic Collection<StrBuilder> center(String text, int textWidth, int format, Character leftPadding, Character rightPadding, Character innerWS, IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to centered lines.
text - the input texttextWidth - the width of each lineformat - a format for the textleftPadding - left padding characterrightPadding - right padding characterinnerWS - character for replacing whitespaces in the textstrategy - the strategy for the returned collectionstatic Collection<StrBuilder> right(String text, int textWidth)
Transforms text to right aligned lines.
text - the input texttextWidth - the width of each linestatic Collection<StrBuilder> right(String text, int textWidth, int format)
Transforms text to right aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textstatic Collection<StrBuilder> right(String text, int textWidth, int format, Character padding)
Transforms text to right aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding on the left side of each linestatic Collection<StrBuilder> right(String text, int textWidth, int format, Character padding, Character innerWS)
Transforms text to right aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding on the left side of each lineinnerWS - character for replacing whitespaces in the textstatic Collection<StrBuilder> right(String text, int textWidth, int format, Character padding, Character innerWS, IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to right aligned lines.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding on the left side of each lineinnerWS - character for replacing whitespaces in the textstrategy - the strategy for the returned collectionstatic Collection<StrBuilder> justified(String text, int textWidth)
Transforms text to justified lines.
text - the input texttextWidth - the width of each linestatic Collection<StrBuilder> justified(String text, int textWidth, int format)
Transforms text to justified lines.
text - the input texttextWidth - the width of each lineformat - a format for the textstatic Collection<StrBuilder> justified(String text, int textWidth, int format, Character innerWS)
Transforms text to justified lines.
text - the input texttextWidth - the width of each lineformat - a format for the textinnerWS - character for replacing whitespaces in the textstatic Collection<StrBuilder> justified(String text, int textWidth, int format, Character innerWS, IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to justified lines.
text - the input texttextWidth - the width of each lineformat - a format for the textinnerWS - character for replacing whitespaces in the textstrategy - the strategy for the returned collectionstatic Collection<StrBuilder> justifiedLeft(String text, int textWidth)
Transforms text to justified lines, last line being left aligned.
text - the input texttextWidth - the width of each linestatic Collection<StrBuilder> justifiedLeft(String text, int textWidth, int format)
Transforms text to justified lines, last line being left aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textstatic Collection<StrBuilder> justifiedLeft(String text, int textWidth, int format, Character padding)
Transforms text to justified lines, last line being left aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding for the last linestatic Collection<StrBuilder> justifiedLeft(String text, int textWidth, int format, Character padding, Character innerWS)
Transforms text to justified lines, last line being left aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding for the last lineinnerWS - character for replacing whitespaces in the textstatic Collection<StrBuilder> justifiedLeft(String text, int textWidth, int format, Character padding, Character innerWS, IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to justified lines, last line being left aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding for the last lineinnerWS - character for replacing whitespaces in the textstrategy - the strategy for the returned collectionstatic Collection<StrBuilder> justifiedRight(String text, int textWidth)
Transforms text to justified lines, last line being right aligned.
text - the input texttextWidth - the width of each linestatic Collection<StrBuilder> justifiedRight(String text, int textWidth, int format)
Transforms text to justified lines, last line being right aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textstatic Collection<StrBuilder> justifiedRight(String text, int textWidth, int format, Character padding)
Transforms text to justified lines, last line being right aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding for the last linestatic Collection<StrBuilder> justifiedRight(String text, int textWidth, int format, Character padding, Character innerWS)
Transforms text to justified lines, last line being right aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding for the last lineinnerWS - character for replacing whitespaces in the textstatic Collection<StrBuilder> justifiedRight(String text, int textWidth, int format, Character padding, Character innerWS, IsCollectionStrategy<?,StrBuilder> strategy)
Transforms text to justified lines, last line being right aligned.
text - the input texttextWidth - the width of each lineformat - a format for the textpadding - character for padding for the last lineinnerWS - character for replacing whitespaces in the textstrategy - the strategy for the returned collectionCopyright © 2016–2017. All rights reserved.