net.sf.jasperreports.engine.design
Class JasperDesign

java.lang.Object
  extended bynet.sf.jasperreports.engine.base.JRBaseReport
      extended bynet.sf.jasperreports.engine.design.JasperDesign
All Implemented Interfaces:
JRDefaultFontProvider, JRReport, java.io.Serializable

public class JasperDesign
extends JRBaseReport

JasperDesign is used for in-memory representation of a report design. Instances of this class can be easily created from an XML template and viceversa. It contains all report properties and report elements in their design time state.

The main reason for using this class is for modifying report templates at run time. Although using compiled reports is usually recommended, sometimes people need to dinamically change a report design.

Version:
$Id: JasperDesign.java,v 1.53 2005/09/07 13:58:25 teodord Exp $
Author:
Teodor Danciu (teodord@users.sourceforge.net)
See Also:
JRXmlLoader, Serialized Form

Field Summary
static java.lang.String BACKGROUND_PROPERTY
          Bean property name for background.
static java.lang.String BOTTOM_MARGIN_PROPERTY
          Bean property name for bottom margin.
static java.lang.String COLUMN_COUNT_PROPERTY
          Bean property name for column count.
static java.lang.String COLUMN_FOOTER_PROPERTY
          Bean property name for column footer.
static java.lang.String COLUMN_HEADER_PROPERTY
          Bean property name for column header.
static java.lang.String COLUMN_SPACING_PROPERTY
          Bean property name for column spacing.
static java.lang.String COLUMN_WIDTH_PROPERTY
          Bean property name for column width.
static java.lang.String DEFAULT_FONT_PROPERTY
          Bean property name for default font.
static java.lang.String DETAIL_PROPERTY
          Bean property name for detail band.
static java.lang.String FLOAT_COLUMN_FOOTER_PROPERTY
          Bean property name for float column footer.
static java.lang.String LANGUAGE_PROPERTY
          Bean property name for language.
static java.lang.String LAST_PAGE_FOOTER_PROPERTY
          Bean property name for last page footer.
static java.lang.String LEFT_MARGIN_PROPERTY
          Bean property name for left margin.
static java.lang.String NAME_PROPERTY
          Bean property name for the report's name.
static java.lang.String ORIENTATION_PROPERTY
          Bean property name for orientation.
static java.lang.String PAGE_FOOTER_PROPERTY
          Bean property name for page footer.
static java.lang.String PAGE_HEADER_PROPERTY
          Bean property name for page header.
static java.lang.String PAGE_HEIGHT_PROPERTY
          Bean property name for page height.
static java.lang.String PAGE_WIDTH_PROPERTY
          Bean property name for page width.
static java.lang.String PRINT_ORDER_PROPERTY
          Bean property name for last page footer.
static java.lang.String QUERY_PROPERTY
          Bean property name for query.
static java.lang.String RESOURCE_BUNDLE_PROPERTY
          Bean property name for resource bundle.
static java.lang.String RIGHT_MARGIN_PROPERTY
          Bean property name for right margin.
static java.lang.String SCRIPTLET_CLASS_PROPERTY
          Bean property name for scriptlet class.
static java.lang.String SUMMARY_NEW_PAGE_PROPERTY
          Bean property name for summary new page.
static java.lang.String SUMMARY_PROPERTY
          Bean property name for summary.
static java.lang.String TITLE_NEW_PAGE_PROPERTY
          Bean property name for title new page.
static java.lang.String TITLE_PROPERTY
          Bean property name for title.
static java.lang.String TOP_MARGIN_PROPERTY
          Bean property name for top margin.
 
Fields inherited from class net.sf.jasperreports.engine.base.JRBaseReport
background, bottomMargin, columnCount, columnFooter, columnHeader, columnSpacing, columnWidth, defaultFont, detail, fields, fonts, groups, importsSet, isFloatColumnFooter, isSummaryNewPage, isTitleNewPage, language, lastPageFooter, leftMargin, name, orientation, pageFooter, pageHeader, pageHeight, pageWidth, parameters, printOrder, propertiesMap, query, resourceBundle, rightMargin, scriptletClass, summary, title, topMargin, variables, whenNoDataType, whenResourceMissingType
 
