org.jfree.report.function
Class PaintComponentFunction

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

public class PaintComponentFunction
extends AbstractFunction
implements LayoutListener, java.io.Serializable

Paints a AWT or Swing Component, fitting the component into the element bounds. The component must be contained in the dataRow.

In an headless environment this function wont work and will always return null.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String ELEMENT_PROPERTY
          Literal text for the 'field' property.
static java.lang.String FIELD_PROPERTY
          Literal text for the 'field' property.
static java.lang.String SCALE_PROPERTY
          Literal text for the 'scale' property.
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
PaintComponentFunction()
          DefaultConstructor.
 
Method Summary
 java.lang.String getElement()
          Returns the element used by the function.
 java.lang.String getField()
          Returns the field used by the function.
 Expression getInstance()
          Return a completly separated copy of this function.
 float getScale()
          Gets the scale factor for the created image.
 java.lang.Object getValue()
          Return the current expression value.
 void initialize()
          Initializes the function and tests that all required properties are set.
protected static boolean isHeadless()
          Tests, whether the report generation is executed in an headless environment.
 void layoutComplete(LayoutEvent event)
          Receives notification that the band layouting has completed.
 void setElement(java.lang.String field)
          Sets the element name for the function.
 void setField(java.lang.String field)
          Sets the field name for the function.
 void setScale(float scale)
          Define a scale factor for the created image.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getName, getProperties, getProperty, getProperty, groupFinished, groupStarted, isActive, itemsAdvanced, 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
 

Field Detail

FIELD_PROPERTY

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

See Also:
Constant Field Values

ELEMENT_PROPERTY

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

See Also:
Constant Field Values

SCALE_PROPERTY

public static final java.lang.String SCALE_PROPERTY
Literal text for the 'scale' property.

See Also:
Constant Field Values
Constructor Detail

PaintComponentFunction

public PaintComponentFunction()
DefaultConstructor.

Method Detail

getElement

public java.lang.String getElement()
Returns the element used by the function.

The element name corresponds to a element in the report. The element name must be unique, as the first occurence of the element is used.

Returns:
The field name.

setElement

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

The element name corresponds to a element in the report. The element name must be unique, as the first occurence of the element is used.

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

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).

isHeadless

protected static boolean isHeadless()
Tests, whether the report generation is executed in an headless environment.

Returns:
true, if this is an headless environment, false otherwise.

layoutComplete

public void layoutComplete(LayoutEvent event)
Receives notification that the band layouting has completed.

The event carries the current report state.

Specified by:
layoutComplete in interface LayoutListener
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.

setScale

public void setScale(float scale)
Define a scale factor for the created image. Using a higher scale factor will produce better results. A scale factor of 2 will double the resolution. A scale factor of 1 will create 72 dpi images.

Parameters:
scale - the scale factor.

getScale

public float getScale()
Gets the scale factor for the created image. Using a higher scale factor will produce better results. A scale factor of 2 will double the resolution. A scale factor of 1 will create 72 dpi images.

Returns:
the scale factor.

getInstance

public Expression getInstance()
Return a completly separated copy of this function. The copy does no longer share any changeable objects with the original function.

Specified by:
getInstance in interface Expression
Overrides:
getInstance in class AbstractFunction
Returns:
a copy of this function.

initialize

public void initialize()
                throws FunctionInitializeException
Initializes the function and tests that all required properties are set. If the required field property is not set, a FunctionInitializeException is thrown.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractFunction
Throws:
FunctionInitializeException - when no field is set.