public interface JRElement extends JRChild, JRCommonElement, JRPropertiesHolder, JRIdentifiable
<reportElement>
tag, which appears in the declaration of all report elements.
JRElementGroup.getElementByKey(String)
method available at band level. A key value must be
associated with the report element and it must be unique within the overall band for the
lookup to work.
x
and y
attributes of any report element are mandatory and represent the x and y
coordinates, measured in pixels, that mark the absolute position of the top-left corner of
the specified element within its parent report section.positionType
attribute specifies the behavior that the report element will have if
the layout of the report section in which it is been placed is stretched.positionType
attribute:
Float
- The element floats in its parent section if it is pushed downward
by other elements found above it. It tries to conserve the distance between it and
the neighboring elements placed immediately above itFixRelativeToTop
- The current report element
simply ignores what happens to the other section elements and tries to conserve the
y offset measured from the top of its parent report sectionFixRelativeToBottom
- If the height of the parent
report section is affected by elements that stretch, the current element tries to
conserve the original distance between its bottom margin and the bottom of the
bandpositionType="Float"
e1.y + e1.height <= e2.y
e1.width + e2.width > max(e1.x + e1.width, e2.x + e2.width) - min(e1.x, e2.x)
<printWhenExpression>
is used, which is available for all types of report elements.
If present, this report expression should return a java.lang.Boolean
object or null. It
is evaluated every time the section containing the current element is generated, in order
to see whether this particular element should appear in the report or not. If the expression
returns null, it is equivalent to returning java.lang.Boolean.FALSE
. If the
expression is missing, then the report element will get printed every time - that is, if
other settings do not intervene.
isPrintWhenDetailOverflows="true"
for all report elements
you want to reappear on the next page or column.
isPrintRepeatedValues="false"
The static text elements behave in the same way. As you would expect, their value
always repeats and in fact never changes until the end of the report. This is why we call
them static texts. So, if you set isPrintRepeatedValues="false"
for one of your
<staticText>
elements, it is displayed only once, the first time, at the beginning of the
report, and never again.
Now, what about graphic elements? An image is considered to be repeating itself if its
bytes are exactly the same from one occurrence to the next. This happens only if you
choose to cache your images using the isUsingCache
attribute available in the
<image>
(see JRImage
element and if the corresponding <imageExpression>
returns the same value from one
iteration to the next (the same file name, the same URL, etc.).
Lines and rectangles always repeat themselves because they are static elements, just like
the static texts shown previously. So, when you suppress repeating values for a line or a
rectangle, it is displayed only once, at the beginning of the report, and then ignored until
the end of the report.
Note: The isPrintRepeatedValues
attribute works only if the corresponding
<printWhenExpression>
is missing. If it is not missing, it will always dictate
whether the element should be printed, regardless of the repeating values.
If you decide to not display the repeating values for some of your report elements, you
can modify this behavior by indicating the exceptional occasions in which you might
want to have a particular value redisplayed during the report-generation process.
When the repeating value spans multiple pages or columns, you can redisplay this
repeating value at least once for every page or column. If you set
isPrintInFirstWholeBand="true"
, then the report element will reappear in the first
band of a new page or column that is not an overflow from a previous page or column.
Also, if the repeating value you have suppressed spans multiple groups, you can make it
reappear at the beginning of a certain report group if you specify the name of that
particular group in the printWhenGroupChanges
attribute.
<printWhenExpression>
evaluates to Boolean.FALSE
, or a repeated value is
suppressed), the area where the report element stood at design time will be left empty.
This blank space also appears if a text field displays only blank characters or an empty
text value. You can eliminate this unwanted blank space on the vertical axis only if
certain conditions are met.
The blank space will be removed only if the empty text field doesn't share any vertical space with
other report elements that are printed, even if this empty textfield does not print. If this
condition is met, then set isRemoveLineWhenBlank= "true"
for the empty textfield.
stretchType
attribute of a report element can be used to customize the stretch
behavior of the element when, on the same report section, there are text fields that stretch
themselves because their text content is too large for the original text field height. When
stretchable text fields are present on a report section, the height of the report section
itself is affected by the stretch.
A report element can respond to the modification of the report section layout in three
ways:
NoStretch
- The report element preserves its original specified height.RelativeToBandHeight
- The report element adapts its height
to match the new height of the report section it is placed on, which has been
affected by stretch.RelativeToTallestObject
- Report elements can be made to automatically adapt their
height to fit the amount of stretch suffered by the tallest element in the group that
they are part of.net.sf.jasperreports.print.transfer.<arbitrary_suffix>
. The values of
such properties are used as prefixes for properties that are to be transferred to the filled
report elements.
The built-in JasperReports configuration defines a single such prefix:
net.sf.jasperreports.export
. Consequently, all element properties that start with
this prefix will be propagated to the generated report elements by default.Modifier and Type | Method and Description |
---|---|
JRElement |
clone(JRElementGroup parentGroup,
int y) |
void |
collectExpressions(JRExpressionCollector collector) |
JRElementGroup |
getElementGroup()
Indicates the logical group that the element belongs to.
|
String |
getKey()
Returns the string value that uniquely identifies the element.
|
PositionTypeEnum |
getPositionTypeValue()
Returns the position type for the element
|
JRExpression |
getPrintWhenExpression()
Gets the expression that is evaluated in order to decide if the element should be displayed.
|
JRGroup |
getPrintWhenGroupChanges()
Returns the group for which an element with a printRepeatedValues attribute set to true will be redisplayed
even if the value has not changed.
|
JRPropertyExpression[] |
getPropertyExpressions()
Returns the list of dynamic/expression-based properties for this report element.
|
StretchTypeEnum |
getStretchTypeValue()
Indicates the stretch type for the element
|
int |
getX()
Gets the the section relative horizontal offset of the element top left corner.
|
int |
getY()
Gets the the section relative vertical offset of the element top left corner.
|
boolean |
isPrintInFirstWholeBand()
Returns true if an element with a printRepeatedValues attribute set to true will be redisplayed for every
new page or column that is not an overflow from a previous page or column.
|
boolean |
isPrintRepeatedValues()
Specifies if the element value will be printed for every iteration, even if its value has not changed.
|
boolean |
isPrintWhenDetailOverflows()
If this is set to true, the element will be reprinted on the next page if the band does not fit in the current page.
|
boolean |
isRemoveLineWhenBlank()
Returns true if the remaining blank space appearing when the value is not printed will be removed.
|
void |
setPositionType(PositionTypeEnum positionType)
Sets the position type for the element.
|
void |
setPrintInFirstWholeBand(boolean isPrintInFirstWholeBand)
Specifies whether an element with a printRepeatedValues attribute set to true should be redisplayed for every
new page or column that is not an overflow from a previous page or column.
|
void |
setPrintRepeatedValues(boolean isPrintRepeatedValues) |
void |
setPrintWhenDetailOverflows(boolean isPrintWhenDetailOverflows)
If this is set to true, the element will be reprinted on the next page if the band does not fit in the current page.
|
void |
setRemoveLineWhenBlank(boolean isRemoveLineWhenBlank)
Specifies whether the remaining blank space appearing when the value is not printed will be removed.
|
void |
setStretchType(StretchTypeEnum stretchTypeEnum)
Specifies how the engine should treat a missing image.
|
void |
setWidth(int width) |
void |
setX(int x)
Sets the the section relative horizontal offset of the element top left corner.
|
visit
clone
getBackcolor, getForecolor, getHeight, getModeValue, getOwnBackcolor, getOwnForecolor, getOwnModeValue, getWidth, setBackcolor, setForecolor, setMode
getDefaultStyleProvider, getStyle, getStyleNameReference
getParentProperties, getPropertiesMap, hasProperties
getUUID
String getKey()
getKey
in interface JRCommonElement
PositionTypeEnum getPositionTypeValue()
void setPositionType(PositionTypeEnum positionType)
positionType
- the position typeStretchTypeEnum getStretchTypeValue()
StretchTypeEnum
void setStretchType(StretchTypeEnum stretchTypeEnum)
stretchTypeEnum
- a value representing one of the stretch type constants in StretchTypeEnum
boolean isPrintRepeatedValues()
isRemoveLineWhenBlank()
,
isPrintInFirstWholeBand()
void setPrintRepeatedValues(boolean isPrintRepeatedValues)
int getX()
void setX(int x)
int getY()
void setWidth(int width)
boolean isRemoveLineWhenBlank()
void setRemoveLineWhenBlank(boolean isRemoveLineWhenBlank)
boolean isPrintInFirstWholeBand()
isPrintRepeatedValues()
void setPrintInFirstWholeBand(boolean isPrintInFirstWholeBand)
isPrintRepeatedValues()
boolean isPrintWhenDetailOverflows()
void setPrintWhenDetailOverflows(boolean isPrintWhenDetailOverflows)
JRExpression getPrintWhenExpression()
JRGroup getPrintWhenGroupChanges()
isPrintRepeatedValues()
JRElementGroup getElementGroup()
StretchTypeEnum
void collectExpressions(JRExpressionCollector collector)
JRPropertyExpression[] getPropertyExpressions()
JRElement clone(JRElementGroup parentGroup, int y)
Copyright © 2017. All rights reserved.