
/**
 * dumb wrapper for document processing
 * @author cbrown
 *
 */
public class Document {
	
	private static com.lowagie.text.rtf.RtfFont TITLE_FONT = 
		new com.lowagie.text.rtf.RtfFont("Times New Roman", 18,
				com.lowagie.text.rtf.RtfFont.BOLD );
	private static com.lowagie.text.rtf.RtfFont SECTION_FONT = 
		new com.lowagie.text.rtf.RtfFont("Times New Roman", 14);
	private static com.lowagie.text.rtf.RtfFont HEADER_FONT = 
		new com.lowagie.text.rtf.RtfFont("Times New Roman", 12,
				com.lowagie.text.rtf.RtfFont.BOLDITALIC );
	private static com.lowagie.text.rtf.RtfFont BODY_FONT = 
		new com.lowagie.text.rtf.RtfFont("Courier New", 12);	

	// document object
	private com.lowagie.text.Document document;
	
	/**
	 * open the document
	 * @param filename of document
	 * @throws FileNotFoundException 
	 */
	public void open( String filename ) throws java.io.FileNotFoundException {	
		document = new com.lowagie.text.Document();
		com.lowagie.text.rtf.RtfWriter2.getInstance( document, 
				new java.io.FileOutputStream( filename ) );
		document.open();
	} // open
	
	/**
	 * close the document
	 */
	public void close() {
		document.close();
	}
	
	/**
	 * create a paragraph
	 * @param content of the paragraph
	 * @throws com.lowagie.text.DocumentException 
	 */
	public void paragraph( String content, com.lowagie.text.rtf.RtfFont font, 
			float indent, float spacing ) throws com.lowagie.text.DocumentException {
		com.lowagie.text.Paragraph paragraph = new com.lowagie.text.Paragraph( content, font);
		paragraph.setIndentationLeft( indent );
		paragraph.setSpacingBefore( spacing );
		document.add( paragraph );
	}

	/**
	 * create a title paragraph
	 * @param content of the paragraph
	 * @throws com.lowagie.text.DocumentException 
	 */
	public void title( String content ) throws com.lowagie.text.DocumentException {
		paragraph( content, TITLE_FONT, 0F, 0.5F );
	}

	/**
	 * create a section paragraph
	 * @param content of the paragraph
	 * @throws com.lowagie.text.DocumentException 
	 */
	public void section( String content ) throws com.lowagie.text.DocumentException {
		paragraph( content, SECTION_FONT, 0.25F, 0.5F );
	}

	/**
	 * create a header paragraph
	 * @param content of the paragraph
	 * @throws com.lowagie.text.DocumentException 
	 */
	public void header( String content ) throws com.lowagie.text.DocumentException {
		paragraph( content, HEADER_FONT, 0.5F, 0.25F );
	}

	/**
	 * create a body paragraph
	 * @param content of the paragraph
	 * @return the formatted paragraph
	 */
	public void body( String content ) throws com.lowagie.text.DocumentException {
		paragraph( content, BODY_FONT, 0.75F, 0.25F );
	}

	/**
	 * main
	 */
	public static void main( String [] args ) throws Throwable {
		Document doc = new Document();
		doc.open( "dummy.rtf" );
		doc.title( "TITLE" );
		doc.section( "Section 1" );
		doc.header( "Header 1" );
		doc.body( "body" );
		doc.header( "Header 2" );
		doc.body( "body" );
		doc.section( "Section 2" );
		doc.header( "Header 1" );
		doc.body( "body" );
		doc.header( "Header 2" );
		doc.body( "body" );
		doc.close();
	} // main
	
} // Document