Fields inherited from interface net.sf.jasperreports.engine.JRReport
LANGUAGE_JAVA, ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT, PRINT_ORDER_HORIZONTAL, PRINT_ORDER_VERTICAL, WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL, WHEN_NO_DATA_TYPE_BLANK_PAGE, WHEN_NO_DATA_TYPE_NO_PAGES, WHEN_RESOURCE_MISSING_TYPE_EMPTY, WHEN_RESOURCE_MISSING_TYPE_ERROR, WHEN_RESOURCE_MISSING_TYPE_KEY, WHEN_RESOURCE_MISSING_TYPE_NULL
 
Constructor Summary
JasperDesign()
          Constructs a JasperDesign object and fills it with the default variables and parameters.
 
Method Summary
 void addField(JRField field)
           
 void addFont(JRReportFont reportFont)
          Adds a report font, that can be referenced by text elements.
 void addGroup(JRDesignGroup group)
          Adds a new group to the report design.
 void addImport(java.lang.String value)
          Adds an import (needed if report expression require additional classes in order to compile).
 void addParameter(JRParameter parameter)
          Adds a report parameter.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a property listener to listen to all properties of this class.
 void addPropertyChangeListener(java.lang.String propName, java.beans.PropertyChangeListener l)
          Add a property listener to receive property change events for only one specific property.
 void addVariable(JRDesignVariable variable)
           
 java.util.Collection getExpressions()
          Returns a collection of all report expressions.
 JRField[] getFields()
          Gets an array of report fields.
 java.util.List getFieldsList()
          Gets an array of report fields.
 java.util.Map getFieldsMap()
          Gets a map of report fields.
 JRReportFont[] getFonts()
          Gets an array of report level fonts.
 java.util.List getFontsList()
          Gets a list of report level fonts.
 java.util.Map getFontsMap()
           
 JRGroup[] getGroups()
          Gets an array of report groups.
 java.util.List getGroupsList()
          Gets a list of report groups.
 java.util.Map getGroupsMap()
          Gets a map of report groups.
 JRParameter[] getParameters()
          Gets an array of report parameters (including built-in ones).
 java.util.List getParametersList()
          Gets a list of report parameters (including built-in ones).
 java.util.Map getParametersMap()
          Gets a map of report parameters (including built-in ones).
