Java Code Examples for de.vandermeer.asciitable.AsciiTable#addRow()

The following examples show how to use de.vandermeer.asciitable.AsciiTable#addRow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AT_00i_AddColumn_RendersToClusterWidth.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	class ObjectRendersToClusterWidth implements RendersToClusterWidth{
		@Override
		public Collection<String> renderAsCollection(int width) {
			return ClusterElementTransformer.create().transform(
					Text_To_FormattedText.justified(new LoremIpsum().getWords(30), width),
					StrBuilder_To_String.create(),
					ArrayListStrategy.create()
			);
		}
	}

	at.addRule();
	at.addRow(new ObjectRendersToClusterWidth());
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 2
Source File: AT_06d_NewGrid.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	TA_Grid myGrid = TA_Grid.create("grid using UTF-8 light border characters")
			.addCharacterMap(TA_GridConfig.RULESET_NORMAL, ' ', '#', '&', '#', '#', '%', '%', '+', '+', '+', '#', '%')
	;

	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("rc 11", "rc 12");
	at.addRule();
	at.addRow("rc 21", "rc 22");
	at.addRule();
	at.getContext().setWidth(13);

	at.getContext().setGrid(myGrid);
	System.out.println(at.render());
	// end::example[]
}
 
Example 3
Source File: AT_05_MarginBehavior.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("row 1 col 1", "row 1 col 2");
	at.addRule();
	at.addRow("row 2 col 1", "row 2 col 2");
	at.addRule();

	at.getContext().setFrameTopChar('v');
	at.getContext().setFrameBottomChar('^');
	at.getContext().setFrameLeftChar('>');
	at.getContext().setFrameRightChar('<');

	at.getContext().setFrameTopMargin(1);
	at.getContext().setFrameBottomMargin(2);
	at.getContext().setFrameLeftMargin(3);
	at.getContext().setFrameRightMargin(4);

	System.out.println(at.render(39));
	// end::example[]
}
 
Example 4
Source File: AT_06b_GridRuleStyle.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("rc 11", "rc 12");
	at.addLightRule();
	at.addRow("rc 21", "rc 22");
	at.addStrongRule();
	at.addRow("rc 31", "rc 32");
	at.addHeavyRule();
	at.getContext().setWidth(13);

	at.getContext().setGrid(A8_Grids.lineDoubleBlocks());
	System.out.println(at.render());
	// end::example[]
}
 
Example 5
Source File: AT_00d_AddColumn_HasText.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	class ObjectHasText implements HasText{
		@Override
		public String getText() {
			return new LoremIpsum().getWords(10);
		}
	}

	at.addRule();
	at.addRow(new ObjectHasText());
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 6
Source File: AT_06a_Grids.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("rc 11", "rc 12");
	at.addRule();
	at.addRow("rc 21", "rc 22");
	at.addRule();
	at.getContext().setWidth(13);

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

	at.getContext().setGrid(A7_Grids.minusBarPlusEquals());
	System.out.println(at.render());

	at.getContext().setGrid(A8_Grids.lineDoubleBlocks());
	System.out.println(at.render());

	at.getContext().setGrid(U8_Grids.borderDoubleLight());
	System.out.println(at.render());

	at.getContext().setGrid(U8_Grids.borderDouble());
	System.out.println(at.render());
	// end::example[]
}
 
Example 7
Source File: AT_04c_Padding_Cell.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("row 1 col 1", "row 1 col 2");
	at.addRule();
	AT_Cell cell = at.addRow("row 2 col 1", "row 2 col 2").getCells().get(1);
	at.addRule();

	cell.getContext().setPaddingTopChar('v');
	cell.getContext().setPaddingBottomChar('^');
	cell.getContext().setPaddingLeftChar('>');
	cell.getContext().setPaddingRightChar('<');
	cell.getContext().setTextAlignment(TextAlignment.CENTER);
	cell.getContext().setPadding(1);
	System.out.println(at.render(33));
	// end::example[]
}
 
Example 8
Source File: AT_07b_Width_Fixed.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("col1", "col2", "col3");
	at.addRule();

	at.getRenderer().setCWC(new CWC_FixedWidth().add(10).add(20).add(30));
	System.out.println(at.render());

	at.getRenderer().setCWC(new CWC_FixedWidth().add(5).add(10).add(15));
	System.out.println(at.render());

	at.getRenderer().setCWC(new CWC_FixedWidth().add(3).add(5).add(7));
	System.out.println(at.render());
	// end::example[]
}
 
Example 9
Source File: AT_09b_ConditionalLinebreak.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
	public void showOutput(){
		// tag::example[]
		String text = "line 1<br>" +
			"line 2<br/>" +
			"line three \n still line three"
		;
//		String text = new LoremIpsum().getParagraphs(1) + "\r\n\n<br><br><br>" + new LoremIpsum().getParagraphs(1);

		AsciiTable at = new AsciiTable();
		at.addRule();
		at.addRow(text);
		at.addRule();
		at.setTextAlignment(TextAlignment.LEFT);
		System.out.println(at.render(50));
		// end::example[]
	}
 
