Start end end strings

The implementation allows to add a start and/or end string to each text line. The start string is added before the text and any left text margin. The end string is added after the text and any right text margin. The default is no added text.

Start and end strings can be set any time, they are only considered when the paragraph is rendered.

The following code creates a paragraph context and then a paragraph with some demo text. It then prints the default settings (no added string). This is followed by setting the start string to "// ", printing the output. This is followed by setting the end string to " -→", printing the output. This is followed by setting the start string to null, which effectively removes the start string, printing the output.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
AP_Context ctx = new AP_Context();
ctx.setAlignment(TextAlignment.JUSTIFIED);
ctx.setWidth(50);

AsciiParagraph ap = new AsciiParagraph(ctx);
ap.addText(new LoremIpsum().getWords(29));

System.out.println(ap.render());

ctx.setStartString("// ");
System.out.println(ap.render());

ctx.setEndString(" -->");
System.out.println(ap.render());

ctx.setStartString(null);
System.out.println(ap.render());

The resulting output for the first setting, no added string, 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, added start string "// ", 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 third setting, added end string " -→", 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 fourth setting, removing the start string, 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 -->