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

The following examples show how to use de.vandermeer.asciitable.AsciiTable#addRule() . 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_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 2
Source File: AT_07c_LongestLine.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("0", "1", "22", "333", "4444");
	at.addRule();
	CWC_LongestLine cwc = new CWC_LongestLine();

	at.getRenderer().setCWC(cwc);
	System.out.println(at.render());

	cwc.add(4, 0);
	System.out.println(at.render());

	cwc.add(6, 0).add(0, 0).add(0, 0).add(0, 2);
	System.out.println(at.render());

	at.addRow("0", "1", "22", "333<br>55555", "4444");
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 3
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 4
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 5
Source File: AT_00h_AddColumn_RendersToCluster.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 ObjectRendersToCluster implements RendersToCluster{
		@Override
		public Collection<String> renderAsCollection() {
			ArrayList<String> text = new ArrayList<>();
			text.add(new LoremIpsum().getWords(10));
			text.add(new LoremIpsum().getWords(10));
			text.add(new LoremIpsum().getWords(10));
			return text;
		}
	}

	at.addRule();
	at.addRow(new ObjectRendersToCluster());
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 6
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 7
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 8
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 9
Source File: AT_03_AlignmentOptions.java    From asciitable with Apache License 2.0 6 votes vote down vote up
@Override
public void showOutput(){
	// tag::example[]
	AsciiTable at = new AsciiTable();
	String text = new LoremIpsum().getWords(19);
	AT_Row row;
	at.addRule();
	row = at.addRow(text, text, text);
	row.getCells().get(0).getContext().setTextAlignment(TextAlignment.JUSTIFIED_LEFT);
	row.getCells().get(1).getContext().setTextAlignment(TextAlignment.JUSTIFIED);
	row.getCells().get(2).getContext().setTextAlignment(TextAlignment.JUSTIFIED_RIGHT);
	at.addRule();
	row = at.addRow(text, text, text);
	row.getCells().get(0).getContext().setTextAlignment(TextAlignment.LEFT);
	row.getCells().get(1).getContext().setTextAlignment(TextAlignment.CENTER);
	row.getCells().get(2).getContext().setTextAlignment(TextAlignment.RIGHT);
	at.addRule();
	System.out.println(at.render(79));
	// end::example[]
}
 
Example 10
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 11
Source File: AT_00g_AddColumn_DoesRenderToWidth.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 ObjectDoesRenderToWidth implements DoesRenderToWidth{
		@Override
		public String render(int width) {
			return new StrBuilder().appendWithSeparators(Text_To_FormattedText.left(new LoremIpsum().getWords(10), width), "\n").toString();
		}
	}

	at.addRule();
	at.addRow(new ObjectDoesRenderToWidth());
	at.addRule();
	System.out.println(at.render(30));
	// end::example[]
}
 
Example 12
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 13
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 14
Source File: AT_07d_LongestWord.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_Row row1 = at.addRow("first", "information");
	at.addRule();
	AT_Row row2 = at.addRow("second", "info");
	at.addRule();

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

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

	at.setPaddingLeftRight(0);
	row1.getCells().get(0).getContext().setPaddingLeftRight(2);
	row1.getCells().get(1).getContext().setPaddingLeftRight(3);
	row2.getCells().get(0).getContext().setPaddingLeftRight(3);
	row2.getCells().get(1).getContext().setPaddingLeftRight(4);
	System.out.println(at.render());
	// end::example[]
}
 
Example 15
Source File: AT_04a_Padding_Table.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.setPaddingTopChar('v');
	at.setPaddingBottomChar('^');
	at.setPaddingLeftChar('>');
	at.setPaddingRightChar('<');
	at.setTextAlignment(TextAlignment.CENTER);
	at.setPadding(1);
	System.out.println(at.render(33));
	// end::example[]
}
 
Example 16
Source File: AT_00_Getting_Started.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("row 1 col 1", "row 1 col 2");
	at.addRule();
	at.addRow("row 2 col 1", "row 2 col 2");
	at.addRule();
	System.out.println(at.render());
	// end::example[]
}
 
Example 17
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 18
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 19
Source File: AT_01c_2Columns.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)");
	at.addRule();
	at.addRow("second row (col1)", "some information (col2)");
	at.addRule();
	System.out.println(at.render(65));
	// end::example[]
}
 
Example 20
Source File: AT_01b_1Column.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("Table Heading");
	at.addRule();
	at.addRow("first row (col1)");
	at.addRule();
	at.addRow("second row (col1)");
	at.addRule();
	System.out.println(at.render(30));
	// end::example[]
}