iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideFigure 8-11Adding a new style to the documentYou can define many properties for a style, which are then shown in the property sheet (Figure 8-12). The only property valueof a style that must be set is Name. All other properties are optional.Leave the default value as-is when you don’t want to set a specific value for a property. To restore a default value, right-clickthe property name and select Reset to default value. (This works with all the element properties that support a default value.)Figure 8-12All the properties of a style132

Fonts and StylesTo apply a style to an element, select the element and set the desired style in the property sheet (Figure 8-13).Figure 8-13Style property of an elementYou can choose a specific style to be the default style for your report. When setting a default style, all the element propertieshaving an unspecified value will implicitly inherit their value from the default style. The Parent style property defines the stylefrom which the current one inherits default properties.The remaining properties fall into the following four categories:• Common properties• Graphics properties• Border and padding properties• Text propertiesFor details about the properties, refer to Chapter 5.8.7 Creating Style ConditionsYou can design your report so that a style changes dynamically. For example, you can set the foreground color of a textfield toblack if a particular value is positive and red when it is negative. iReport creates conditional styles as deriving from an existingstyle, for which we set the condition and change some properties.To apply a condition to a style, right-click the style node and select Add Conditional Style (see Figure 8-14).Figure 8-14Setting a conditional styleYou can reconfigure all the values of the parent style. The new values will be used instead of the ones defined in the parentwhen the condition is true. The new conditional style will appear in the outline view. You need to set the condition (actually anexpression that returns a Boolean value) that will be evaluated during the rendering of elements that use the style.In the condition expression you can use all the properties of the report object. Please note that the conditions cannot be generic,for instance, you cannot set a condition like “if the number is positive” or “if the string is null.” You must be very specific,specifying, for example, that a particular value (field, parameter, variable or any expression involving them) must be positiveor null, and so on.133

Fonts and StylesTo apply a style to an element, select the element and set the desired style in the property sheet (Figure 8-13).Figure 8-13Style property of an elementYou can choose a specific style to be the default style for your report. When setting a default style, all the element propertieshaving an unspecified value will implicitly inherit their value from the default style. The Parent style property defines the stylefrom which the current one inherits default properties.The remaining properties fall into the following four categories:• Common properties• Graphics properties• Border and padding properties• Text propertiesFor details about the properties, refer to Chapter 5.8.7 Creating Style ConditionsYou can design your report so that a style changes dynamically. For example, you can set the foreground color of a textfield toblack if a particular value is positive and red when it is negative. <strong>iReport</strong> creates conditional styles as deriving from an existingstyle, for which we set the condition and change some properties.To apply a condition to a style, right-click the style node and select Add Conditional Style (see Figure 8-14).Figure 8-14Setting a conditional styleYou can reconfigure all the values of the parent style. The new values will be used instead of the ones defined in the parentwhen the condition is true. The new conditional style will appear in the outline view. You need to set the condition (actually anexpression that returns a Boolean value) that will be evaluated during the rendering of elements that use the style.In the condition expression you can use all the properties of the report object. Please note that the conditions cannot be generic,for instance, you cannot set a condition like “if the number is positive” or “if the string is null.” You must be very specific,specifying, for example, that a particular value (field, parameter, variable or any expression involving them) must be positiveor null, and so on.133

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!