com.jrefinery.report.function
Class ElementColorFunction

java.lang.Object
  |
  +--com.jrefinery.report.function.AbstractFunction
        |
        +--com.jrefinery.report.function.ElementColorFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener, java.io.Serializable

public class ElementColorFunction
extends AbstractFunction
implements java.io.Serializable

A function that alternates between true and false for each item within a group. The functions value affects a defined elements color. If the function evaluates to true, the named element is painted with the elementColorTrue, else the element is painted with elementColorFalse.

Use the property element to name an element contained in the ItemBand whose color should be affected by this function. All colors have the color 'black' by default.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String ELEMENT_PROPERTY
          the Property key for the name of the ItemBand element.
static java.lang.String FIELD_PROPERTY
          Literal text for the 'field' property.
 
Fields inherited from interface com.jrefinery.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
ElementColorFunction()
          Default constructor.
 
Method Summary
 java.lang.String getElement()
          Returns the element name.
 java.awt.Color getElementColorFalse()
          Returns the color for false values.
 java.awt.Color getElementColorTrue()
          Returns the color for true values.
 java.lang.String getField()
          Returns the field used by the function.
 java.lang.Object getValue()
          Return the current expression value.
 void initialize()
          Checks that the function has been correctly initialized.
 void itemsAdvanced(ReportEvent event)
          Receives notification that a row of data is being processed.
 void setElement(java.lang.String name)
          Sets the element name.
 void setElementColorFalse(java.awt.Color elementColorFalse)
          Sets the color for false values.
 void setElementColorTrue(java.awt.Color elementColorTrue)
          Sets the color for true values.
 void setField(java.lang.String field)
          Sets the field name for the function.
 
Methods inherited from class com.jrefinery.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getInstance, getName, getProperties, getProperty, getProperty, groupFinished, groupStarted, isActive, itemsFinished, itemsStarted, pageFinished, pageStarted, 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
 

Field Detail

ELEMENT_PROPERTY

public static final java.lang.String ELEMENT_PROPERTY
the Property key for the name of the ItemBand element.

See Also:
Constant Field Values

FIELD_PROPERTY

public static final java.lang.String FIELD_PROPERTY
Literal text for the 'field' property.

See Also:
Constant Field Values
Constructor Detail

ElementColorFunction

public ElementColorFunction()
Default constructor.

Method Detail

setElement

public void setElement(java.lang.String name)
Sets the element name. The name denotes an element within the item band. The element will be retrieved using the getElement(String) function.

Parameters:
name - The element name.
See Also:
Band.getElement(String)

getElement

public java.lang.String getElement()
Returns the element name.

Returns:
The element name.

getField

public java.lang.String getField()
Returns the field used by the function.

The field name corresponds to a column name in the report's TableModel.

Returns:
The field name.

setField

public void setField(java.lang.String field)
Sets the field name for the function.

The field name corresponds to a column name in the report's TableModel.

Parameters:
field - the field name (null not permitted).

initialize

public void initialize()
                throws FunctionInitializeException
Checks that the function has been correctly initialized.

The only check performed at present is to make sure the name is not null.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractFunction
Throws:
FunctionInitializeException - in case the function is not initialized properly.

setElementColorTrue

public void setElementColorTrue(java.awt.Color elementColorTrue)
Sets the color for true values.

Parameters:
elementColorTrue - the color.

setElementColorFalse

public void setElementColorFalse(java.awt.Color elementColorFalse)
Sets the color for false values.

Parameters:
elementColorFalse - the color.

getElementColorTrue

public java.awt.Color getElementColorTrue()
Returns the color for true values.

Returns:
A color.

getElementColorFalse

public java.awt.Color getElementColorFalse()
Returns the color for false values.

Returns:
A color.

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Receives notification that a row of data is being processed.

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

getValue

public java.lang.Object getValue()
Return the current expression value.

The value depends (obviously) on the expression implementation.

Specified by:
getValue in interface Expression
Returns:
the value of the function.