Skip to content
This repository has been archived by the owner on Dec 21, 2018. It is now read-only.

Commit

Permalink
First GitHub Commit
Browse files Browse the repository at this point in the history
Signed-off-by: David Farrell <[email protected]>
  • Loading branch information
davidpfarrell committed Aug 29, 2011
0 parents commit 664874e
Show file tree
Hide file tree
Showing 10 changed files with 1,611 additions and 0 deletions.
339 changes: 339 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

128 changes: 128 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
Just a simple set of classes to help print text in tabulated form.

With these classes you can organize 'cells' of data into rows and columns.
Each cell can contain multiple lines of text and may specify a horizontal
alignment (left, center, right) and a vertical alignment (top, center, bottom).

When you are ready to print the data, these classes will ensure that all cells
in a given column have the same width and all cells in a given row have
the same height.

Below is a little test proggy and, below that, the output of the proggy.

--- TestTableFormatter.java ---
import com.inamik.utils.*;
import java.util.List;

public class TestTableFormatter
{
public static void main(String[] args)
{
TableFormatter tf = new SimpleTableFormatter(true)
.nextRow()
.nextCell()
.addLine(".")
.nextCell()
.addLine("..........")
.nextCell()
.addLine(" ")
.nextCell()
.addLine("..........")
.nextCell()
.addLine(" ")
.nextCell()
.addLine("..........")
.nextRow()
.nextCell()
.addLine(".")
.addLine(".")
.addLine(".")
.addLine(".")
.nextCell(TableFormatter.ALIGN_LEFT, TableFormatter.VALIGN_TOP)
.addLine("Left")
.addLine("Top")
.nextCell()
.nextCell(TableFormatter.ALIGN_LEFT, TableFormatter.VALIGN_CENTER)
.addLine("Left")
.addLine("Center")
.nextCell()
.nextCell(TableFormatter.ALIGN_LEFT, TableFormatter.VALIGN_BOTTOM)
.addLine("Left")
.addLine("Bottom")
.nextRow().nextCell().addLine(" ")
.nextRow()
.nextCell()
.addLine(".")
.addLine(".")
.addLine(".")
.addLine(".")
.nextCell(TableFormatter.ALIGN_CENTER, TableFormatter.VALIGN_TOP)
.addLine("Center")
.addLine("Top")
.nextCell()
.nextCell(TableFormatter.ALIGN_CENTER, TableFormatter.VALIGN_CENTER)
.addLine("Center")
.addLine("Center")
.nextCell()
.nextCell(TableFormatter.ALIGN_CENTER, TableFormatter.VALIGN_BOTTOM)
.addLine("Center")
.addLine("Bottom")
.nextRow().nextCell().addLine(" ")
.nextRow()
.nextCell()
.addLine(".")
.addLine(".")
.addLine(".")
.addLine(".")
.nextCell(TableFormatter.ALIGN_RIGHT, TableFormatter.VALIGN_TOP)
.addLine("Right")
.addLine("Top")
.nextCell()
.nextCell(TableFormatter.ALIGN_RIGHT, TableFormatter.VALIGN_CENTER)
.addLine("Right")
.addLine("Center")
.nextCell()
.nextCell(TableFormatter.ALIGN_RIGHT, TableFormatter.VALIGN_BOTTOM)
.addLine("Right")
.addLine("Bottom")
;
System.out.println("\t 1 2 3 4");
System.out.println("\t1234567890123456789012345678901234567890");
String[] table = tf.getFormattedTable();

for (int i = 0, size = table.length; i < size; i++)
{
System.out.println( (i + 1) + "\t" + table[i]);
}

System.out.println();
System.out.println("Table size = " + tf.getTableWidth() + " x " + tf.getTableHeight());
}
}
--- Test Program Output ---
1 2 3 4
1234567890123456789012345678901234567890
1 +-+----------+-+----------+-+----------+
2 |.|..........| |..........| |..........|
3 +-+----------+-+----------+-+----------+
4 |.|Left | | | | |
5 |.|Top | |Left | | |
6 |.| | |Center | |Left |
7 |.| | | | |Bottom |
8 +-+----------+-+----------+-+----------+
9 | | | | | | |
10 +-+----------+-+----------+-+----------+
11 |.| Center | | | | |
12 |.| Top | | Center | | |
13 |.| | | Center | | Center |
14 |.| | | | | Bottom |
15 +-+----------+-+----------+-+----------+
16 | | | | | | |
17 +-+----------+-+----------+-+----------+
18 |.| Right| | | | |
19 |.| Top| | Right| | |
20 |.| | | Center| | Right|
21 |.| | | | | Bottom|
22 +-+----------+-+----------+-+----------+

Table size = 40 x 22
12 changes: 12 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TODO
====