protected  java.beans.PropertyChangeSupport getPropertyChangeSupport()
          Get the property change support object for this class.
 JRVariable[] getVariables()
          Gets an array of report variables.
 java.util.List getVariablesList()
          Gets a list of report variables.
 java.util.Map getVariablesMap()
          Gets a map of report variables.
 JRField removeField(JRField field)
           
 JRField removeField(java.lang.String fieldName)
           
 JRReportFont removeFont(JRReportFont reportFont)
          Removes a report font from the list.
 JRReportFont removeFont(java.lang.String propName)
          Removes a report font from the list, based on the font name.
 JRGroup removeGroup(JRGroup group)
           
 JRGroup removeGroup(java.lang.String groupName)
           
 void removeImport(java.lang.String value)
          Removes an import.
 JRParameter removeParameter(JRParameter parameter)
          Removes a report parameter.
 JRParameter removeParameter(java.lang.String parameterName)
          Removes a report parameter, based on its name.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener.
 JRVariable removeVariable(JRVariable variable)
           
 JRVariable removeVariable(java.lang.String variableName)
           
 void setBackground(JRBand background)
          Sets the background band.
 void setBottomMargin(int bottomMargin)
          Sets the top margin.
 void setColumnCount(int columnCount)
          Specifies the number of report columns.
 void setColumnFooter(JRBand columnFooter)
          Sets the column footer band.
 void setColumnHeader(JRBand columnHeader)
          Sets the column header band.
 void setColumnSpacing(int columnSpacing)
          Sets the spacing between columns.
 void setColumnWidth(int columnWidth)
          Sets the column width.
 void setDefaultFont(JRReportFont font)
           
 void setDetail(JRBand detail)
          Sets the detail band.
 void setFloatColumnFooter(boolean isFloatColumnFooter)
          Flag used to specify if the column footer section should be printed at the bottom of the column or if it should immediately follow the last detail or group footer printed on the current column.
 void setLanguage(java.lang.String language)
          Specifies the language used for report expressions (Java or Groovy).
 void setLastPageFooter(JRBand lastPageFooter)
          Sets the last page footer band.
 void setLeftMargin(int leftMargin)
          Sets the left margin.
 void setName(java.lang.String name)
          Sets the report name.
 void setOrientation(byte orientation)
          Sets the report orientation.
 void setPageFooter(JRBand pageFooter)
          Sets the page footer band.
 void setPageHeader(JRBand pageHeader)
          Sets the page header band.
 void setPageHeight(int pageHeight)
          Sets page height (including margins etc.).
 void setPageWidth(int pageWidth)
          Sets page width (including margins etc.).
 void setPrintOrder(byte printOrder)
          Sets the print order.
 void setQuery(JRQuery query)
          Specifies the report query.
 void setResourceBundle(java.lang.String resourceBundle)
          Sets the base name of the report associated resource bundle.
 void setRightMargin(int rightMargin)
          Sets the right margin.
 void setScriptletClass(java.lang.String scriptletClass)
           
 void setSummary(JRBand summary)
          Sets the summary band.
 void setSummaryNewPage(boolean isSummaryNewPage)
          Flag used to specify if the summary section should be printed on a separate last page.
 void setTitle(JRBand title)
          Sets the title band.
 void setTitleNewPage(boolean isTitleNewPage)
          Flag used to specify if the title section should be printed on a separate initial page.
 void setTopMargin(int topMargin)
          Sets the top margin.
 
Methods inherited from class net.sf.jasperreports.engine.base.JRBaseReport
getBackground, getBottomMargin, getColumnCount, getColumnFooter, getColumnHeader, getColumnSpacing, getColumnWidth, getDefaultFont, getDetail, getImports, getLanguage, getLastPageFooter, getLeftMargin, getName, getOrientation, getPageFooter, getPageHeader, getPageHeight, getPageWidth, getPrintOrder, getProperty, getPropertyNames, getQuery, getResourceBundle, getRightMargin, getScriptletClass, getSummary, getTitle, getTopMargin, getWhenNoDataType, getWhenResourceMissingType, isFloatColumnFooter, isSummaryNewPage, isTitleNewPage, removeProperty, setProperty, setWhenNoDataType, setWhenResourceMissingType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_PROPERTY

public static final java.lang.String NAME_PROPERTY
Bean property name for the report's name.

See Also:
Constant Field Values

LANGUAGE_PROPERTY

public static final java.lang.String LANGUAGE_PROPERTY
Bean property name for language.

See Also:
Constant Field Values

QUERY_PROPERTY

public static final java.lang.String QUERY_PROPERTY
Bean property name for query.

See Also:
Constant Field Values

RESOURCE_BUNDLE_PROPERTY

public static final java.lang.String RESOURCE_BUNDLE_PROPERTY
Bean property name for resource bundle.

See Also:
Constant Field Values

SCRIPTLET_CLASS_PROPERTY

public static final java.lang.String SCRIPTLET_CLASS_PROPERTY
Bean property name for scriptlet class.

See Also:
Constant Field Values

ORIENTATION_PROPERTY

public static final java.lang.String ORIENTATION_PROPERTY
Bean property name for orientation.

See Also:
Constant Field Values

BACKGROUND_PROPERTY

public static final java.lang.String BACKGROUND_PROPERTY
Bean property name for background.

See Also:
Constant Field Values

