org.jfree.report.elementfactory
Class NumberFieldElementFactory

java.lang.Object
  extended byorg.jfree.report.elementfactory.ElementFactory
      extended byorg.jfree.report.elementfactory.TextElementFactory
          extended byorg.jfree.report.elementfactory.TextFieldElementFactory
              extended byorg.jfree.report.elementfactory.NumberFieldElementFactory

public class NumberFieldElementFactory
extends TextFieldElementFactory

The number format factory can be used to create numeric text elements. These text elements have special abilities to format numeric values.

Once the desired properties are set, the factory can be reused to create similiar text elements.

Author:
Thomas Morgner

Constructor Summary
NumberFieldElementFactory()
          Creates a new number field element factory.
 
Method Summary
 Element createElement()
          Creates the number text element based on the defined settings.
static TextElement createNumberElement(java.lang.String name, java.awt.geom.Rectangle2D bounds, java.awt.Color color, ElementAlignment alignment, ElementAlignment valign, FontDefinition font, java.lang.String nullString, java.text.NumberFormat format, java.lang.String field)
          Creates a new TextElement containing a numeric filter structure.
static TextElement createNumberElement(java.lang.String name, java.awt.geom.Rectangle2D bounds, java.awt.Color color, ElementAlignment alignment, ElementAlignment valign, FontDefinition font, java.lang.String nullString, java.lang.String format, java.lang.String field)
          Creates a new TextElement containing a numeric filter structure.
static TextElement createNumberElement(java.lang.String name, java.awt.geom.Rectangle2D bounds, java.awt.Color paint, ElementAlignment alignment, FontDefinition font, java.lang.String nullString, java.text.NumberFormat format, java.lang.String field)
          Creates a new TextElement containing a numeric filter structure.
static TextElement createNumberElement(java.lang.String name, java.awt.geom.Rectangle2D bounds, java.awt.Color paint, ElementAlignment alignment, FontDefinition font, java.lang.String nullString, java.lang.String format, java.lang.String field)
          Creates a new TextElement containing a numeric filter structure.
 java.text.NumberFormat getFormat()
          Returns the number format used for all generated text elements.
 java.lang.String getFormatString()
          Returns the format string of the used number format.
 void setFormat(java.text.NumberFormat format)
          Defines the number format used for all generated text elements.
 void setFormatString(java.lang.String formatString)
          Defines the format string of the used number format.
 
Methods inherited from class org.jfree.report.elementfactory.TextFieldElementFactory
createStringElement, createStringElement, getFieldname, getNullString, setFieldname, setNullString
 
Methods inherited from class org.jfree.report.elementfactory.TextElementFactory
applyStyle, getBold, getColor, getEmbedFont, getEncoding, getFontName, getFontSize, getHorizontalAlignment, getItalic, getLineHeight, getReservedLiteral, getStrikethrough, getTrimTextContent, getUnderline, getVerticalAlignment, setBold, setColor, setEmbedFont, setEncoding, setFontName, setFontSize, setHorizontalAlignment, setItalic, setLineHeight, setReservedLiteral, setStrikethrough, setTrimTextContent, setUnderline, setVerticalAlignment
 
Methods inherited from class org.jfree.report.elementfactory.ElementFactory
applyElementName, getAbsolutePosition, getDynamicHeight, getMaximumSize, getMinimumSize, getName, getPreferredSize, setAbsolutePosition, setDynamicHeight, setMaximumSize, setMinimumSize, setName, setPreferredSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberFieldElementFactory

public NumberFieldElementFactory()
Creates a new number field element factory.

Method Detail

getFormat

public java.text.NumberFormat getFormat()
Returns the number format used for all generated text elements. The number format is shared among all generated elements.

Returns:
the number format used in this factory.

setFormat

public void setFormat(java.text.NumberFormat format)
Defines the number format used for all generated text elements. The number format is shared among all generated elements.

Parameters:
format - the number format used in this factory.

getFormatString

public java.lang.String getFormatString()
Returns the format string of the used number format. This method will return null, if the current number format is no instance of DecimalFormat.

