Interface JRStyle
-
- All Superinterfaces:
Cloneable
,JRBoxContainer
,JRCloneable
,JRParagraphContainer
,JRPenContainer
,JRStyleContainer
- All Known Subinterfaces:
JRConditionalStyle
- All Known Implementing Classes:
JRBaseConditionalStyle
,JRBaseStyle
,JRDesignConditionalStyle
,JRDesignStyle
public interface JRStyle extends JRBoxContainer, JRPenContainer, JRParagraphContainer, JRCloneable
Provides a collection of style settings declared at the report level.Report Styles
A report style is a collection of style settings declared at the report level. These settings can be reused throughout the entire report template when setting the style properties of report elements.The
name
attribute of a<style>
element is mandatory. It must be unique because it references the corresponding report style throughout the report.One can use
isDefault="true"
for one of your report style declarations to mark the default for elements that do not or cannot have another style specified.Each report style definition can reference another style definition from which it will inherit some or all of its properties. The
style
attribute inside a<style>
element specifies the name of the parent report style.Below is a list with the main style attributes:
name
- the name of the style. Required.isDefault
- flag that specifies if the style represents the default report style.style
- the name of the parent stylemode
- specifies whether report elements are opaque or transparent. Possible values are:Opaque
Transparent
forecolor
- the font color for text elements or the line color for graphic elementsbackcolor
- the element background colorfill
- the fill pattern. Possible value isSolid
radius
- the radius for some graphic elementshTextAlign
- the horizontal alignment of the text within a text element. Possible values are:Left
- default settingCenter
Right
Justified
vTextAlign
- the vertical alignment of the text within a text element. Possible values are:Top
- default settingMiddle
Bottom
hImageAlign
- the horizontal alignment of the image within an image element. Possible values are:Left
- default settingCenter
Right
vImageAlign
- the vertical alignment of the image within an image element. Possible values are:Top
- default settingMiddle
Bottom
rotation
- the text rotation within a text element. Possible values are:None
- default settingLeft
Right
UpsideDown
fontName
- the name of the font facefontSize
- the font sizeisBold
- flag that specifies whether the font is boldisItalic
- flag that specifies whether the font is italicisUnderline
- flag that specifies whether the font is underlinedisStrikeThrough
- flag that specifies whether the font is strike throughpattern
- specifies the format pattern for text elementsisBlankWhenNull
- flag that specifies whether null values should be represented as blanksmarkup
- the markup style for the text elements. Possible values are:none
- default settingstyled
html
rtf
A style also may contain:
- a
JRPen
element that can be retrieved using thegetLinePen()
method. - a
JRLineBox
element that can be retrieved using theJRBoxContainer.getLineBox()
method. - a
JRParagraph
element that can be retrieved using theJRParagraphContainer.getParagraph()
method inherited from theJRParagraphContainer
interface.
All report elements can reference a report style to inherit all or part of the style properties. A report style declaration groups all the style-related properties supported throughout the library, but an individual element inherits only those style properties that apply to it. The others will be ignored.
Conditional Styles
Sometimes users need to change a report element style at runtime based on certain conditions (for example, to alternate adjacent row colors in a report detail section). To achieve this goal, one can set some style properties to be enabled only if a specified condition is true. This is done using conditional styles.A conditional style has two elements: a Boolean condition expression and a
style
. The style is used only if the condition evaluates to true.An important aspect is the priority of styles. When applied, a conditional style will override the properties of its parent style.
A style can contain more than one conditional style. In this case, all conditionals that evaluate to true will be appended to the existing style (the second style will be appended to the first, and so on).
By default, the style condition expressions are evaluated during the report filling process at the time that the style reference is used. The conditional expression evaluation will use the current values of referenced variables and fields, regardless of the
evaluationTime
attribute of the element that makes use of the style.If the evaluation of the condition expression of the style needs to be delayed, just like the value of the text field or the image element that uses the conditional style, the
net.sf.jasperreports.style.evaluation.time.enabled
configuration property should be set to true.Style Templates
Report styles can also be defined in external style template files that are referenced by report templates. This allows report designers to define in a single place a common look for a set of reports.A style template is an XML file that contains one or more style definitions. A template can include references to other style template files, hence one can organize a style library as a hierarchical set of style template files.
Style template files use by convention the
*.jrtx
extension, but this is not mandatory.A report can use style templates by explicitly referring them in its definition. References to a style templates are included in JRXML reports as
<template>
elements. Such an element contains an expression that is resolved at fill time to a style template instance.- Author:
- Ionut Nedelcu (ionutned@users.sourceforge.net)
- See Also:
JRLineBox
,JRParagraph
,JRPen
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_EVALUATION_TIME_ENABLED
A flag the determines whether the style of an element is evaluated at the element evaluation time, or at the time the band on which the element is placed is rendered.
-
Method Summary
-
Methods inherited from interface net.sf.jasperreports.engine.JRBoxContainer
getDefaultLineColor, getLineBox
-
Methods inherited from interface net.sf.jasperreports.engine.JRCloneable
clone
-
Methods inherited from interface net.sf.jasperreports.engine.JRParagraphContainer
getParagraph
-
Methods inherited from interface net.sf.jasperreports.engine.JRPenContainer
getDefaultLineColor, getDefaultLineWidth
-
Methods inherited from interface net.sf.jasperreports.engine.JRStyleContainer
getDefaultStyleProvider, getStyle, getStyleName, getStyleNameReference
-
-
-
-
Field Detail
-
PROPERTY_EVALUATION_TIME_ENABLED
static final String PROPERTY_EVALUATION_TIME_ENABLED
A flag the determines whether the style of an element is evaluated at the element evaluation time, or at the time the band on which the element is placed is rendered.This applies to report elements that can have delayed evaluations times (such as text fields and images). When this flag is set to
true
, conditional style expressions of the style that is associated with the element are evaluated at the moment the element is set to evaluate, and the resulting style to the generated print element.By default, this flag is set to
false
. The property can be set globally, at report level and at element level.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName()
Gets the style unique name.
-
isDefault
boolean isDefault()
Gets a flag that specifies if this is the default report style.
-
getMode
ModeEnum getMode()
Returns the element transparency mode. The default value depends on the type of the report element. Graphic elements like rectangles and lines are opaque by default, but the images are transparent. Both static texts and text fields are transparent by default, and so are the subreport elements.
-
getOwnMode
ModeEnum getOwnMode()
-
getForecolor
Color getForecolor()
-
getOwnForecolor
Color getOwnForecolor()
-
getBackcolor
Color getBackcolor()
-
getOwnBackcolor
Color getOwnBackcolor()
-
getLinePen
JRPen getLinePen()
-
getFill
FillEnum getFill()
Indicates the fill type used for this element.- Returns:
- one of the fill constants in
FillEnum
.
-
getOwnFill
FillEnum getOwnFill()
-
getRadius
Integer getRadius()
Indicates the corner radius for rectangles with round corners. The default is 0.
-
getOwnRadius
Integer getOwnRadius()
-
getScaleImage
ScaleImageEnum getScaleImage()
Gets the image scale type.- Returns:
- one of the scale types defined in
ScaleImageEnum
-
getOwnScaleImage
ScaleImageEnum getOwnScaleImage()
Gets the image own scale type.- Returns:
- one of the scale types defined in
ScaleImageEnum
-
getHorizontalTextAlign
HorizontalTextAlignEnum getHorizontalTextAlign()
Gets the horizontal text alignment of the element.- Returns:
- one of the alignment values defined in
HorizontalTextAlignEnum
-
getOwnHorizontalTextAlign
HorizontalTextAlignEnum getOwnHorizontalTextAlign()
-
getVerticalTextAlign
VerticalTextAlignEnum getVerticalTextAlign()
Gets the vertical text alignment of the element.- Returns:
- one of the alignment values defined in
VerticalTextAlignEnum
-
getOwnVerticalTextAlign
VerticalTextAlignEnum getOwnVerticalTextAlign()
-
getHorizontalImageAlign
HorizontalImageAlignEnum getHorizontalImageAlign()
Gets the horizontal image alignment of the element.- Returns:
- one of the alignment values defined in
HorizontalImageAlignEnum
-
getOwnHorizontalImageAlign
HorizontalImageAlignEnum getOwnHorizontalImageAlign()
-
getVerticalImageAlign
VerticalImageAlignEnum getVerticalImageAlign()
Gets the vertical image alignment of the element.- Returns:
- one of the alignment values defined in
VerticalImageAlignEnum
-
getOwnVerticalImageAlign
VerticalImageAlignEnum getOwnVerticalImageAlign()
-
getRotation
RotationEnum getRotation()
Gets the text rotation.- Returns:
- a value representing one of the rotation values in the
RotationEnum
.
-
getOwnRotation
RotationEnum getOwnRotation()
Gets the text own rotation.- Returns:
- a value representing one of the rotation values in the
RotationEnum
.
-
getMarkup
String getMarkup()
Returns the markup language used to format the text.
-
getOwnMarkup
String getOwnMarkup()
-
getFontName
String getFontName()
-
getOwnFontName
String getOwnFontName()
-
isBold
Boolean isBold()
-
isOwnBold
Boolean isOwnBold()
-
isItalic
Boolean isItalic()
-
isOwnItalic
Boolean isOwnItalic()
-
isUnderline
Boolean isUnderline()
-
isOwnUnderline
Boolean isOwnUnderline()
-
isStrikeThrough
Boolean isStrikeThrough()
-
isOwnStrikeThrough
Boolean isOwnStrikeThrough()
-
getFontSize
Float getFontSize()
-
getOwnFontSize
Float getOwnFontSize()
-
getPdfFontName
String getPdfFontName()
-
getOwnPdfFontName
String getOwnPdfFontName()
-
getPdfEncoding
String getPdfEncoding()
-
getOwnPdfEncoding
String getOwnPdfEncoding()
-
isPdfEmbedded
Boolean isPdfEmbedded()
-
isOwnPdfEmbedded
Boolean isOwnPdfEmbedded()
-
getPattern
String getPattern()
Gets the pattern used for this text field. The pattern will be used in a SimpleDateFormat for dates and a DecimalFormat for numeric text fields. The pattern format must follow one of these two classes formatting rules, as specified in the JDK API docs.- Returns:
- a string containing the pattern.
-
getOwnPattern
String getOwnPattern()
-
isBlankWhenNull
Boolean isBlankWhenNull()
-
isOwnBlankWhenNull
Boolean isOwnBlankWhenNull()
-
setForecolor
void setForecolor(Color forecolor)
-
setBackcolor
void setBackcolor(Color backcolor)
-
setMode
void setMode(ModeEnum mode)
-
setFill
void setFill(FillEnum fill)
-
setRadius
void setRadius(Integer radius)
-
setScaleImage
void setScaleImage(ScaleImageEnum scaleImage)
-
setHorizontalTextAlign
void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalAlignment)
-
setVerticalTextAlign
void setVerticalTextAlign(VerticalTextAlignEnum verticalAlignment)
-
setHorizontalImageAlign
void setHorizontalImageAlign(HorizontalImageAlignEnum horizontalAlignment)
-
setVerticalImageAlign
void setVerticalImageAlign(VerticalImageAlignEnum verticalAlignment)
-
setRotation
void setRotation(RotationEnum rotation)
-
setFontName
void setFontName(String fontName)
-
setBold
void setBold(Boolean bold)
-
setItalic
void setItalic(Boolean italic)
-
setPdfEmbedded
void setPdfEmbedded(Boolean pdfEmbedded)
-
setStrikeThrough
void setStrikeThrough(Boolean strikeThrough)
-
setMarkup
void setMarkup(String markup)
-
setUnderline
void setUnderline(Boolean underline)
-
setPattern
void setPattern(String pattern)
-
setBlankWhenNull
void setBlankWhenNull(Boolean isBlankWhenNull)
-
setPdfEncoding
void setPdfEncoding(String pdfEncoding)
-
setPdfFontName
void setPdfFontName(String pdfFontName)
-
setFontSize
void setFontSize(Float fontSize)
-
getConditionalStyles
JRConditionalStyle[] getConditionalStyles()
-
-