Description
A function that alternates between true and false for each item within a group. The function value determines when to use an object's color. If the function evaluates to true, the named object is painted with the color=True, else the object is painted with color=False.
Use a property tag to name an object contained in the Item section whose color should be affected by this function.
Example
<expression class="org.jfree.report.modules.misc.beanshell.BSHExpression" name="isVarNeg"> <properties> <property name="expression"> Object getValue() { Object value = dataRow.get("VARIANCE"); if (!(value instanceof Number)) { return Boolean.FALSE; } Number number = (Number) value; if (number.doubleValue() < 0) { return Boolean.TRUE; } return Boolean.FALSE; } </property> </properties> </expression> <function class="org.jfree.report.function.ElementColorFunction" name="changeColor"> <properties> <property name="element">Variance Field</property> <property name="field">isVarNeg</property> <property name="colorTrue">red</property> <property name="colorFalse">black</property> </properties> </function> <items fontname="Arial" fontsize="10" vertical-alignment="middle"> <string-field fieldname="POSITIONTITLE" height="15" vertical-alignment="middle" width="40%" x="15%" y="0"/> <number-field alignment="right" fieldname="ACTUAL" format="$#,##0" height="15" width="15%" x="55%" y="0"/> <number-field alignment="right" fieldname="BUDGET" format="$#,##0" height="15" width="15%" x="70%" y="0"/> <number-field alignment="right" fieldname="VARIANCE" format="$#,##0" height="15" name="Variance Field" width="15%" x="85%" y="0"/> <line color="gray" height="0" weight=".25" width="85%" x1="15%" x2="100%" y1="16" y2="16"/> </items>