org.pentaho.reporting.engine.classic.core.style
Class ElementStyleSheet

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.style.AbstractStyleSheet
      extended by org.pentaho.reporting.engine.classic.core.style.ElementStyleSheet
All Implemented Interfaces:
Serializable, Cloneable, StyleChangeListener, StyleSheet
Direct Known Subclasses:
ElementDefaultStyleSheet

public abstract class ElementStyleSheet
extends AbstractStyleSheet
implements Serializable, StyleChangeListener, Cloneable

An element style-sheet contains zero, one or many attributes that affect the appearance of report elements. For each attribute, there is a predefined key that can be used to access that attribute in the style sheet.

Every report element has an associated style-sheet.

A style-sheet maintains a list of parent style-sheets. If an attribute is not defined in a style-sheet, the code refers to the parent style-sheets to see if the attribute is defined there.

All StyleSheet entries are checked against the StyleKeyDefinition for validity.

As usual, this implementation is not synchronized, we need the performance during the reporting.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static StyleKey ALIGNMENT
          Deprecated. use ElementStyleKeys instead..
static StyleKey BOLD
          Deprecated. use ElementStyleKeys instead..
static StyleKey DYNAMIC_HEIGHT
          Deprecated. use ElementStyleKeys instead..
static StyleKey EMBEDDED_FONT
          Deprecated. use ElementStyleKeys instead..
static StyleKey EXCEL_DATA_FORMAT_STRING
          Deprecated. use ElementStyleKeys instead..
static StyleKey EXCEL_WRAP_TEXT
          Deprecated. use ElementStyleKeys instead..
static StyleKey FONT
          Deprecated. use ElementStyleKeys instead..
static StyleKey FONTENCODING
          Deprecated. use ElementStyleKeys instead..
static StyleKey FONTSIZE
          Deprecated. use ElementStyleKeys instead..
static StyleKey HREF_TARGET
          Deprecated. use ElementStyleKeys instead..
static StyleKey HREF_WINDOW
          Deprecated. use ElementStyleKeys instead..
static StyleKey ITALIC
          Deprecated. use ElementStyleKeys instead..
static StyleKey KEEP_ASPECT_RATIO
          Deprecated. use ElementStyleKeys instead..
static StyleKey LINEHEIGHT
          Deprecated. use ElementStyleKeys instead..
static StyleKey MAXIMUMSIZE
          Deprecated. use the minimum-width and minimum-height style-keys instead.
static StyleKey MINIMUMSIZE
          Deprecated. use the minimum-width and minimum-height style-keys instead.
static StyleKey PAINT
          Deprecated. use ElementStyleKeys instead..
static StyleKey PREFERREDSIZE
          Deprecated. use the minimum-width and minimum-height style-keys instead.
static StyleKey RESERVED_LITERAL
          Deprecated. use ElementStyleKeys instead..
static StyleKey SCALE
          Deprecated. use ElementStyleKeys instead..
static StyleKey STRIKETHROUGH
          Deprecated. use ElementStyleKeys instead..
static StyleKey STROKE
          Deprecated. use ElementStyleKeys instead..
static StyleKey TRIM_TEXT_CONTENT
          Deprecated. use ElementStyleKeys instead..
static StyleKey UNDERLINED
          Deprecated. use ElementStyleKeys instead..
static StyleKey VALIGNMENT
          Deprecated. use ElementStyleKeys instead..
static StyleKey VISIBLE
          Deprecated. use ElementStyleKeys instead..
 
