TIBCO 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.
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 prefered field measure unit. The report's default measure unit is the pixel.
To change the report level measure:
- Select Window > Preferences >Jaspersoft Studio >Report Designer.
- Find the Default Unit where you can set one of the supported measure units, as shown below:
- Use the drop-down menu to select one of the following measure units:
Changing the Field Measure Unit
- 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 will be 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 will remain 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 Autocompletion
Jaspersoft® Studio has included alias and autocompletion services for measure units. For instance, if you want to use inches, you can type "inch", "inches", or use quote marks. the table below shows the options for entering measure units:
|centimeter||centimeter, centimeters, cm|
|millimeter||millimeter, millimeters, mm|
|meter||meter, meters, m|
|pixel||pixel, pixels, px|
|inch||inch, inches, " (double quote)|
In this way, it is simpler to provide a unit, and to help, an autocompletion system is provided. 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 will be suggested with a popup, and could be selected using the keyboard arrow keys or the mouse, as you can see in the image below:
If a typed value, or measure, is not understood, the background of its field will appear red, and the corresponding value or measure will not changed in the report until a correct value is inserted, as you can see in the following image:
For the width, in the figure above, we have an invalid number (the numerical value can have only digits and dot). The height has "cat" as an invalid measure unit.
Even if Jaspersoft® Studiohandled many measure units, JasperReports works only with pixels. Because of this, pixels is the only measure unit that is allowed in the project file. Jaspersoft® Studio will approximate measurement and convert them to pixels. For example, if you are using centimeters, "5 cm", it will be converted to the nearest pixels value. In this case the 5 centimeters will be converted to 139 pixels (about 4.97 cm)