COLUMN_COUNT_PROPERTY

public static final java.lang.String COLUMN_COUNT_PROPERTY
Bean property name for column count.

See Also:
Constant Field Values

COLUMN_HEADER_PROPERTY

public static final java.lang.String COLUMN_HEADER_PROPERTY
Bean property name for column header.

See Also:
Constant Field Values

COLUMN_FOOTER_PROPERTY

public static final java.lang.String COLUMN_FOOTER_PROPERTY
Bean property name for column footer.

See Also:
Constant Field Values

LEFT_MARGIN_PROPERTY

public static final java.lang.String LEFT_MARGIN_PROPERTY
Bean property name for left margin.

See Also:
Constant Field Values

RIGHT_MARGIN_PROPERTY

public static final java.lang.String RIGHT_MARGIN_PROPERTY
Bean property name for right margin.

See Also:
Constant Field Values

TOP_MARGIN_PROPERTY

public static final java.lang.String TOP_MARGIN_PROPERTY
Bean property name for top margin.

See Also:
Constant Field Values

BOTTOM_MARGIN_PROPERTY

public static final java.lang.String BOTTOM_MARGIN_PROPERTY
Bean property name for bottom margin.

See Also:
Constant Field Values

COLUMN_WIDTH_PROPERTY

public static final java.lang.String COLUMN_WIDTH_PROPERTY
Bean property name for column width.

See Also:
Constant Field Values

COLUMN_SPACING_PROPERTY

public static final java.lang.String COLUMN_SPACING_PROPERTY
Bean property name for column spacing.

See Also:
Constant Field Values

PRINT_ORDER_PROPERTY

public static final java.lang.String PRINT_ORDER_PROPERTY
Bean property name for last page footer.

See Also:
Constant Field Values

DEFAULT_FONT_PROPERTY

public static final java.lang.String DEFAULT_FONT_PROPERTY
Bean property name for default font.

See Also:
Constant Field Values

TITLE_PROPERTY

public static final java.lang.String TITLE_PROPERTY
Bean property name for title.

See Also:
Constant Field Values

TITLE_NEW_PAGE_PROPERTY

public static final java.lang.String TITLE_NEW_PAGE_PROPERTY
Bean property name for title new page.

See Also:
Constant Field Values

PAGE_WIDTH_PROPERTY

public static final java.lang.String PAGE_WIDTH_PROPERTY
Bean property name for page width.

See Also:
Constant Field Values

PAGE_HEIGHT_PROPERTY

public static final java.lang.String PAGE_HEIGHT_PROPERTY
Bean property name for page height.

See Also:
Constant Field Values

PAGE_HEADER_PROPERTY

public static final java.lang.String PAGE_HEADER_PROPERTY
Bean property name for page header.

See Also:
Constant Field Values

PAGE_FOOTER_PROPERTY

public static final java.lang.String PAGE_FOOTER_PROPERTY
Bean property name for page footer.

See Also:
Constant Field Values

LAST_PAGE_FOOTER_PROPERTY

public static final java.lang.String LAST_PAGE_FOOTER_PROPERTY
Bean property name for last page footer.

See Also:
Constant Field Values

SUMMARY_PROPERTY

public static final java.lang.String SUMMARY_PROPERTY
Bean property name for summary.

See Also:
Constant Field Values

SUMMARY_NEW_PAGE_PROPERTY

public static final java.lang.String SUMMARY_NEW_PAGE_PROPERTY
Bean property name for summary new page.

See Also:
Constant Field Values

FLOAT_COLUMN_FOOTER_PROPERTY

public static final java.lang.String FLOAT_COLUMN_FOOTER_PROPERTY
Bean property name for float column footer.

See Also:
Constant Field Values

DETAIL_PROPERTY

public static final java.lang.String DETAIL_PROPERTY
Bean property name for detail band.

See Also:
Constant Field Values
Constructor Detail

JasperDesign

public JasperDesign()
Constructs a JasperDesign object and fills it with the default variables and parameters.