* Not sure there needs to be an interface.

* Considering seperating the row/table formatting methods into a different
class/interface. Maybe change the name to TextTable and then create a
seperate TableFormatter class.

* Also considering just moving the class as is into SimpleTextTable, which
would leave room for a ComplexTextTable that might allow more control over
the table formatting (i.e. Specifying max column widths and/or word wrap)
88 changes: 88 additions & 0 deletions TestTableFormatter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import com.inamik.utils.*;
import java.util.List;

public class TestTableFormatter
{
public static void main(String[] args)
{
TableFormatter tf = new SimpleTableFormatter(true) // true = show border
.nextRow()
.nextCell()
.addLine(".")
.nextCell()
.addLine("..........")
.nextCell()
.addLine(" ")
.nextCell()
.addLine("..........")
.nextCell()
.addLine(" ")
.nextCell()
.addLine("..........")
.nextRow()
.nextCell()
.addLine(".")
.addLine(".")
.addLine(".")
.addLine(".")
.nextCell(TableFormatter.ALIGN_LEFT, TableFormatter.VALIGN_TOP)
.addLine("Left")
.addLine("Top")
.nextCell()
.nextCell(TableFormatter.ALIGN_LEFT, TableFormatter.VALIGN_CENTER)
.addLine("Left")
.addLine("Center")
.nextCell()
.nextCell(TableFormatter.ALIGN_LEFT, TableFormatter.VALIGN_BOTTOM)
.addLine("Left")
.addLine("Bottom")
.nextRow().nextCell().addLine(" ")
.nextRow()
.nextCell()
.addLine(".")
.addLine(".")
.addLine(".")
.addLine(".")
.nextCell(TableFormatter.ALIGN_CENTER, TableFormatter.VALIGN_TOP)
.addLine("Center")
.addLine("Top")
.nextCell()
.nextCell(TableFormatter.ALIGN_CENTER, TableFormatter.VALIGN_CENTER)
.addLine("Center")
.addLine("Center")
.nextCell()
.nextCell(TableFormatter.ALIGN_CENTER, TableFormatter.VALIGN_BOTTOM)
.addLine("Center")
.addLine("Bottom")
.nextRow().nextCell().addLine(" ")
.nextRow()
.nextCell()
.addLine(".")
.addLine(".")
.addLine(".")
.addLine(".")
.nextCell(TableFormatter.ALIGN_RIGHT, TableFormatter.VALIGN_TOP)
.addLine("Right")
.addLine("Top")
.nextCell()
.nextCell(TableFormatter.ALIGN_RIGHT, TableFormatter.VALIGN_CENTER)
.addLine("Right")
.addLine("Center")
.nextCell()
.nextCell(TableFormatter.ALIGN_RIGHT, TableFormatter.VALIGN_BOTTOM)
.addLine("Right")
.addLine("Bottom")
;
System.out.println("\t 1 2 3 4");
System.out.println("\t1234567890123456789012345678901234567890");
String[] table = tf.getFormattedTable();

for (int i = 0, size = table.length; i < size; i++)
{
System.out.println( (i + 1) + "\t" + table[i]);
}

System.out.println();
System.out.println("Table size = " + tf.getTableWidth() + " x " + tf.getTableHeight());
}
}
50 changes: 50 additions & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
iNamik TableFormatter for Java [email protected]@ (@build.date@)

Version History
===============

Changes in v0.96.3

* First GIT Commit

Changes in v0.96.2

* Updated src files to include new GPL text from FSF

Changes in v0.96.1

* Updated LICENSE.txt from FSF with new address

* Modified build.xml to include a copy of the 'rendered' VERSION.txt
as a stand-alone file in the dist folder

* Minor changes to VERSION.txt

Changes in v0.96.0

* Added example java file "TestTableFormatter.java"

* Moved TODO section from VERSION.txt into TODO.txt

* Minor build changes

Changes in v0.95.0

* Bumped version to 0.95.0 in preparation for FreshMeat.net release.

* Updated build files to match new build patterns since last change.
- Project name moved to build.properties
- Build & Dist folders now include project name+version

* Updated Eclipse build script to refresh project after build.

Changes in v0.9.1

* Revamped the entire Interface
Changed to be more 'cell' oriented

* Made a little more generic to give the user more options.

Changes in v0.9.0

* All development up to this point :)
7 changes: 7 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# $Id: build.properties,v 1.6 2010/08/08 18:34:43 dave Exp $
build.version=0.96.3
project.name=com.inamik.utils.tableformatter-${build.version}
src.dir=src
build.dir=build/${project.name}
dist.dir=dist/${project.name}
dist.text_files=LICENSE.txt,README.txt,TODO.txt,TestTableFormatter.java
Loading

0 comments on commit 664874e

Please sign in to comment.