public class TextColumnInfo extends Object
width
, alignment
,
indent
, and various other meta-information for the layout of a textual column.LineWrapper
Modifier and Type | Class and Description |
---|---|
static class |
TextColumnInfo.IndentationMode
This enum contains the available modes how to deal with
indentation after
newlines . |
Modifier and Type | Field and Description |
---|---|
private HorizontalAlignment |
alignment |
private String |
borderLeft |
private String |
borderRight |
private char |
filler |
private String |
indent |
private TextColumnInfo.IndentationMode |
indentationMode |
private Locale |
locale |
static int |
MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN
|
private char[] |
omitChars |
private int |
width |
static int |
WIDTH_AUTO_ADJUST
|
private char[] |
wrapChars |
Constructor and Description |
---|
TextColumnInfo()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
HorizontalAlignment |
getAlignment()
This method gets the
alignment . |
String |
getBorderLeft()
This method gets the string for the left border of this column.
|
String |
getBorderRight()
This method gets the string for the right border of this column.
|
int |
getBorderWidth()
This method gets the auto calculated width of the
left and right
border . |
char |
getFiller()
This method gets the character used to fill up the column.
|
String |
getIndent()
This method gets the indent.
|
TextColumnInfo.IndentationMode |
getIndentationMode()
This method gets the
TextColumnInfo.IndentationMode that defines when to add an indentation . |
Locale |
getLocale()
This method gets the
Locale to use for this column. |
char[] |
getOmitChars()
This method gets the characters to omit at the beginning of each
indented line. |
int |
getWidth()
This method gets the width of this column in characters excluding the
left and
right border . |
char[] |
getWrapChars()
This method gets the characters where a wrap of the line is preferred.
|
void |
setAlignment(HorizontalAlignment alignment)
This method sets the
alignment . |
void |
setBorderLeft(String separator)
This method sets the
left border string . |
void |
setBorderRight(String separator)
This method sets the
right border string . |
void |
setFiller(char filler)
This method sets the
filler . |
void |
setIndent(String indent)
This method sets the
indent . |
void |
setIndentationMode(TextColumnInfo.IndentationMode indentationMode)
This method sets the
indentation-mode . |
void |
setLocale(Locale locale)
This method sets the
locale . |
void |
setOmitChars(char... omitChars)
This method sets the
characters to omit . |
void |
setWidth(int width) |
void |
setWrapChars(char... wrapChars)
This method sets the
wrap characters . |
public static final int MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN
width
of a column
in order that indentation
and hyphenation
will be active. The value is
4.public static final int WIDTH_AUTO_ADJUST
width
of a column
in order to activate automatic
adjustment of the width. The value is -1. Please note that automatic adjustment for
multiple columns needs to pre-process the entire text
of these columns what costs a
little bit of additional performance.private int width
private String borderLeft
private String borderRight
private char filler
private String indent
private HorizontalAlignment alignment
private char[] wrapChars
private char[] omitChars
private TextColumnInfo.IndentationMode indentationMode
private Locale locale
public int getWidth()
left
and
right border
. WIDTH_AUTO_ADJUST
(the default). A reasonable value
is at least 5, typically more than 10. However you may use a very low values (<5) for rendering a small column
of a large table, but then do NOT expect nice results if text is really wrapped.WIDTH_AUTO_ADJUST
for automatic calculation of the width.MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN
public void setWidth(int width)
width
- is the width to setpublic int getBorderWidth()
getBorderLeft()
.length() + getBorderRight()
.length()public String getBorderRight()
changed
for all columns except the last one.public void setBorderRight(String separator)
right border string
. This is typically a single character (e.g. ' '
or '|'). However it is also possible to use the empty string or a sequence of characters.separator
- is the right border.public String getBorderLeft()
public void setBorderLeft(String separator)
left border string
. This is typically a single character (e.g. '|').
However it is also possible to use a sequence of characters.separator
- is the right border.public String getIndent()
left border
and before the
text of the column in each line except the first one. The exact behavior depends on getIndentationMode()
.
The default is the empty string. width
is less than MINIMUM_WIDTH_FOR_INDENT_AND_HYPHEN
.
alignment
other than
left
. However this might cause confusing results.getIndentationMode()
public void setIndent(String indent)
indent
.indent
- is the indent to setpublic HorizontalAlignment getAlignment()
alignment
.public void setAlignment(HorizontalAlignment alignment)
alignment
.alignment
- is the HorizontalAlignment
to use.public char getFiller()
public void setFiller(char filler)
filler
.filler
- is character used to fill up the column.public char[] getWrapChars()
public void setWrapChars(char... wrapChars)
wrap characters
.wrapChars
- are the wrap characters
.public char[] getOmitChars()
indented
line. E.g. if space
(' ') is contained in getWrapChars()
you can add it to omit chars to prevent the space to occur at the
beginning of the next line.public void setOmitChars(char... omitChars)
characters to omit
.omitChars
- are the characters that shall be omitted from the column text.public TextColumnInfo.IndentationMode getIndentationMode()
TextColumnInfo.IndentationMode
that defines when to add an indentation
. To turn
indentation
off, simply set indent
to the empty string. TextColumnInfo.IndentationMode.NO_INDENT_AFTER_DOUBLE_NEWLINE
.getIndent()
public void setIndentationMode(TextColumnInfo.IndentationMode indentationMode)
indentation-mode
.indentationMode
- is the indentationMode to setpublic Locale getLocale()
Locale
to use for this column. It is used for line wrapping including hyphenation.Copyright © 2001–2016 mmm-Team. All rights reserved.