Method Summary
 void addListener(StyleChangeListener l)
          Adds a StyleChangeListener.
 void addParent(ElementStyleSheet parent)
          Adds a parent style-sheet.
 void addParent(int position, ElementStyleSheet parent)
          Adds a parent style-sheet.
 Object clone()
          Creates and returns a copy of this object.
 StyleSheet derive()
           
 ElementStyleSheet getCascadeStyleSheet()
           
 long getChangeTracker()
           
 ElementStyleSheet getCopy()
          Clones the style-sheet.
 Iterator getDefinedPropertyNames()
          Returns an enumeration of all local property keys.
 StyleKey[] getDefinedPropertyNamesArray()
           
 FontDefinition getFontDefinitionProperty()
          Deprecated. This method will be removed in the next version.
 ElementDefaultStyleSheet getGlobalDefaultStyleSheet()
          Returns the global default (if defined).
 String getName()
          Returns the name of the style-sheet.
 ElementStyleSheet[] getParents()
          Returns a list of the parent style-sheets.
 StyleKey[] getPropertyKeys()
          Returns the property keys.
 Object getStyleProperty(StyleKey key, Object defaultValue)
          Returns the value of a style.
 boolean isAllowCaching()
          Deprecated. has no effect. Always return true.
 boolean isGlobalDefault()
          Returns true, if this stylesheet is one of the global default stylesheets.
 boolean isLocalKey(StyleKey key)
          Returns true, if the given key is locally defined, false otherwise.
 void removeListener(StyleChangeListener l)
          Removes a StyleChangeListener.
 void removeParent(ElementStyleSheet parent)
          Removes a parent style-sheet.
 void setAllowCaching(boolean allowCaching)
          Deprecated. has no effect - there is always some caching now
 void setBooleanStyleProperty(StyleKey key, boolean value)
          Sets a boolean style property.
 void setCascadeStyleSheet(ElementStyleSheet cascadeStyleSheet)
           
 void setFontDefinitionProperty(FontDefinition font)
          Deprecated. This method will be removed in the next version.
 void setGlobalDefaultStyleSheet(ElementDefaultStyleSheet defaultStyleSheet)
           
 void setStyleProperty(StyleKey key, Object value)
          Sets a style property (or removes the style if the value is null).
 void styleChanged(ElementStyleSheet source, StyleKey key, Object value)
          Forwards a change event notification to all registered StyleChangeListener objects.
 void styleRemoved(ElementStyleSheet source, StyleKey key)
          Forwards a change event notification to all registered StyleChangeListener objects.
 Object[] toArray()
           
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.style.AbstractStyleSheet
getBooleanStyleProperty, getBooleanStyleProperty, getDoubleStyleProperty, getId, getIntStyleProperty, getStyleProperty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUMSIZE

public static final StyleKey MINIMUMSIZE
Deprecated. use the minimum-width and minimum-height style-keys instead.
A key for the 'minimum size' of an element. This style property is not inherited from the parent band.


MAXIMUMSIZE

public static final StyleKey MAXIMUMSIZE
Deprecated. use the minimum-width and minimum-height style-keys instead.
A key for the 'maximum size' of an element. This style property is not inherited from the parent band.


PREFERREDSIZE

public static final StyleKey PREFERREDSIZE
Deprecated. use the minimum-width and minimum-height style-keys instead.
A key for the 'preferred size' of an element. This style property is not inherited from the parent band.


VISIBLE

public static final StyleKey VISIBLE
Deprecated. use ElementStyleKeys instead..
A key for an element's 'visible' flag.


PAINT

public static final StyleKey PAINT
Deprecated. use ElementStyleKeys instead..
A key for the 'paint' used to color an element. For historical reasons, this key requires a color value.


STROKE

public static final StyleKey STROKE
Deprecated. use ElementStyleKeys instead..
A key for the 'stroke' used to draw an element. (This now only applies to shape and drawable-elements.)


ALIGNMENT

public static final StyleKey ALIGNMENT
Deprecated. use ElementStyleKeys instead..
A key for the horizontal alignment of an element.


VALIGNMENT

public static final StyleKey VALIGNMENT
Deprecated. use ElementStyleKeys instead..
A key for the vertical alignment of an element.


SCALE

public static final StyleKey SCALE
Deprecated. use ElementStyleKeys instead..
A key for an element's 'scale' flag.


KEEP_ASPECT_RATIO

public static final StyleKey KEEP_ASPECT_RATIO
Deprecated. use ElementStyleKeys instead..
A key for an element's 'keep aspect ratio' flag.


DYNAMIC_HEIGHT

public static final StyleKey DYNAMIC_HEIGHT
Deprecated. use ElementStyleKeys instead..
A key for the dynamic height flag for an element.


HREF_TARGET

public static final StyleKey HREF_TARGET
Deprecated. use ElementStyleKeys instead..

HREF_WINDOW

public static final StyleKey HREF_WINDOW
Deprecated. use ElementStyleKeys instead..
Specifies the anchor tag's target window for opening the link.