Returns:
the formatstring of the number format instance.

setFormatString

public void setFormatString(java.lang.String formatString)
Defines the format string of the used number format. This method will replace the number format instance of this factory.

Parameters:
formatString - the formatstring of the number format instance.

createElement

public Element createElement()
Creates the number text element based on the defined settings. Undefined properties will not be set in the generated element.

Overrides:
createElement in class TextFieldElementFactory
Returns:
the generated numberic text element
See Also:
ElementFactory.createElement()

createNumberElement

public static TextElement createNumberElement(java.lang.String name,
                                              java.awt.geom.Rectangle2D bounds,
                                              java.awt.Color paint,
                                              ElementAlignment alignment,
                                              FontDefinition font,
                                              java.lang.String nullString,
                                              java.text.NumberFormat format,
                                              java.lang.String field)
Creates a new TextElement containing a numeric filter structure.

Parameters:
name - the name of the new element
bounds - the bounds of the new element
paint - the text color of this text element
alignment - the horizontal text alignment.
font - the font for this element
nullString - the text used when the value of this element is null
field - the field in the datamodel to retrieve values from
format - the NumberFormat used in this number element
Returns:
a report element for displaying Number objects.
Throws:
java.lang.NullPointerException - if bounds, name or function are null
java.lang.IllegalArgumentException - if the given alignment is invalid

createNumberElement

public static TextElement createNumberElement(java.lang.String name,
                                              java.awt.geom.Rectangle2D bounds,
                                              java.awt.Color color,
                                              ElementAlignment alignment,
                                              ElementAlignment valign,
                                              FontDefinition font,
                                              java.lang.String nullString,
                                              java.text.NumberFormat format,
                                              java.lang.String field)
Creates a new TextElement containing a numeric filter structure.

Parameters:
name - the name of the new element.
bounds - the bounds of the new element.
color - the text color of this text element.
alignment - the horizontal text alignment.
valign - the vertical alignment.
font - the font for this element.
nullString - the text used when the value of this element is null.
field - the field in the datamodel to retrieve values from.
format - the NumberFormat used in this number element.
Returns:
a report element for displaying Number objects.
Throws:
java.lang.NullPointerException - if bounds, name or function are null
java.lang.IllegalArgumentException - if the given alignment is invalid

createNumberElement

public static TextElement createNumberElement(java.lang.String name,
                                              java.awt.geom.Rectangle2D bounds,
                                              java.awt.Color paint,
                                              ElementAlignment alignment,
                                              FontDefinition font,
                                              java.lang.String nullString,
                                              java.lang.String format,
                                              java.lang.String field)
Creates a new TextElement containing a numeric filter structure.

Parameters:
name - the name of the new element
bounds - the bounds of the new element
paint - the text color of this text element
alignment - the horizontal text alignment.
font - the font for this element
nullString - the text used when the value of this element is null
field - the fieldname in the datamodel to retrieve values from
format - the DecimalFormatString used in this text field
Returns:
a report element for displaying Number objects.
Throws:
java.lang.NullPointerException - if bounds, name or function are null
java.lang.IllegalArgumentException - if the given alignment is invalid

createNumberElement

public static TextElement createNumberElement(java.lang.String name,
                                              java.awt.geom.Rectangle2D bounds,
                                              java.awt.Color color,
                                              ElementAlignment alignment,
                                              ElementAlignment valign,
                                              FontDefinition font,
                                              java.lang.String nullString,
                                              java.lang.String format,
                                              java.lang.String field)
Creates a new TextElement containing a numeric filter structure.

Parameters:
name - the name of the new element.
bounds - the bounds of the new element.
color - the text color of the element.
alignment - the horizontal text alignment.
valign - the vertical alignment.
font - the font for this element.
nullString - t he text used when the value of this element is null.
field - the fieldname in the datamodel to retrieve values from.
format - the DecimalFormatString used in this text field.
Returns:
a report element for displaying Number objects.
Throws:
java.lang.NullPointerException - if bounds, name or function are null
java.lang.IllegalArgumentException - if the given alignment is invalid