Interface JRCommonElement

All Superinterfaces:
JRStyleContainer
All Known Subinterfaces:
JRBreak, JRChart, JRCommonGraphicElement, JRCommonImage, JRCommonText, JRComponentElement, JRCrosstab, JRElement, JREllipse, JRFrame, JRGenericElement, JRGenericPrintElement, JRGraphicElement, JRImage, JRLine, JRPrintElement, JRPrintEllipse, JRPrintFrame, JRPrintGraphicElement, JRPrintImage, JRPrintLine, JRPrintRectangle, JRPrintText, JRRecordedValuesPrintElement, JRRectangle, JRStaticText, JRSubreport, JRTextElement, JRTextField
All Known Implementing Classes:
ChartTemplateImage, ComponentFillSubreport, ElementDecorator, JRBaseBreak, JRBaseChart, JRBaseComponentElement, JRBaseCrosstab, JRBaseElement, JRBaseEllipse, JRBaseFrame, JRBaseGenericElement, JRBaseGenericPrintElement, JRBaseGraphicElement, JRBaseImage, JRBaseLine, JRBasePrintElement, JRBasePrintEllipse, JRBasePrintFrame, JRBasePrintGraphicElement, JRBasePrintImage, JRBasePrintLine, JRBasePrintRectangle, JRBasePrintText, JRBaseRectangle, JRBaseStaticText, JRBaseSubreport, JRBaseTextElement, JRBaseTextField, JRDesignBreak, JRDesignChart, JRDesignComponentElement, JRDesignCrosstab, JRDesignElement, JRDesignEllipse, JRDesignFrame, JRDesignGenericElement, JRDesignGraphicElement, JRDesignImage, JRDesignLine, JRDesignRectangle, JRDesignStaticText, JRDesignSubreport, JRDesignTextElement, JRDesignTextField, JRFillBreak, JRFillChart, JRFillChartForAxis, JRFillComponentElement, JRFillCrosstab, JRFillElement, JRFillEllipse, JRFillFrame, JRFillGenericElement, JRFillGraphicElement, JRFillImage, JRFillLine, JRFillRectangle, JRFillStaticText, JRFillSubreport, JRFillTextElement, JRFillTextField, JRRecordedValuesGenericPrintElement, JRRecordedValuesPrintImage, JRRecordedValuesPrintText, JRTemplateElement, JRTemplateEllipse, JRTemplateFrame, JRTemplateGenericElement, JRTemplateGenericPrintElement, JRTemplateGraphicElement, JRTemplateImage, JRTemplateLine, JRTemplatePrintElement, JRTemplatePrintEllipse, JRTemplatePrintFrame, JRTemplatePrintGraphicElement, JRTemplatePrintImage, JRTemplatePrintLine, JRTemplatePrintRectangle, JRTemplatePrintText, JRTemplateRectangle, JRTemplateText, JRVirtualPrintPage.JRIdHolderTemplateElement, SubreportElementAdapter

public interface JRCommonElement extends JRStyleContainer
An abstract representation of a report element. All report elements implement this interface. The interface contains constants and methods that apply to all report elements.

The properties that are common to all types of report elements are grouped in the <reportElement> tag, which appears in the declaration of all report elements.

Element Key

Unlike variables and parameters, report elements are not required to have a name, because normally you do not need to obtain any individual element inside a report template. However, in some cases it is useful to be able to locate an element to alter one of its properties before using the report template.

This could be the case in an application for which the color of some elements in the report template needs to change based on user input. To locate the report elements that need to have their colors altered, the caller program could use the 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.

Element Size

The width and height attributes are mandatory and represent the size of the report element measured in pixels. Other element stretching settings may instruct the reporting engine to ignore the specified element height. Even in this case, the attributes remain mandatory since even when the height is calculated dynamically, the element will not be smaller than the originally specified height.

Element Transparency

Report elements can either be transparent or opaque, depending on the value specified for the mode attribute. The default value for this attribute depends on the type of the report element. Graphic elements like rectangles and lines are opaque by default, while images are transparent. Both static texts and text fields are transparent by default, and so are the subreport elements.

Element Color

Two attributes represent colors: forecolor and backcolor. The fore color is for the text of the text elements and the border of the graphic elements. The background color fills the background of the specified report element, if it is not transparent.

One can also use the decimal or hexadecimal representation for the desired color. The preferred way to specify colors in JRXML is using the hexadecimal representation, because it lets people control the level for each base color of the RGB system. For example, one can display a text field in red by setting its forecolor attribute as follows:

forecolor="#FF0000"

The equivalent using the decimal representation would be the following:

forecolor="16711680"

The default fore color is black and the default background color is white.

Author:
Teodor Danciu (teodord@users.sourceforge.net)
  • Method Details

    • getWidth

      int getWidth()
    • getHeight

      int getHeight()
    • getKey

      String getKey()
      Returns the string value that uniquely identifies the element.
    • 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()
    • setMode

      void setMode(ModeEnum mode)
      Sets the element transparency mode.
    • getForecolor

      Color getForecolor()
    • getOwnForecolor

      Color getOwnForecolor()
    • setForecolor

      void setForecolor(Color forecolor)
    • getBackcolor

      Color getBackcolor()
    • getOwnBackcolor

      Color getOwnBackcolor()
    • setBackcolor

      void setBackcolor(Color backcolor)