EXCEL_WRAP_TEXT

public static final StyleKey EXCEL_WRAP_TEXT
Deprecated. use ElementStyleKeys instead..
The StyleKey for the user defined cell data format.


EXCEL_DATA_FORMAT_STRING

public static final StyleKey EXCEL_DATA_FORMAT_STRING
Deprecated. use ElementStyleKeys instead..
The StyleKey for the user defined cell data format.


FONT

public static final StyleKey FONT
Deprecated. use ElementStyleKeys instead..
A key for the 'font family' used to draw element text.


FONTSIZE

public static final StyleKey FONTSIZE
Deprecated. use ElementStyleKeys instead..
A key for the 'font size' used to draw element text.


LINEHEIGHT

public static final StyleKey LINEHEIGHT
Deprecated. use ElementStyleKeys instead..
A key for the 'font size' used to draw element text.


BOLD

public static final StyleKey BOLD
Deprecated. use ElementStyleKeys instead..
A key for an element's 'bold' flag.


ITALIC

public static final StyleKey ITALIC
Deprecated. use ElementStyleKeys instead..
A key for an element's 'italic' flag.


UNDERLINED

public static final StyleKey UNDERLINED
Deprecated. use ElementStyleKeys instead..
A key for an element's 'underlined' flag.


STRIKETHROUGH

public static final StyleKey STRIKETHROUGH
Deprecated. use ElementStyleKeys instead..
A key for an element's 'strikethrough' flag.


EMBEDDED_FONT

public static final StyleKey EMBEDDED_FONT
Deprecated. use ElementStyleKeys instead..
A key for an element's 'embedd' flag.


FONTENCODING

public static final StyleKey FONTENCODING
Deprecated. use ElementStyleKeys instead..
A key for an element's 'embedd' flag.


RESERVED_LITERAL

public static final StyleKey RESERVED_LITERAL
Deprecated. use ElementStyleKeys instead..
The string that is used to end a text if not all text fits into the element.


TRIM_TEXT_CONTENT

public static final StyleKey TRIM_TEXT_CONTENT
Deprecated. use ElementStyleKeys instead..
The Layout Cacheable stylekey. Set this stylekey to false, to define that the element is not cachable. This key defaults to true.

Method Detail

isAllowCaching

public final boolean isAllowCaching()
Deprecated. has no effect. Always return true.

Returns true if caching is allowed, and false otherwise.

Returns:
A boolean.

getChangeTracker

public long getChangeTracker()
Specified by:
getChangeTracker in interface StyleSheet
Overrides:
getChangeTracker in class AbstractStyleSheet

isLocalKey

public boolean isLocalKey(StyleKey key)
Returns true, if the given key is locally defined, false otherwise.

Parameters:
key - the key to test
Returns:
true, if the key is local, false otherwise.

setAllowCaching

public void setAllowCaching(boolean allowCaching)
Deprecated. has no effect - there is always some caching now

Sets the flag that controls whether or not caching is allowed.

Parameters:
allowCaching - the flag value.

getName

public String getName()
Returns the name of the style-sheet.

Returns:
the name (never null).

addParent

public void addParent(ElementStyleSheet parent)
Adds a parent style-sheet. This method adds the parent to the beginning of the list, and guarantees, that this parent is queried first.

Parameters:
parent - the parent (null not permitted).

addParent

public void addParent(int position,
                      ElementStyleSheet parent)
Adds a parent style-sheet. Parents on a lower position are queried before any parent with an higher position in the list.

Parameters:
position - the position where to insert the parent style sheet
parent - the parent (null not permitted).
Throws:
IndexOutOfBoundsException - if the position is invalid (pos < 0 or pos >= numberOfParents)

removeParent

public void removeParent(ElementStyleSheet parent)
Removes a parent style-sheet.

Parameters:
parent - the style-sheet to remove (null not permitted).

getParents

public ElementStyleSheet[] getParents()
Returns a list of the parent style-sheets.

The list is unmodifiable.

Returns:
the list.

getGlobalDefaultStyleSheet

public ElementDefaultStyleSheet getGlobalDefaultStyleSheet()
Returns the global default (if defined).

Returns:
the list.

setGlobalDefaultStyleSheet

