Java Reference
In-Depth Information
Adding Rectangles to a Report
Adding a rectangle to a report can be achieved by using the JRXML <rectangle>
element. A rectangle simply outlines the area defined by its <reportElement> sub-
element. We can create rectangles with round corners by setting the radius property
of the <rectangle> element. The following JRXML template illustrates how to create
rectangles in a report:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//
EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="RectangleDemoReport">
<detail>
<band height="100">
<rectangle>
<reportElement x="0" y="0" width="555" height="30"/>
</rectangle>
<rectangle radius="5">
<reportElement x="0" y="70" width="555" height="30"
forecolor="lightGray"/>
<graphicElement pen="4Point"/>
</rectangle>
</band>
</detail>
</jasperReport>
After compiling the above JRXML template, and filling the resulting binary Jasper
template, we should see a report like the following:
Notice how the line outlining the second rectangle is thicker than the first one. This
is because we used the <graphicElement> sub-element of the <rectangle> element.
Just as every text element can contain a <textElement> sub-element, every graphic
element can contain a <graphicElement> sub-element.
 
Search WWH ::




Custom Search