org.jfree.report.demo.helper
Class FontChangeFunction

java.lang.Object
  extended byorg.jfree.report.function.AbstractFunction
      extended byorg.jfree.report.demo.helper.FontChangeFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener, java.io.Serializable

public class FontChangeFunction
extends AbstractFunction
implements java.io.Serializable

This is a function used in report4-demo. The function demonstrates how to alter an elements property during the report generation. The elements font is changed base on the data provided in the reports datasource.

For every new item row in the report, the font for that row is changed to the fontname specified in the second column of the report data source.

Parameters:
The function expects the name of a field in the item band in the parameter "element". This functions value will always be null.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
FontChangeFunction()
          DefaultConstructor.
 
Method Summary
 java.lang.String getElement()
          Returns the name of the element that should get the font set.
 java.lang.Object getValue()
          Returns the value calculated by this function.
 void initialize()
          Performs the functions initialisation.
 void itemsAdvanced(ReportEvent event)
          Before an ItemBand is printed, the report generator will call itemsAdvanced for all functions in the function collection.
 void setElement(java.lang.String name)
          Defines the name of the text element that gets its font altered.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getInstance, getName, getProperties, getProperty, getProperty, groupFinished, groupStarted, isActive, itemsFinished, itemsStarted, reportDone, reportFinished, reportInitialized, reportStarted, setDataRow, setDependencyLevel, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontChangeFunction

public FontChangeFunction()
DefaultConstructor.

Method Detail

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Before an ItemBand is printed, the report generator will call itemsAdvanced for all functions in the function collection. This is the right place to alter the font of the element defined in the "element" property, so that every ItemBand has the font set, that is defined in the data model.

Specified by:
itemsAdvanced in interface ReportListener
Overrides:
itemsAdvanced in class AbstractFunction
Parameters:
event - the report event.

initialize

public void initialize()
                throws FunctionInitializeException
Performs the functions initialisation. The initialisation will fail, if the function has no valid name or the required parameter "element" is missing.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractFunction
Throws:
FunctionInitializeException - if the element name has not been specified.
See Also:
setElement(java.lang.String)

setElement

public void setElement(java.lang.String name)
Defines the name of the text element that gets its font altered. If the element does not exist or is no text element, the function will do nothing.

This functions property is reachable by using the key "element" on getProperty.

Parameters:
name - the element name.

getElement

public java.lang.String getElement()
Returns the name of the element that should get the font set. Returns an empty string, if the property is not set.

Returns:
the element name.

getValue

public java.lang.Object getValue()
Returns the value calculated by this function. As this function does not calculate values, this method does always return null.

Specified by:
getValue in interface Expression
Returns:
always null, as this function does not calculate something.