Monday, 1 December 2008

The Definitive Guide to JasperReports - Part5

Couple of Weeks back i started reading The Definitive Guide to JasperReports By Teodor Danciu , Lucian Chirita.

Nice book written by Teodor Danciu , Lucian Chirita.

I wanted to share few qoutations i found from this book found from the next 2 chapters (9-10).

1) Data Grouping

Groups represent a flexible way to organize data on a report. A report group is represented by sequence of consecutive records in the data source that have something in common, like the value of a certain report field.

A report group has three components:
• Group expression
• Group header section
• Group footer section

The value of the associated group expression is what makes group records stick together.This value is what they have in common. When the value of the group expression changes during the iteration through the data source at report-filling time, a group rupture occurs and the corresponding and sections are inserted in the resulting document.

You can have as many groups as you want on a report. The order of groups declared in a report template is important because groups contain each other. One group contains the following group, and so on. When a larger group encounters a rupture, all subsequent groups are reinitialized.

2) The reports we generate will be empty if you do not put some report elements in the report template. Report elements are displayable objects like static texts, text fields, images, lines, and rectangles that you put in your report template sections. Report elements come in two flavors:

• Text elements: Static texts and text fields that display dynamic content
• Graphic elements: Lines, rectangles, ellipses, images, and charts

3) Removing Blank Space

When a report element is not displayed for some reason (e.g., <printWhenExpression> evaluates to Boolean.FALSE, or a repeated value is suppressed), the area where the report element stood at design time will be left empty. This blank space also appears if a text field displays only blank characters or an empty text value. You can eliminate this unwanted blank space on the vertical axis only if certain conditions are met.

For example, say you have three successive text fields, one on top of the other, like this:

TextField1
TextField2
TextField3

If the second field has an empty string as its value or contains a repeated value that you chose to suppress, the output would look like this:

TextField1
TextField3

4) Line Spacing

The amount of space between consecutive lines of text can be set using the lineSpacing attribute:

• Single: The paragraph text advances normally using an offset equal to the text line height (lineSpacing="Single").

• 1.5 Lines: The offset between two consecutive text lines is 1.5 lines (lineSpacing= "1_1_2").

• Double: The space between text lines is double the height of a single text line (lineSpacing="Double").

The font settings for the text elements are also part of the textElement tag.

5) Styled Text

The isStyledText attribute is a flag that indicates whether the text content of the element is pure text or has embedded styling information like colors, fonts, and so on.

6) Font Name

In Java, there are two types of fonts: physical fonts and logical fonts. Physical fonts are the actual font libraries consisting of, for example, TrueType or PostScript Type 1 fonts. The physical fonts may be Arial, Time, Helvetica, Courier, or any number of other fonts, including international fonts.

Logical fonts are the five font types that have been recognized by the Java platform since version 1.0: Serif, Sans-Serif, Monospaced, Dialog, and DialogInput. These logical fonts are not actual font libraries that are installed anywhere on your system. They are merely font type names recognized by the Java runtime, which must be mapped to some physical font that is installed on your system.

In the fontName attribute of the font element or the reportFont element, you must specify the name of a physical font or the name of a logical font. You only need to make sure the font you specify really exists and is available on your system.

7) Hyperlink Target

All hyperlink elements, like text fields, images, and charts, also expose an attribute called hyperlinkTarget. Its purpose is to help customize the behavior of the specified link when it is clicked in the viewer.

Currently, there are only two possible values for this attribute:

• Self: The document to which the hyperlink points will be opened in the current viewer window (hyperlinkTarget="Self").

• Blank: The document to which the hyperlink points will be opened in a new viewer window (hyperlinkTarget="Blank").

If not specified, the hyperlink target is Self by default.

8) Frames
A frame is a report element that behaves like an element container. It is like a rectangle that can contain other report elements. Frames can be nested into one another to any depth.

About the Author

Teodor Danciu is the founder and architect of the JasperReports library, the most popular open source reporting tool, and is now working for JasperSoft. Before joining JasperSoft, Teodor worked for almost 8 years with several French IT companies as a software engineer and team leader on ERP and other medium-to-large database-related enterprise applications using mainly Java technologies and the J2EE platform. Teodor holds a B.S. in computer science from the Academy of Economic Studies in Bucharest.

Lucian Chirita joined Teodor Danciu at JasperSoft in the development of JasperReports library back in 2005, and he quickly became one of the main contributors to the project. Prior to joining JasperSoft, Lucian had 3 years of software engineering experience on several Java/J2EE products and applications. His contributions to JasperReports include support for crosstabs and integration with data query technologies such as Hibernate and OLAP. Lucian holds an M.S. in computer science from the University of Bucharest.

No comments: