Class ElementStyleSheet
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.style.AbstractStyleSheet
-
- org.pentaho.reporting.engine.classic.core.style.ElementStyleSheet
-
- All Implemented Interfaces:
Serializable
,Cloneable
,StyleSheet
- Direct Known Subclasses:
CSSCounterRule
,ElementDefaultStyleSheet
,ElementStyleRule
,ResolverStyleSheet
public class ElementStyleSheet extends AbstractStyleSheet implements Serializable, 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
-
-
Constructor Summary
Constructors Constructor Description ElementStyleSheet()
Creates a new element style-sheet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(ElementStyleSheet sourceStyleSheet)
void
addDefault(ElementStyleSheet sourceStyleSheet)
void
addInherited(SimpleStyleSheet sourceStyleSheet)
void
addInherited(ElementStyleSheet sourceStyleSheet)
void
addListener(StyleChangeListener l)
Adds aStyleChangeListener
.void
clear()
ElementStyleSheet
clone()
Creates and returns a copy of this object.void
copyFrom(ElementStyleSheet style)
ElementStyleSheet
derive(boolean preserveId)
long
getChangeTracker()
long
getChangeTrackerHash()
StyleKey[]
getDefinedPropertyNamesArray()
long
getModificationCount()
List<StyleKey>
getPropertyKeyList()
StyleKey[]
getPropertyKeys()
Returns the property keys.Object
getStyleProperty(StyleKey key, Object defaultValue)
Returns the value of a style.boolean
isLocalKey(StyleKey key)
Returns true, if the given key is locally defined, false otherwise.void
removeListener(StyleChangeListener l)
Removes aStyleChangeListener
.void
setBooleanStyleProperty(StyleKey key, boolean value)
Sets a boolean style property.protected void
setChangeTrackerHash(long changeTracker)
protected void
setModificationCount(long modificationCount)
void
setStyleProperty(StyleKey key, Object value)
Sets a style property (or removes the style if the value isnull
).Object[]
toArray()
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.style.AbstractStyleSheet
getBooleanStyleProperty, getBooleanStyleProperty, getDoubleStyleProperty, getId, getIntStyleProperty, getStyleProperty, setId
-
-
-
-
Method Detail
-
getChangeTracker
public long getChangeTracker()
- Specified by:
getChangeTracker
in interfaceStyleSheet
-
isLocalKey
public boolean isLocalKey(StyleKey key)
Returns true, if the given key is locally defined, false otherwise.- Specified by:
isLocalKey
in interfaceStyleSheet
- Overrides:
isLocalKey
in classAbstractStyleSheet
- Parameters:
key
- the key to test- Returns:
- true, if the key is local, false otherwise.
-
toArray
public final Object[] toArray()
- Specified by:
toArray
in interfaceStyleSheet
-
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 (possiblynull
) is returned.- Specified by:
getStyleProperty
in interfaceStyleSheet
- 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 isnull
).- 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 ElementStyleSheet clone()
Creates and returns a copy of this object. After the cloning, the new StyleSheet is no longer registered with its parents.- Overrides:
clone
in classAbstractStyleSheet
- Returns:
- a clone of this instance.
- See Also:
Cloneable
-
derive
public ElementStyleSheet derive(boolean preserveId)
- Overrides:
derive
in classAbstractStyleSheet
-
getDefinedPropertyNamesArray
public StyleKey[] getDefinedPropertyNamesArray()
-
addListener
public void addListener(StyleChangeListener l)
Adds aStyleChangeListener
.- Parameters:
l
- the listener.
-
removeListener
public void removeListener(StyleChangeListener l)
Removes aStyleChangeListener
.- Parameters:
l
- the listener.
-
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.
-
addAll
public void addAll(ElementStyleSheet sourceStyleSheet)
-
addInherited
public void addInherited(ElementStyleSheet sourceStyleSheet)
-
addInherited
public void addInherited(SimpleStyleSheet sourceStyleSheet)
-
addDefault
public void addDefault(ElementStyleSheet sourceStyleSheet)
-
clear
public void clear()
-
getModificationCount
public long getModificationCount()
- Specified by:
getModificationCount
in interfaceStyleSheet
- Overrides:
getModificationCount
in classAbstractStyleSheet
-
setModificationCount
protected void setModificationCount(long modificationCount)
-
getChangeTrackerHash
public long getChangeTrackerHash()
- Specified by:
getChangeTrackerHash
in interfaceStyleSheet
- Overrides:
getChangeTrackerHash
in classAbstractStyleSheet
-
setChangeTrackerHash
protected void setChangeTrackerHash(long changeTracker)
-
copyFrom
public void copyFrom(ElementStyleSheet style)
-
-