org.jfree.report
Class TextElement

java.lang.Object
  extended byorg.jfree.report.Element
      extended byorg.jfree.report.TextElement
All Implemented Interfaces:
java.lang.Cloneable, DataTarget, java.io.Serializable

public class TextElement
extends Element

The base class for all elements that display text in a report band.

All content is converted to String using the String.valueOf () method. To convert values in a more sophisicated way, add filters to this element. Known filters are for instance the NumberFormatFilter or the SimpleDateFormatFilter.

For more information on filters have a look at the filter package org.jfree.report.filter

Author:
David Gilbert, Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String CONTENT_TYPE
          The content type string.
 
Fields inherited from class org.jfree.report.Element
ANONYMOUS_ELEMENT_PREFIX
 
Constructor Summary
TextElement()
          Creates a new empty text element.
 
Method Summary
 java.lang.Object clone()
          Clones this element.
 java.lang.String getContentType()
          Returns the content type, in this case 'text/plain'.
 FontDefinition getFont()
          Returns the font definition object assigned with this element.
 java.lang.String getFontName()
          Returns the name of the current font.
 int getFontSize()
          Returns the font size in points.
 float getLineHeight()
          Returns the lineheight for the element.
 java.lang.String getNullString()
          Return the null-value representation for this element.
 java.lang.String getReservedLiteral()
          Returns the reserved literal for this text element.
 java.lang.Object getValue()
          Returns the value for this text element.
 boolean isBold()
          Checks, whether the font should be displayed in bold style.
 boolean isItalic()
          Checks, whether the font should be displayed in italic style.
 boolean isStrikethrough()
          Returns whether the text should have the strikethough style applied.
 boolean isUnderline()
          Returns whether the text should be displayed underlined.
 void setBold(boolean bold)
          Defines, whether the font should be displayed in bold, false otherwise.
 void setFont(FontDefinition font)
          Defines all font properties by applying the values from the given font definition object.
 void setFontName(java.lang.String fontName)
          Defines the font name of the current font.
 void setFontSize(int fontSize)
          Defines the height of the font in points.
 void setItalic(boolean italic)
          Defines, whether the font should be displayed in italics.
 void setLineHeight(float lineHeight)
          Defines the lineheight for the element.
 void setNullString(java.lang.String s)
          Defines the null value representation for this element.
 void setReservedLiteral(java.lang.String reservedLiteral)
          Defines the reserved literal for this text element.
 void setStrikethrough(boolean strikethrough)
          Defines, whether the text should be displayed striked through.
 void setUnderline(boolean underline)
          Defines, whether the text should be displayed with the underline style applied.
 java.lang.String toString()
          Returns a string representation of this element, useful for debugging purposes.
 
Methods inherited from class org.jfree.report.Element
getDataSource, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getStyle, getStyleSheetCollection, getTreeLock, handleRegisterStyleSheetCollection, handleUnregisterStyleSheetCollection, isDynamicContent, isLayoutCacheable, isVisible, registerStyleSheetCollection, setDataSource, setDynamicContent, setLayoutCacheable, setMaximumSize, setMinimumSize, setName, setParent, setPreferredSize, setVisible, unregisterStyleSheetCollection, updateStyleSheetCollection
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
The content type string.

See Also:
Constant Field Values
Constructor Detail

TextElement

public TextElement()
Creates a new empty text element.

Method Detail

getNullString

public java.lang.String getNullString()
Return the null-value representation for this element. This will never return null, although you may feed a null value into the set method of this property.

Returns:
the null value representation for this element.
See Also:
setNullString(String)

setNullString

public void setNullString(java.lang.String s)
Defines the null value representation for this element. If null is given, the value is set to a reasonable value (this implementation sets the value to the string "-").

Parameters:
s - the null string.

getValue

public final java.lang.Object getValue()
Returns the value for this text element.

Internally, a StringFilter is used to ensure that the final result is an instance of String (even though it is returned as an Object.

Overrides:
getValue in class Element
Returns:
the value for the element.

toString

public java.lang.String toString()
Returns a string representation of this element, useful for debugging purposes.

Returns:
a string.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this element.

Specified by:
clone in interface DataTarget
Overrides:
clone in class Element
Returns:
a clone of this element.
Throws:
java.lang.CloneNotSupportedException - this should never happen.

getContentType

public java.lang.String getContentType()
Returns the content type, in this case 'text/plain'.

Specified by:
getContentType in class Element
Returns:
the content type.

getFontName

public java.lang.String getFontName()
Returns the name of the current font.

Returns:
the font name

setFontName

public void setFontName(java.lang.String fontName)
Defines the font name of the current font.

Parameters:
fontName - the font name

getFontSize

public int getFontSize()
Returns the font size in points.

Returns:
the font size.

setFontSize

public void setFontSize(int fontSize)
Defines the height of the font in points.

Calling this function with either parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
fontSize - the font size in points.

isBold

public boolean isBold()
Checks, whether the font should be displayed in bold style.

Returns:
true, if the font should be bold, false otherwise.

setBold

public void setBold(boolean bold)
Defines, whether the font should be displayed in bold, false otherwise.

Calling this function with either parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
bold - true, if the font should be displayed in bold, false otherwise

isItalic

public boolean isItalic()
Checks, whether the font should be displayed in italic style.

Returns:
true, if the font should be italic, false otherwise.

setItalic

public void setItalic(boolean italic)
Defines, whether the font should be displayed in italics.

Calling this function with either parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
italic - true, if the font should be in italic style, false otherwise.

isUnderline

public boolean isUnderline()
Returns whether the text should be displayed underlined.

Returns:
true, if the fond should be underlined, false otherwise.

setUnderline

public void setUnderline(boolean underline)
Defines, whether the text should be displayed with the underline style applied.

Calling this function with either parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
underline - true, if the text should be displayed underlined, false otherwise.

isStrikethrough

public boolean isStrikethrough()
Returns whether the text should have the strikethough style applied.

Returns:
true, if the font should be striked through, false otherwise.

setStrikethrough

public void setStrikethrough(boolean strikethrough)
Defines, whether the text should be displayed striked through.

Calling this function with either parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
strikethrough - whether to display the text with strikethrough style applied

getFont

public FontDefinition getFont()
Returns the font definition object assigned with this element. Never null.

Returns:
the font definition for this element.

setFont

public void setFont(FontDefinition font)
Defines all font properties by applying the values from the given font definition object.

Calling this function with either parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
font - the font definition for this element.

getLineHeight

public float getLineHeight()
Returns the lineheight for the element. The lineheight can be used to extend the space between two text lines, the effective lineheight will be the maximum of this property and the font height.

Returns:
the defined line height.

setLineHeight

public void setLineHeight(float lineHeight)
Defines the lineheight for the element. The lineheight can be used to extend the space between two text lines, the effective lineheight will be the maximum of this property and the font height.

Calling this function with any parameter will override any previously defined value for the layoutcachable attribute. The value can no longer be inherited from parent stylesheets.

Parameters:
lineHeight - the defined line height.

getReservedLiteral

public java.lang.String getReservedLiteral()
Returns the reserved literal for this text element. This literal is appended, whenever the text from tne content does not fully fit into the element's bounds.

Returns:
the reserved literal.

setReservedLiteral

public void setReservedLiteral(java.lang.String reservedLiteral)
Defines the reserved literal for this text element. This literal is appended, whenever the text from tne content does not fully fit into the element's bounds.

Parameters:
reservedLiteral - the reserved literal.