Method Detail

setName

public void setName(java.lang.String name)
Sets the report name. It is strongly recommended that the report name matches the .jrxml file name, since report compilers usually use this name for the compiled .jasper file.


setLanguage

public void setLanguage(java.lang.String language)
Specifies the language used for report expressions (Java or Groovy). The default is Java.


setColumnCount

public void setColumnCount(int columnCount)
Specifies the number of report columns.


setPrintOrder

public void setPrintOrder(byte printOrder)
Sets the print order. In case of multiple column reports, the engine can perform vertical or horizontal fill.

See Also:
PRINT_ORDER_VERTICAL,, PRINT_ORDER_HORIZONTAL

setPageWidth

public void setPageWidth(int pageWidth)
Sets page width (including margins etc.). Default is 595.


setPageHeight

public void setPageHeight(int pageHeight)
Sets page height (including margins etc.). Default is 842.


setOrientation

public void setOrientation(byte orientation)
Sets the report orientation.

See Also:
ORIENTATION_PORTRAIT,, ORIENTATION_LANDSCAPE

setColumnWidth

public void setColumnWidth(int columnWidth)
Sets the column width.


setColumnSpacing

public void setColumnSpacing(int columnSpacing)
Sets the spacing between columns.


setLeftMargin

public void setLeftMargin(int leftMargin)
Sets the left margin. The working space is calculated by subtracting the margins from the page width.


setRightMargin

public void setRightMargin(int rightMargin)
Sets the right margin. The working space is calculated by subtracting the margins from the page width.


setTopMargin

public void setTopMargin(int topMargin)
Sets the top margin. The working space is calculated by subtracting the margins from the page height.


setBottomMargin

public void setBottomMargin(int bottomMargin)
Sets the top margin. The working space is calculated by subtracting the margins from the page height.


setBackground

public void setBackground(JRBand background)
Sets the background band.


setTitle

public void setTitle(JRBand title)
Sets the title band.


setTitleNewPage

public void setTitleNewPage(boolean isTitleNewPage)
Flag used to specify if the title section should be printed on a separate initial page.

Parameters:
isTitleNewPage - true if the title section should be displayed on a separate initial page, false if it will be displayed on the first page along with other sections.

setSummary

public void setSummary(JRBand summary)
Sets the summary band.


setSummaryNewPage

public void setSummaryNewPage(boolean isSummaryNewPage)
Flag used to specify if the summary section should be printed on a separate last page.

Parameters:
isSummaryNewPage - true if the summary section should be displayed on a separate last page, false if it will be displayed on the last page along with other sections, if there is enough space.

setFloatColumnFooter

public void setFloatColumnFooter(boolean isFloatColumnFooter)
Flag used to specify if the column footer section should be printed at the bottom of the column or if it should immediately follow the last detail or group footer printed on the current column.


setPageHeader

public void setPageHeader(JRBand pageHeader)
Sets the page header band.


setPageFooter

public void setPageFooter(JRBand pageFooter)
Sets the page footer band.


setLastPageFooter

public void setLastPageFooter(JRBand lastPageFooter)
Sets the last page footer band.


setColumnHeader

public void setColumnHeader(JRBand columnHeader)
Sets the column header band.


setColumnFooter

public void setColumnFooter(JRBand columnFooter)
Sets the column footer band.


setDetail

public void setDetail(JRBand detail)
Sets the detail band.


setScriptletClass

public void setScriptletClass(java.lang.String scriptletClass)

setResourceBundle

public void setResourceBundle(java.lang.String resourceBundle)
Sets the base name of the report associated resource bundle.


addImport

public void addImport(java.lang.String value)
Adds an import (needed if report expression require additional classes in order to compile).


removeImport

public void removeImport(java.lang.String value)
Removes an import.


setDefaultFont

public void setDefaultFont(JRReportFont font)

getFonts

public JRReportFont[] getFonts()
Gets an array of report level fonts. These fonts can be referenced by text elements.

Specified by:
getFonts in interface JRReport
Overrides:
getFonts in class JRBaseReport

getFontsList

public java.util.List getFontsList()
Gets a list of report level fonts. These fonts can be referenced by text elements.


getFontsMap

public java.util.Map getFontsMap()

addFont

public void addFont(JRReportFont reportFont)
             throws JRException
Adds a report font, that can be referenced by text elements.

Throws:
JRException

removeFont

public JRReportFont removeFont(java.lang.String propName)
Removes a report font from the list, based on the font name.


removeFont

public JRReportFont removeFont(JRReportFont reportFont)
Removes a report font from the list.


getParameters

public JRParameter[] getParameters()
Gets an array of report parameters (including built-in ones).

Specified by:
getParameters in interface JRReport
Overrides:
getParameters in class JRBaseReport

getParametersList

public java.util.List getParametersList()
Gets a list of report parameters (including built-in ones).


getParametersMap

public java.util.Map getParametersMap()
Gets a map of report parameters (including built-in ones).


addParameter

public void addParameter(JRParameter parameter)
                  throws JRException
Adds a report parameter.

Throws:
JRException

removeParameter

public JRParameter removeParameter(java.lang.String parameterName)
Removes a report parameter, based on its name.


removeParameter

public JRParameter removeParameter(JRParameter parameter)
Removes a report parameter.


setQuery

public void setQuery(JRQuery query)
Specifies the report query. This is used only when datasource type is JDBC (a java.sql.Connection).


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a property listener to listen to all properties of this class.

Parameters:
l - The property listener to add.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propName,
                                      java.beans.PropertyChangeListener l)
Add a property listener to receive property change events for only one specific property.

Parameters:
propName - The property to listen to.
l - The property listener to add.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a property change listener. This will remove any listener that was added through either of the addPropertyListener methods.

Parameters:
l - The listener to remove.

getPropertyChangeSupport

protected java.beans.PropertyChangeSupport getPropertyChangeSupport()
Get the property change support object for this class. Because the property change support object has to be transient, it may need to be created.

Returns:
The property change support object.

getFields

public JRField[] getFields()
Gets an array of report fields.

Specified by:
getFields in interface JRReport
Overrides:
getFields in class JRBaseReport

getFieldsList

public java.util.List getFieldsList()
Gets an array of report fields.


getFieldsMap

public java.util.Map getFieldsMap()
Gets a map of report fields.


addField

public void addField(JRField field)
              throws JRException
Throws:
JRException

removeField

public JRField removeField(java.lang.String fieldName)

removeField

public JRField removeField(JRField field)

getVariables

public JRVariable[] getVariables()
Gets an array of report variables.

Specified by:
getVariables in interface JRReport
Overrides:
getVariables in class JRBaseReport

getVariablesList

public java.util.List getVariablesList()
Gets a list of report variables.


getVariablesMap

public java.util.Map getVariablesMap()
Gets a map of report variables.


addVariable

public void addVariable(JRDesignVariable variable)
                 throws JRException
Throws:
JRException

removeVariable

public JRVariable removeVariable(java.lang.String variableName)

removeVariable

public JRVariable removeVariable(JRVariable variable)

getGroups

public JRGroup[] getGroups()
Gets an array of report groups.

Specified by:
getGroups in interface JRReport
Overrides:
getGroups in class JRBaseReport

getGroupsList

public java.util.List getGroupsList()
Gets a list of report groups.


getGroupsMap

public java.util.Map getGroupsMap()
Gets a map of report groups.


addGroup

public void addGroup(JRDesignGroup group)
              throws JRException
Adds a new group to the report design. Groups are nested.

Throws:
JRException

removeGroup

public JRGroup removeGroup(java.lang.String groupName)

removeGroup

public JRGroup removeGroup(JRGroup group)

getExpressions

public java.util.Collection getExpressions()
Returns a collection of all report expressions.



© 2001-2005 JasperSoft Corporation www.jaspersoft.com