Example 10
Source File: AT_04b_Padding_Row.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("row 1 col 1", "row 1 col 2");
	at.addRule();
	AT_Row row = at.addRow("row 2 col 1", "row 2 col 2");
	at.addRule();

	row.setPaddingTopChar('v');
	row.setPaddingBottomChar('^');
	row.setPaddingLeftChar('>');
	row.setPaddingRightChar('<');
	row.setTextAlignment(TextAlignment.CENTER);
	row.setPadding(1);
	System.out.println(at.render(33));
	// end::example[]
}
 
Example 11
Source File: AT_07e_LongestWordMax.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("first", "information");
	at.addRule();
	at.addRow("second", "info");
	at.addRule();

	at.getRenderer().setCWC(new CWC_LongestWordMax(8));
	System.out.println(at.render());

	at.getRenderer().setCWC(new CWC_LongestWordMax(new int[]{4,-1}));
	System.out.println(at.render());
	// end::example[]
}
 
Example 12
Source File: AT_00f_AddColumn_DoesRender.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	class ObjectDoesRender implements DoesRender{
		@Override
		public String render() {
			return new LoremIpsum().getWords(10);
		}
	}

	at.addRule();
	at.addRow(new ObjectDoesRender());
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 13
Source File: AT_07f_LongestWordMin.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("first", "information");
	at.addRule();
	at.addRow("second", "info");
	at.addRule();

	at.getRenderer().setCWC(new CWC_LongestWordMin(9));
	System.out.println(at.render());

	at.getRenderer().setCWC(new CWC_LongestWordMin(new int[]{-1,30}));
	System.out.println(at.render());
	// end::example[]
}
 
Example 14
Source File: AT_03a_AlignmentTable.java    From asciitable with Apache License 2.0 5 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	String text = new LoremIpsum().getWords(9);
	at.addRule();
	at.addRow(text, text, text);
	at.addRule();
	at.addRow(text, text, text);
	at.addRule();
	at.setTextAlignment(TextAlignment.RIGHT);
	System.out.println(at.render(76));
	// end::example[]
}
 
Example 15
Source File: AT_09c_ListWithLinebreaks.java    From asciitable with Apache License 2.0 5 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("column with a list using conditional line breaks", " * list item one<br> * list item two<br> * list item three");
	at.addRule();
	at.setTextAlignment(TextAlignment.LEFT);
	at.getRenderer().setCWC(new CWC_FixedWidth().add(20).add(25));
	System.out.println(at.render(50));
	// end::example[]
}
 
Example 16
Source File: AT_01f_5Columns.java    From asciitable with Apache License 2.0 5 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("row1 (col1)", "text (col2)", "text (col3)", "text (col4)", "text (col5)");
	at.addRule();
	at.addRow("row2 (col1)", "text (col2)", "text (col3)", "text (col4)", "text (col5)");
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 17
Source File: AT_09a_URIs.java    From asciitable with Apache License 2.0 5 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]", "scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]");
	at.addRule();
	at.addRow(null, "scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]");
	at.addRule();
	at.addRow("abc://username:[email protected]:123/path/data?key=value#fragid1", "abc://username:[email protected]:123/path/data?key=value#fragid1");
	at.addRule();
	at.addRow(null, "abc://username:[email protected]:123/path/data?key=value#fragid1");
	at.addRule();
	at.addRow("urn:example:mammal:monotreme:echidna", "urn:example:mammal:monotreme:echidna");
	at.addRule();
	at.addRow(null, "urn:example:mammal:monotreme:echidna");
	at.addRule();
	at.addRow("http://www.example.com/test1/test2", "http://www.example.com/test1/test2");
	at.addRule();
	at.addRow(null, "http://www.example.com/test1/test2");
	at.addRule();
	at.addRow("mailto:[email protected]", "mailto:[email protected]");
	at.addRule();
	at.addRow(null, "mailto:[email protected]");
	at.addRule();

	System.out.println(at.render(73));
	// end::example[]
}
 
Example 18
Source File: AT_01d_3Columns.java    From asciitable with Apache License 2.0 5 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("first row (col1)", "some information (col2)", "more info (col3)");
	at.addRule();
	at.addRow("second row (col1)", "some information (col2)", "more info (col3)");
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 19
Source File: AT_03b_AlignmentRow.java    From asciitable with Apache License 2.0 5 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	String text = new LoremIpsum().getWords(9);
	at.addRule();
	at.addRow(text, text, text);
	at.addRule();
	AT_Row row = at.addRow(text, text, text);
	at.addRule();
	row.setTextAlignment(TextAlignment.RIGHT);
	System.out.println(at.render(76));
	// end::example[]
}
 
Example 20
Source File: AT_06c_GridThemes.java    From asciitable with Apache License 2.0 4 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	at.addRule();
	at.addRow("rc 11", "rc 12");
	at.addRule();
	at.addRow("rc 21", "rc 22");
	at.addRule();
	at.getContext().setWidth(13);

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

	at.getContext().setGridTheme(TA_GridThemes.NONE);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.CORNERS);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.CC);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.HORIZONTAL);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.VERTICAL);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.INSIDE);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.OUTSIDE);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.LEFT);
	System.out.println(at.render());

	at.getContext().setGridTheme(TA_GridThemes.TOPBOTTOM);
	System.out.println(at.render());
	// end::example[]
}