Jaspersoft Studio can handle a wide variety of measure units, including pixels, centimeters, millimeters and inches. To accomplish this, we included a measure component in Jaspersoft Studio. This component looks like a standard text box with a place to enter a measure unit to the right of the value. You can see an example of this widget in the following image:
This component can handle a different measure unit for each field, if needed.
Configuration
You can set two preferred (default) measure units, one at the field level, the other at the report level. The report level measure is used wherever there is not a preferred field measure unit. The report's default measure unit is the pixel.
To change the report level measure:
1. | Select Window > Preferences > Jaspersoft Studio > Report Designer. |
2. | Find the Default Unit where you can set one of the supported measure units, as shown below: |
3. | Use the drop-down menu to select one of the following measure units: |
• | Pixels |
• | Inches |
• | Millimeters |
• | Centimeters |
• | Meters |
Changing the Field Measure Unit
There are two ways to change a specific field's measure units:
You can insert a new value with the measure unit you want to use in that field. For example, in the figure below, there is an element with size “496 pixel”. By inserting a new value, such as “5 cm”, the new measure unit for this field is switched to centimeter and saved for the current sections. This means that without closing the report and reopening it (or changing it manually) the measure unit for the width of that element remains centimeters. If one value is provided without a measure unit it is assumed that it is the default measure of the field, or, if one isn't provided there, the default unit defined at report level. When a value is inserted manually into the field, no spaces are allowed in the numerical value or in the measure unit, but there can be any number of spaces between the value and the unit.
You can also change the local measure unit of a field by double clicking on the measure unit. A pop-up menu appears with all the available measure units listed. Select one of them to set the field's preferred measure, as shown in the following image:
Alias and Autocomplete
Jaspersoft Studio has included alias and autocomplete services for measure units. The following table shows the options for entering measure units:
Unit | Accepted Values |
centimeter | centimeter, centimeters, cm |
millimeter | millimeter, millimeters, mm |
meter | meter, meters, m |
pixel | pixel, pixels, px |
inch | inch, inches, " (double quote) |
After the value is provided and the first character of a measure unit is be typed, all the available units that start with that character are suggested, and can be selected using the keyboard arrow keys or the mouse.
If a typed value or measure is not understood, the background of its field is colored red; the corresponding value or measure isn't changed in the report until a correct value is inserted.
Approximations
Even through Jaspersoft Studio handled many measure units, JasperReports works only with pixels. Because of this, pixels are the only measure unit that is allowed in the project file. Jaspersoft Studio approximates measurement and convert them to pixels. For example, 5 cm is converted to the nearest whole-number value in pixels. In this case the 5 centimeters is converted to 139 pixels (approximately 4.97 cm).
Recommended Comments
There are no comments to display.