public void setGlobalDefaultStyleSheet(ElementDefaultStyleSheet defaultStyleSheet)

getCascadeStyleSheet

public ElementStyleSheet getCascadeStyleSheet()

setCascadeStyleSheet

public void setCascadeStyleSheet(ElementStyleSheet cascadeStyleSheet)

toArray

public final Object[] toArray()
Specified by:
toArray in interface StyleSheet

getStyleProperty

public Object getStyleProperty(StyleKey key,
                               Object defaultValue)
Returns the value of a style. If the style is not found in this style-sheet, the code looks in the parent style-sheets. If the style is not found in any of the parent style-sheets, then the default value (possibly null) is returned.

Specified by:
getStyleProperty in interface StyleSheet
Parameters:
key - the style key.
defaultValue - the default value (null permitted).
Returns:
the value.

setBooleanStyleProperty

public void setBooleanStyleProperty(StyleKey key,
                                    boolean value)
Sets a boolean style property.

Parameters:
key - the style key (null not permitted).
value - the value.
Throws:
NullPointerException - if the given key is null.
ClassCastException - if the value cannot be assigned with the given key.

setStyleProperty

public void setStyleProperty(StyleKey key,
                             Object value)
Sets a style property (or removes the style if the value is null).

Parameters:
key - the style key (null not permitted).
value - the value.
Throws:
NullPointerException - if the given key is null.
ClassCastException - if the value cannot be assigned with the given key.

clone

public Object clone()
             throws CloneNotSupportedException
Creates and returns a copy of this object. After the cloning, the new StyleSheet is no longer registered with its parents.

Overrides:
clone in class Object
Returns:
a clone of this instance.
Throws:
CloneNotSupportedException
See Also:
Cloneable

derive

public StyleSheet derive()
                  throws CloneNotSupportedException
Overrides:
derive in class AbstractStyleSheet
Throws:
CloneNotSupportedException

getCopy

public ElementStyleSheet getCopy()
                          throws CloneNotSupportedException
Clones the style-sheet. The assigned parent style sheets are not cloned. The stylesheets are not assigned to the contained stylesheet collection, you have to reassign them manually ...

Returns:
the clone.
Throws:
CloneNotSupportedException

getFontDefinitionProperty

public FontDefinition getFontDefinitionProperty()
Deprecated. This method will be removed in the next version.

Returns the font for this style-sheet.

Overrides:
getFontDefinitionProperty in class AbstractStyleSheet
Returns:
the font.

setFontDefinitionProperty

public void setFontDefinitionProperty(FontDefinition font)
Deprecated. This method will be removed in the next version.

Sets the font for this style-sheet.

Parameters:
font - the font (null not permitted).

getDefinedPropertyNames

public Iterator getDefinedPropertyNames()
Returns an enumeration of all local property keys.

Returns:
an enumeration of all localy defined style property keys.

getDefinedPropertyNamesArray

public StyleKey[] getDefinedPropertyNamesArray()

addListener

public void addListener(StyleChangeListener l)
Adds a StyleChangeListener.

Parameters:
l - the listener.

removeListener

public void removeListener(StyleChangeListener l)
Removes a StyleChangeListener.

Parameters:
l - the listener.

styleChanged

public void styleChanged(ElementStyleSheet source,
                         StyleKey key,
                         Object value)
Forwards a change event notification to all registered StyleChangeListener objects.

Specified by:
styleChanged in interface StyleChangeListener
Parameters:
source - the source of the change.
key - the style key.
value - the new value.

styleRemoved

public void styleRemoved(ElementStyleSheet source,
                         StyleKey key)
Forwards a change event notification to all registered StyleChangeListener objects.

Specified by:
styleRemoved in interface StyleChangeListener
Parameters:
source - the source of the change.
key - the style key.

isGlobalDefault

public boolean isGlobalDefault()
Returns true, if this stylesheet is one of the global default stylesheets. Global default stylesheets are unmodifiable and shared among all element stylesheets.

Returns:
true, if this is one of the unmodifiable global default stylesheets, false otherwise.

getPropertyKeys

public StyleKey[] getPropertyKeys()
Returns the property keys. This must return the same set of keys as a call to StyleSheet.getDefinedKeys(), but it allows us to avoid the synchronization on that call.

Returns:
the local copy of the style keys.