ElementVisibilitySwitchFunction

Description

A function that alternates between true and false for each item within a group. The functions value affects a defined objects visibility. If the function evaluates to true, the named object is visible, else the element is invisible.

Objects do not define their own background color attribute. To create a background, a rectangle shape element must be created behind the element.

The ElementVisibilitySwitchFunction is used to trigger the visibility of an named object. If the object is in the background, it will alternate between an object being visible and not being visible.

The ElementVisibilitySwitchFunction defines two parameters:

  • element defines the name of the element aka object in the item band that should be modified. The element must be named using the "name" attribute, only the first occurrence of that named element will be modified.
  • initial-state defines the initial state of the function. (true or false) defaults to false. This is the reverts of the object's visibility (set to false to start with an visible object, set to true to hide the object in the first item row).
<function name="bkgrndTrggr" class="org.jfree.report.function.ElementVisibilitySwitchFunction">
  <properties>
     <property name="element">background</property>
     <property name="numberOfElements">1</property>
  </properties>

<items fontname="Arial" fontsize="9" fontstyle="plain" height="12" layout-cachable="false" visible="true" vertical-alignment="middle">
  <rectangle name="background" x="15%" y="0" width="70%" height="100%" color="#DFDFDF" weight="0"/>
  <string-field height="12" width="55%" fieldname="CUSTOMERNAME" x="15%" alignment="left" name="URL-Field" />
  <number-field height="12" width="15%" fieldname="QUANTITYORDERED" x="70%" alignment="right" format="###,###.00" />
</items>