1. Overview
In the designer, the display of the parameters such as the layout, background, and display mode of the parameter pane can be controlled by the design of the parameter pane.The question is, how to control the related attributes of the parameters in the program? This can be achieved through the ReportParameterAttr class.
The following is a detailed introduction to the usage of this class. It is assumed that the background color of the parameter pane is cyan and displayed in the center. The following demonstrates how to achieve this requirement.
2. Example
2.1 Read Report Parameter Attributes
1) First we read a template and save it as a WorkBook, as follows:
WorkBook workbook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook("//doc//Primary//Parameter//Parameter.cpt");
2) Then get the parameter attribute of WorkBook ReportParameterAttr:
ReportParameterAttr paraAttr = workbook.getReportParameterAttr();
2.2 Layout of the parameter pane
Call the method setAlign on the parameter attribute to set the center. The parameter value equal to 0 means left, 1 means center, 2 means right.
paraAttr.setAlign(1);
2.3 Set Parameter Background
Get the color background object, set the color to (0,255,255), and set the background of the parameter attribute object. In addition to color backgrounds, It is common to make use of gradient backgrounds, picture backgrounds, pattern backgrounds, and texture backgrounds.
Background background = ColorBackground.getInstance(new Color(0, 255, 255));
paraAttr.setBackground(background);
2.4 Reset Parameter Properties
After changing a series of parameter attributes, the user may need to add the changed ReportParameterAttr to WorkBook again:
workbook.setReportParameterAttr(paraAttr);
3. Preview
For the code details of the above example, please check out: