net.sf.jasperreports.crosstabs.base
Class JRBaseCrosstab

java.lang.Object
  extended by net.sf.jasperreports.engine.base.JRBaseElement
      extended by net.sf.jasperreports.crosstabs.base.JRBaseCrosstab
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, JRCrosstab, JRChangeEventsSupport, JRBoxContainer, JRChild, JRCloneable, JRCommonElement, JRElement, JRIdentifiable, JRPropertiesHolder, JRStyleContainer, JRVisitable

public class JRBaseCrosstab
extends JRBaseElement
implements JRCrosstab

Base read-only crosstab implementation.

Version:
$Id: JRBaseCrosstab.java 5180 2012-03-29 13:23:12Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)
See Also:
Serialized Form

Field Summary
protected  JRCrosstabCell[][] cells
           
protected  int columnBreakOffset
           
protected  JRCrosstabColumnGroup[] columnGroups
           
protected  JRCrosstabDataset dataset
           
protected  JRCellContents headerCell
           
protected  int id
           
protected  java.lang.Boolean ignoreWidth
           
protected  JRLineBox lineBox
           
protected  JRCrosstabMeasure[] measures
           
protected  JRCrosstabParameter[] parameters
           
protected  JRExpression parametersMapExpression
           
static java.lang.String PROPERTY_IGNORE_WIDTH
           
static java.lang.String PROPERTY_RUN_DIRECTION
           
protected  boolean repeatColumnHeaders
           
protected  boolean repeatRowHeaders
           
protected  JRCrosstabRowGroup[] rowGroups
           
protected  RunDirectionEnum runDirectionValue
           
protected  JRVariable[] variables
           
protected  JRCellContents whenNoDataCell
           
 
Fields inherited from class net.sf.jasperreports.engine.base.JRBaseElement
backcolor, defaultStyleProvider, elementGroup, forecolor, height, isPrintInFirstWholeBand, isPrintRepeatedValues, isPrintWhenDetailOverflows, isRemoveLineWhenBlank, key, modeValue, parentStyle, parentStyleNameReference, positionTypeValue, printWhenExpression, printWhenGroupChanges, PROPERTY_POSITION_TYPE, PROPERTY_PRINT_IN_FIRST_WHOLE_BAND, PROPERTY_PRINT_REPEATED_VALUES, PROPERTY_PRINT_WHEN_DETAIL_OVERFLOWS, PROPERTY_REMOVE_LINE_WHEN_BLANK, PROPERTY_STRETCH_TYPE, PROPERTY_WIDTH, PROPERTY_X, stretchTypeValue, uuid, width, x, y
 
Fields inherited from interface net.sf.jasperreports.crosstabs.JRCrosstab
DEFAULT_COLUMN_BREAK_OFFSET, VARIABLE_COLUMN_COUNT, VARIABLE_ROW_COUNT
 
Constructor Summary
JRBaseCrosstab(JRCrosstab crosstab, JRBaseObjectFactory factory, int id)
           
 
Method Summary
 java.lang.Object clone()
           
 void collectExpressions(JRExpressionCollector collector)
           
 JRCrosstabCell[][] getCells()
          Returns the data cell matrix.
 int getColumnBreakOffset()
          Returns the column break offset.
 JRCrosstabColumnGroup[] getColumnGroups()
          Returns the column groups of the crosstab.
 JRCrosstabDataset getDataset()
          Returns the input dataset of the crosstab.
 java.awt.Color getDefaultLineColor()
           
static JRElement getElementByKey(JRCrosstab crosstab, java.lang.String key)
           
 JRElement getElementByKey(java.lang.String elementKey)
          Searches for an element inside all crosstab cells.
 JRCellContents getHeaderCell()
          Returns a cell which will be rendered at the upper-left corner of the crosstab.
 int getId()
          Returns the ID of the crosstab.
 java.lang.Boolean getIgnoreWidth()
          Returns the ignore width flag for the crosstab.
 JRLineBox getLineBox()
           
 JRCrosstabMeasure[] getMeasures()
          Returns the crosstab measures.
 ModeEnum getModeValue()
          Returns the element transparency mode.
 JRCrosstabParameter[] getParameters()
          Returns the crosstab parameters.
 JRExpression getParametersMapExpression()
          Returns the parameters map expression.
 JRCrosstabRowGroup[] getRowGroups()
          Returns the row groups of the crosstab.
 RunDirectionEnum getRunDirectionValue()
          Retrieves the run direction of this crosstab
 JRVariable[] getVariables()
          Returns the variables defined for the crosstab.
 JRCellContents getWhenNoDataCell()
          Returns a cell which will be rendered when no data was fed to the crosstab.
 boolean isRepeatColumnHeaders()
          Returns whether to repeat the column headers after a row break.
 boolean isRepeatRowHeaders()
          Returns whether to repeat the row headers after a column break.
 void setIgnoreWidth(boolean ignoreWidth)
          Set the ignore width crosstab flag.
 void setIgnoreWidth(java.lang.Boolean ignoreWidth)
          Set the ignore width crosstab flag.
 void setRunDirection(RunDirectionEnum runDirectionValue)
          Sets the run direction of the crosstab.
 void visit(JRVisitor visitor)
           
 
Methods inherited from class net.sf.jasperreports.engine.base.JRBaseElement
clone, getBackcolor, getBaseStyle, getDefaultStyleProvider, getElementGroup, getEventSupport, getForecolor, getHeight, getKey, getOwnBackcolor, getOwnForecolor, getOwnModeValue, getParentProperties, getPositionTypeValue, getPrintWhenExpression, getPrintWhenGroupChanges, getPropertiesMap, getPropertyExpressions, getStretchTypeValue, getStyle, getStyleNameReference, getUUID, getWidth, getX, getY, hasProperties, isPrintInFirstWholeBand, isPrintRepeatedValues, isPrintWhenDetailOverflows, isRemoveLineWhenBlank, setBackcolor, setForecolor, setMode, setPositionType, setPrintInFirstWholeBand, setPrintRepeatedValues, setPrintWhenDetailOverflows, setRemoveLineWhenBlank, setStretchType, setWidth, setX
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jasperreports.engine.JRElement
getElementGroup, getKey, getPositionTypeValue, getPrintWhenExpression, getPrintWhenGroupChanges, getPropertyExpressions, getStretchTypeValue, getX, getY, isPrintInFirstWholeBand, isPrintRepeatedValues, isPrintWhenDetailOverflows, isRemoveLineWhenBlank, setPositionType, setPrintInFirstWholeBand, setPrintRepeatedValues, setPrintWhenDetailOverflows, setRemoveLineWhenBlank, setStretchType, setWidth, setX
 
Methods inherited from interface net.sf.jasperreports.engine.JRChild
clone
 
Methods inherited from interface net.sf.jasperreports.engine.JRCommonElement
getBackcolor, getForecolor, getHeight, getOwnBackcolor, getOwnForecolor, getOwnModeValue, getWidth, setBackcolor, setForecolor, setMode
 
Methods inherited from interface net.sf.jasperreports.engine.JRStyleContainer
getDefaultStyleProvider, getStyle, getStyleNameReference
 
Methods inherited from interface net.sf.jasperreports.engine.JRIdentifiable
getUUID
 
Methods inherited from interface net.sf.jasperreports.engine.JRPropertiesHolder
getParentProperties, getPropertiesMap, hasProperties
 

Field Detail

PROPERTY_RUN_DIRECTION

public static final java.lang.String PROPERTY_RUN_DIRECTION
See Also:
Constant Field Values

PROPERTY_IGNORE_WIDTH

public static final java.lang.String PROPERTY_IGNORE_WIDTH
See Also:
Constant Field Values

id

protected int id

parameters

protected JRCrosstabParameter[] parameters

variables

protected JRVariable[] variables

parametersMapExpression

protected JRExpression parametersMapExpression

dataset

protected JRCrosstabDataset dataset

rowGroups

protected JRCrosstabRowGroup[] rowGroups

columnGroups

protected JRCrosstabColumnGroup[] columnGroups

measures

protected JRCrosstabMeasure[] measures

columnBreakOffset

protected int columnBreakOffset

repeatColumnHeaders

protected boolean repeatColumnHeaders

repeatRowHeaders

protected boolean repeatRowHeaders

runDirectionValue

protected RunDirectionEnum runDirectionValue

cells

protected JRCrosstabCell[][] cells

whenNoDataCell

protected JRCellContents whenNoDataCell

headerCell

protected JRCellContents headerCell

ignoreWidth

protected java.lang.Boolean ignoreWidth

lineBox

protected JRLineBox lineBox
Constructor Detail

JRBaseCrosstab

public JRBaseCrosstab(JRCrosstab crosstab,
                      JRBaseObjectFactory factory,
                      int id)
Method Detail

getModeValue

public ModeEnum getModeValue()
Description copied from interface: JRCommonElement
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.

Specified by:
getModeValue in interface JRCommonElement
Overrides:
getModeValue in class JRBaseElement

getId

public int getId()
Description copied from interface: JRCrosstab
Returns the ID of the crosstab.

The ID is generated when the report is compiled and is used internally.

Specified by:
getId in interface JRCrosstab
Returns:
the ID of the crosstab

getDataset

public JRCrosstabDataset getDataset()
Description copied from interface: JRCrosstab
Returns the input dataset of the crosstab.

Specified by:
getDataset in interface JRCrosstab
Returns:
the input dataset of the crosstab

getRowGroups

public JRCrosstabRowGroup[] getRowGroups()
Description copied from interface: JRCrosstab
Returns the row groups of the crosstab.

Specified by:
getRowGroups in interface JRCrosstab
Returns:
the row groups

getColumnGroups

public JRCrosstabColumnGroup[] getColumnGroups()
Description copied from interface: JRCrosstab
Returns the column groups of the crosstab.

Specified by:
getColumnGroups in interface JRCrosstab
Returns:
the column groups

getMeasures

public JRCrosstabMeasure[] getMeasures()
Description copied from interface: JRCrosstab
Returns the crosstab measures.

Specified by:
getMeasures in interface JRCrosstab
Returns:
the crosstab measures

collectExpressions

public void collectExpressions(JRExpressionCollector collector)
Specified by:
collectExpressions in interface JRElement

visit

public void visit(JRVisitor visitor)
Specified by:
visit in interface JRVisitable

getColumnBreakOffset

public int getColumnBreakOffset()
Description copied from interface: JRCrosstab
Returns the column break offset.

When the crosstab columns do not fit the width, the crosstab breaks the columns and prints the ones that don't fit after printing the first set of columns for all rows. This method returns the offset to be used when continuing the printing after a column break.

Specified by:
getColumnBreakOffset in interface JRCrosstab
Returns:
the column break offset

isRepeatColumnHeaders

public boolean isRepeatColumnHeaders()
Description copied from interface: JRCrosstab
Returns whether to repeat the column headers after a row break.

Specified by:
isRepeatColumnHeaders in interface JRCrosstab
Returns:
whether to repeat the column headers after a row break

isRepeatRowHeaders

public boolean isRepeatRowHeaders()
Description copied from interface: JRCrosstab
Returns whether to repeat the row headers after a column break.

Specified by:
isRepeatRowHeaders in interface JRCrosstab
Returns:
whether to repeat the row headers after a column break

getCells

public JRCrosstabCell[][] getCells()
Description copied from interface: JRCrosstab
Returns the data cell matrix.

A crosstab can have multiple data cells for row/groups totals. These cells are organized in a (rowGroupCount + 1) x (columnGroupCount + 1) matrix as following:

E.g. if the crosstab has Country and City (subgroup of Country) row groups and Year and Month column groups, the cells will be organized in the following matrix

0/Years total 1/Months total 2/Base
0/Countries total Total for all countries and all years Total for all countries and a year Total for all countries and a month
1/Cities total Total for a country and all years Total for a country and a year Total for a country and a month
2/Base Total for a city and all years Total for a city and a year Total for a city and a month

If the data cell for a total row/column is not specified, the cell will be inherited from lower levels, if possible. For example, if the "Total for all countries and a year" cell is not specified, the "Total for a country and a year" or "Total for a city and a year" cell will be used (in this order).

The data cell sizes are calculated from the base data cell sizes, i.e. the height of all data cells for a row will be the height of the base cell of that row. The base cell sizes are also inherited, e.g. if the height of a total row is not specified the height of the base row will be used.

Specified by:
getCells in interface JRCrosstab
Returns:
the data cell matrix

getParameters

public JRCrosstabParameter[] getParameters()
Description copied from interface: JRCrosstab
Returns the crosstab parameters.

Crosstabs have separate expression evaluators and cannot access the parameters/fields/variables of the report. In order to use a value from the report inside a crosstab, it should be passed as parameter to the crosstab.

A crosstab parameters has a name and a value expression.

Specified by:
getParameters in interface JRCrosstab
Returns:
the crosstab parameters

getParametersMapExpression

public JRExpression getParametersMapExpression()
Description copied from interface: JRCrosstab
Returns the parameters map expression.

The set of values for crosstab parameters can be set using a map. If a parameter has also a value expression, it will overwrite the value from the map.

Specified by:
getParametersMapExpression in interface JRCrosstab
Returns:
the parameters map expression

getWhenNoDataCell

public JRCellContents getWhenNoDataCell()
Description copied from interface: JRCrosstab
Returns a cell which will be rendered when no data was fed to the crosstab.

If this cell is not specified for a crosstab, nothing will be rendered for an empty crosstab.

The cell sizes are the same as the crosstab element sizes.

Specified by:
getWhenNoDataCell in interface JRCrosstab
Returns:
a cell which will be rendered when no data was fed to the crosstab

getElementByKey

public static JRElement getElementByKey(JRCrosstab crosstab,
                                        java.lang.String key)

getElementByKey

public JRElement getElementByKey(java.lang.String elementKey)
Description copied from interface: JRCrosstab
Searches for an element inside all crosstab cells.

Specified by:
getElementByKey in interface JRCrosstab
Parameters:
elementKey - the element key
Returns:
the first element having the specified key

getHeaderCell

public JRCellContents getHeaderCell()
Description copied from interface: JRCrosstab
Returns a cell which will be rendered at the upper-left corner of the crosstab.

The cell size will be calculated based on the row/column header cell widths/heights.

Specified by:
getHeaderCell in interface JRCrosstab
Returns:
a cell which will be rendered at the upper-left corner of the crosstab

getVariables

public JRVariable[] getVariables()
Description copied from interface: JRCrosstab
Returns the variables defined for the crosstab.

Specified by:
getVariables in interface JRCrosstab
Returns:
variables defined for the crosstab
See Also:
JRCrosstabGroup.getVariable(), JRCrosstabMeasure.getVariable(), JRCrosstab.VARIABLE_ROW_COUNT, JRCrosstab.VARIABLE_COLUMN_COUNT

getRunDirectionValue

public RunDirectionEnum getRunDirectionValue()
Description copied from interface: JRCrosstab
Retrieves the run direction of this crosstab

Specified by:
getRunDirectionValue in interface JRCrosstab
Returns:
a value representing one of the run direction constants in RunDirectionEnum

setRunDirection

public void setRunDirection(RunDirectionEnum runDirectionValue)
Description copied from interface: JRCrosstab
Sets the run direction of the crosstab.

Crosstabs can either be filled from left to right (the default) or from right to left (mainly for reports in RTL languages).

Specified by:
setRunDirection in interface JRCrosstab
Parameters:
runDirectionValue - a value representing one of the run direction constants in RunDirectionEnum

clone

public java.lang.Object clone()
Specified by:
clone in interface JRCloneable
Overrides:
clone in class JRBaseElement

getIgnoreWidth

public java.lang.Boolean getIgnoreWidth()
Description copied from interface: JRCrosstab
Returns the ignore width flag for the crosstab.

Specified by:
getIgnoreWidth in interface JRCrosstab
Returns:
the ignore width flag, or null is the crosstab does not specify a flag value
See Also:
JRCrosstab.setIgnoreWidth(Boolean)

setIgnoreWidth

public void setIgnoreWidth(java.lang.Boolean ignoreWidth)
Description copied from interface: JRCrosstab
Set the ignore width crosstab flag.

This flag determines whether the crosstab will break at the width set for the crosstab element, or whether the crosstab is to expand over this width (and over the page width as well).

If this flag is set to true, the crosstab will expand towards the right (or towards the left if the crosstab direction is RTL) as long as it needs to. This would result in crosstab cells being rendered over the page boundary; such elements will be exported by certain grid-based exporters such as the HTML or XLS ones, but will not be visible in export formats that observe the page width, such as the PDF exporter.

The default value of this flag is given by the JRCrosstab.PROPERTY_IGNORE_WIDTH property and the JRParameter.IS_IGNORE_PAGINATION parameter.

Specified by:
setIgnoreWidth in interface JRCrosstab
Parameters:
ignoreWidth - whether the element width is to be ignored by the crosstab, or null if the default setting is to be used
See Also:
JRCrosstab.PROPERTY_IGNORE_WIDTH

setIgnoreWidth

public void setIgnoreWidth(boolean ignoreWidth)
Description copied from interface: JRCrosstab
Set the ignore width crosstab flag.

Specified by:
setIgnoreWidth in interface JRCrosstab
See Also:
JRCrosstab.setIgnoreWidth(Boolean)

getDefaultLineColor

public java.awt.Color getDefaultLineColor()
Specified by:
getDefaultLineColor in interface JRBoxContainer

getLineBox

public JRLineBox getLineBox()
Specified by:
getLineBox in interface JRBoxContainer


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com