Adding a frame

The implementation allows to add frames to a paragraph. Frame borders will be added to the left and right of each line. Top and bottom lines will be added to the top and the bottom of the paragraph. Additional margins can be set to separate the frame from any text (string margins) and to add margins around the frame.

Some frame examples

The following code creates a paragraph and then adds frames to it. The first setting uses a frame constructed of UTF-8 light border characters, with frame and text margins set to 1. The second setting removes all added margins and uses the same frame in a different mode. The third setting uses the frame in yet another mode.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
AP_Context ctx = new AP_Context();
ctx.setAlignment(TextAlignment.CENTER);
ctx.setFrame(U8_Frames.borderLight());
ctx.setFrameTopBottomMargin(1);
ctx.setTextTopBottomMargin(1);
ctx.setTextLeftRightMargin(1);

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

ctx.setFrameMode(TA_FrameOptions.THEME_CORNERS_ONLY);
ctx.setFrameTopBottomMargin(0);
ctx.setTextTopBottomMargin(0);
ctx.setTextLeftRightMargin(0);
System.out.println(ap.render(25));

ctx.setFrameMode(TA_FrameOptions.THEME_LINE_TOPBOTTOM);
System.out.println(ap.render(25));

The resulting output for the first setting, added margins, is:

┌─────────────────────────┐
│                         │
│  Lorem ipsum dolor sit  │
│    amet, consetetur     │
│  sadipscing elitr, sed  │
│                         │
└─────────────────────────┘

The resulting output for the second setting, removed margins different frame mode, is:

┌                         ┐
   Lorem ipsum dolor sit
     amet, consetetur
   sadipscing elitr, sed
└                         ┘

The resulting output for the third setting, yet another frame mode, is:

─────────────────────────
  Lorem ipsum dolor sit
    amet, consetetur
  sadipscing elitr, sed
─────────────────────────