com.jrefinery.report
Class TextElement

java.lang.Object
  |
  +--com.jrefinery.report.Element
        |
        +--com.jrefinery.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 com.jrefinery.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 com.jrefinery.report.Element
BOTTOM, CENTER, LEFT, MIDDLE, RIGHT, TOP
 
Constructor Summary
TextElement()
          Creates a new empty text element.
 
Method Summary
 java.lang.Object clone()
          Clones this element.
 int getAlignment()
          Deprecated. the text alignment should be defined using the style sheet interfaces.
 java.lang.String getContentType()
          Returns the content type, in this case 'text/plain'.
 java.awt.Font getFont()
          Deprecated. the FontDefinition object should be used to define the font and font-related properties.
 java.lang.String getFormattedText()
          Deprecated. this method is replaced by Element.getValue(), filters are used for any formatting that is required.
 java.lang.String getNullString()
          Return the null-value representation for this element.
 java.lang.Object getValue()
          Returns the value for this text element.
 int getVerticalAlignment()
          Deprecated. the text alignment should be defined using the style sheet interfaces.
 boolean isStrikethrough()
          Deprecated. this information is contained in the FontDefinition object.
 boolean isUnderlined()
          Deprecated. this information is contained in the FontDefinition object.
 void setAlignment(int alignment)
          Deprecated. the text alignment should be defined using the style sheet interfaces.
 void setFont(java.awt.Font f)
          Deprecated. the FontDefinition object should be used to define the font and font-related properties.
 void setNullString(java.lang.String s)
          Defines the null value representation for this element.
 void setStrikethrough(boolean b)
          Deprecated. this information is contained in the FontDefinition object.
 void setUnderlined(boolean b)
          Deprecated. this information is contained in the FontDefinition object.
 void setVerticalAlignment(int alignment)
          Deprecated. the text alignment should be defined using the style sheet interfaces.
 java.lang.String toString()
          Returns a string representation of this element, useful for debugging purposes.
 
Methods inherited from class com.jrefinery.report.Element
getDataSource, getName, getPaint, getParent, getStyle, getStyleSheetCollection, isVisible, registerStyleSheetCollection, setDataSource, setName, setPaint, setParent, setStyleSheetCollection, setVisible, unregisterStyleSheetCollection
 
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.

Overrides:
toString in class java.lang.Object
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.

isStrikethrough

public boolean isStrikethrough()
Deprecated. this information is contained in the FontDefinition object.

Returns true, if the text should be strike-through style, and false otherwise.

Returns:
true or false.

setStrikethrough

public void setStrikethrough(boolean b)
Deprecated. this information is contained in the FontDefinition object.

Defines whether the text should be printed in strike-through style.

Parameters:
b - the flag.

setFont

public void setFont(java.awt.Font f)
Deprecated. the FontDefinition object should be used to define the font and font-related properties.

Defines the font for this element. If no font is defined, on drawing time the band's font is used.

Parameters:
f - the font.

getFont

public java.awt.Font getFont()
Deprecated. the FontDefinition object should be used to define the font and font-related properties.

Returns the font defined for this element.

Returns:
the font or null if no font has been defined for this element.

isUnderlined

public boolean isUnderlined()
Deprecated. this information is contained in the FontDefinition object.

Returns true, if the text should be underlined, and false otherwise.

Returns:
true or false.

setUnderlined

public void setUnderlined(boolean b)
Deprecated. this information is contained in the FontDefinition object.

Defines whether the text should be printed in underline style.

Parameters:
b - the flag.

getFormattedText

public java.lang.String getFormattedText()
Deprecated. this method is replaced by Element.getValue(), filters are used for any formatting that is required.

Returns a formatted version of the data element. Typically used for numbers and dates which can be formatted in various ways.

Returns:
a formatted version of the data value.

getAlignment

public int getAlignment()
Deprecated. the text alignment should be defined using the style sheet interfaces.

Returns the text alignment for this element's text.

This is one of ElementConstants.LEFT, ElementConstants.CENTER or ElementConstants.RIGHT.

Returns:
the alignment for this element.

setAlignment

public void setAlignment(int alignment)
Deprecated. the text alignment should be defined using the style sheet interfaces.

Defines the text alignment for this element's text.

This is one of Element.LEFT, Element.CENTER or Element.RIGHT.

Parameters:
alignment - the alignment for this element.

getVerticalAlignment

public int getVerticalAlignment()
Deprecated. the text alignment should be defined using the style sheet interfaces.

Returns the vertical alignment for this element's text.

This is one of Element.TOP, Element.MIDDLE or Element.BOTTOM.

Returns:
the alignment.

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Deprecated. the text alignment should be defined using the style sheet interfaces.

Defines the vertical alignment for this element's text.

This is one of the constants defined in the Element class: TOP, MIDDLE or RIGHT.

Parameters:
alignment - the alignment.