Basic Ideas

The goal is to design a flexible java library which can be used to easily create multiple kinds of reports.  To server this end, the library relies heavily on object oriented methodology, so that components can be extended and customized to individual situations.  The basic hierarchy is as follows:

FieldRenderer This is a class that knows how to draw a single piece of information on a report.  For example: a string, a number, picture.  You initialize a field renderer by giving it the data that it needs to print.  Then, you can pass it a graphics object, a rectangle, and what justification to use, and it draws the data item in the given rectangle.

Example: CommentRenderer

ReportDataModel This is a class that wraps around data to provide reports a single interface to the data which the report prints.  

Example: SQLReportDataModel - Takes a select statement and a database connection, and creates a data model where each row is interpreted as a record, and each field as a separate field in the printed report.

RecordsRenderer This is a class that knows how to draw a record from a ReportDataModel.  The RecordsRenderer controls the arrangement of the data in a record with respect to one another.

Example: HorizRecordsRenderer - Draws the fields next to one another in a row.  Can draw lines around each field, or each row.

AbstractReportItem This class  is passed to the Report for printing.  It is the basic printed unit on a Report.  Classes descended from the AbstractReportItem know how to do page breaks, and control the printing of each record.

Examples: DefaultRecordsItem - takes a ReportDataModel and a RecordsRenderer, and knows how to print the records as requested by the report.

Report The highest class in the hierarchy.  This class takes and print a collection of AbstractReportItems.

The basic stages in creating a report are as follows:

  1. Put all the data you want printed into ReportDataModels.
  2. Create RecordsRenderers to control how the data will be printed.
  3. Create ReportDataItems for each section printed on the report.
  4. Put them in a Report object.
  5. Print the report.
 

Send questions, comments, etc. to trbauer@users.sourceforge.net
Last Modified: Tuesday, May 15, 2001