Text margin - right

The implementation allows to change the right text margin (padding after - to the right of - each line, independent to any padding for alignment). The number of characters as well as the used character can be changed. The default values are 0 and blank ` `.

The following code creates a paragraph context and then a paragraph with some demo text. It then prints the default settings (no right margin). This is followed by setting the right text margin to 5, printing the output. This is followed by setting the right text margin to 10 and the character to <, printing the output.

To demonstrate the actual margin added, the paragraph is using a right border marked by |. The right text is visibule between the right end of the text and the border in each line.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
AP_Context ctx = new AP_Context();
ctx.setAlignment(TextAlignment.RIGHT);
ctx.setWidth(29);
ctx.setEndString("|");

AsciiParagraph ap = new AsciiParagraph(ctx);
ap.addText(new LoremIpsum().getWords(29));
System.out.println(ap.render());

ctx.setTextRightMargin(5);
System.out.println(ap.render());

ctx.setTextRightMargin(10);
ctx.setTextRightChar('<');
System.out.println(ap.render());

The resulting output for the first setting, default margin, is:

  Lorem ipsum dolor sit amet,|
 consetetur sadipscing elitr,|
sed diam nonumy eirmod tempor|
 invidunt ut labore et dolore|
magna aliquyam erat, sed diam|
     voluptua. At vero eos et|
                      accusam|

The resulting output for the second setting, right text margin set to 5, is:

  Lorem ipsum dolor sit amet,     |
 consetetur sadipscing elitr,     |
sed diam nonumy eirmod tempor     |
 invidunt ut labore et dolore     |
magna aliquyam erat, sed diam     |
     voluptua. At vero eos et     |
                      accusam     |

The resulting output for the second setting, right text margin set to 10 and character set to <, is:

  Lorem ipsum dolor sit amet,<<<<<<<<<<|
 consetetur sadipscing elitr,<<<<<<<<<<|
sed diam nonumy eirmod tempor<<<<<<<<<<|
 invidunt ut labore et dolore<<<<<<<<<<|
magna aliquyam erat, sed diam<<<<<<<<<<|
     voluptua. At vero eos et<<<<<<<<<<|
                      accusam<<<<<<<<<<|