net.sf.jasperreports.engine.fill
Class JRFillCrosstab

java.lang.Object
  extended by net.sf.jasperreports.engine.fill.JRFillElement
      extended by net.sf.jasperreports.engine.fill.JRFillCrosstab
All Implemented Interfaces:
java.lang.Cloneable, JRCrosstab, JRFillCloneable, JRChild, JRCloneable, JRCommonElement, JRElement, JRPropertiesHolder, JRStyleContainer, JRStyleSetter, JRVisitable

public class JRFillCrosstab
extends JRFillElement
implements JRCrosstab

Fill-time implementation of a crosstab.

Version:
$Id: JRFillCrosstab.java 2006 2007-12-05 14:28:33Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
protected  class JRFillCrosstab.CrosstabFiller
          Crosstab filler class.
 class JRFillCrosstab.JRFillCrosstabDataset
          Fill-time crosstab input dataset implementation.
 
Field Summary
protected  BucketingService bucketingService
           
protected  CrosstabCell[][] cellData
           
protected  JRFillCrosstabColumnGroup[] columnGroups
           
protected  java.util.Map columnGroupsMap
           
protected  HeaderCell[][] columnHeadersData
           
protected  JRFillCrosstabCell[][] crossCells
           
protected  JRCrosstabExpressionEvaluator crosstabEvaluator
           
protected  JRFillCrosstab.JRFillCrosstabDataset dataset
           
protected  MeasureDefinition.MeasureValue[] grandTotals
           
protected  boolean hasData
           
protected  JRFillCellContents headerCell
           
protected  JRFillCrosstabMeasure[] measures
           
protected  JRFillCrosstabParameter[] parameters
           
protected  java.util.Map parametersMap
           
protected  JRCrosstab parentCrosstab
           
protected  boolean[][] retrieveTotal
           
protected  JRFillCrosstabRowGroup[] rowGroups
           
protected  java.util.Map rowGroupsMap
           
protected  HeaderCell[][] rowHeadersData
           
protected  JRFillVariable[][][] totalVariables
           
protected  JRFillVariable[] variables
           
protected  java.util.Map variablesMap
           
protected  JRFillCellContents whenNoDataCell
           
 
Fields inherited from class net.sf.jasperreports.engine.fill.JRFillElement
band, conditionalStylesContainer, currentEvaluation, defaultStyleProvider, delayedEvaluationsMap, elementGroup, expressionEvaluator, filler, initStyle, parent, printWhenGroupChanges, templates
 
Fields inherited from interface net.sf.jasperreports.crosstabs.JRCrosstab
DEFAULT_COLUMN_BREAK_OFFSET, RUN_DIRECTION_LTR, RUN_DIRECTION_RTL, VARIABLE_COLUMN_COUNT, VARIABLE_ROW_COUNT
 
Fields inherited from interface net.sf.jasperreports.engine.JRElement
MODE_OPAQUE, MODE_TRANSPARENT, POSITION_TYPE_FIX_RELATIVE_TO_BOTTOM, POSITION_TYPE_FIX_RELATIVE_TO_TOP, POSITION_TYPE_FLOAT, STRETCH_TYPE_NO_STRETCH, STRETCH_TYPE_RELATIVE_TO_BAND_HEIGHT, STRETCH_TYPE_RELATIVE_TO_TALLEST_OBJECT
 
Constructor Summary
JRFillCrosstab(JRBaseFiller filler, JRCrosstab crosstab, JRFillObjectFactory factory)
           
 
Method Summary
 void collectExpressions(JRExpressionCollector collector)
           
 JRFillCloneable createClone(JRFillCloneFactory factory)
          Creates a working clone of itself.
protected  void evaluate(byte evaluation)
           
protected  JRPrintElement fill()
           
 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.
 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.
protected  JRTemplateRectangle getJRTemplateRectangle()
           
 JRCrosstabMeasure[] getMeasures()
          Returns the crosstab measures.
 byte getMode()
          Returns the element transparency mode.
 JRCrosstabParameter[] getParameters()
          Returns the crosstab parameters.
 JRExpression getParametersMapExpression()
          Returns the parameters map expression.
protected  java.util.List getPrintElements()
           
 JRCrosstabRowGroup[] getRowGroups()
          Returns the row groups of the crosstab.
 byte getRunDirection()
          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.
protected  void initBucketingService()
           
protected  void initEvaluator(byte evaluation)
           
 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.
protected  void loadEvaluator(JasperReport jasperReport)
           
protected  void mirrorPrintElements(java.util.List printElements)
           
protected  boolean prepare(int availableStretchHeight, boolean isOverflow)
           
protected  void reset()
           
protected  void resolveElement(JRPrintElement element, byte evaluation)
          Resolves an element.
protected  void rewind()
           
 void setRunDirection(byte direction)
          Sets the run direction of the crosstab.
 void visit(JRVisitor visitor)
           
 
Methods inherited from class net.sf.jasperreports.engine.fill.JRFillElement
addDependantElement, clone, clone, collectDelayedEvaluations, collectDelayedEvaluations, delayedEvaluate, evaluateExpression, evaluatePrintWhenExpression, getBackcolor, getBand, getBandBottomY, getDefaultStyleProvider, getDependantElements, getElementGroup, getEvaluationTime, getField, getForecolor, getGroupElements, getHeight, getKey, getOwnBackcolor, getOwnForecolor, getOwnMode, getParentProperties, getPositionType, getPrintWhenExpression, getPrintWhenGroupChanges, getPropertiesMap, getRelativeY, getStretchHeight, getStretchType, getStyle, getStyleNameReference, getTemplate, getVariable, getWidth, getX, getY, hasProperties, initDelayedEvaluationPrint, initDelayedEvaluations, isAlreadyPrinted, isAutoEvaluateNow, isEvaluateAuto, isEvaluateNow, isPrintInFirstWholeBand, isPrintRepeatedValues, isPrintWhenDetailOverflows, isPrintWhenExpressionNull, isPrintWhenTrue, isRemoveLineWhenBlank, isReprinted, isToPrint, isValueRepeating, moveDependantElements, registerTemplate, resolveElement, setAlreadyPrinted, setBackcolor, setBand, setBandBottomY, setConditionalStylesContainer, setCurrentEvaluation, setForecolor, setHeight, setMode, setMode, setPositionType, setPrintInFirstWholeBand, setPrintRepeatedValues, setPrintWhenDetailOverflows, setPrintWhenExpressionNull, setPrintWhenTrue, setRelativeY, setRemoveLineWhenBlank, setReprinted, setShrinkable, setStretchHeight, setStretchType, setStyle, setStyleNameReference, setToPrint, setValueRepeating, setWidth, setX, setY, stretchElement, stretchHeightFinal
 
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, getHeight, getKey, getPositionType, getPrintWhenExpression, getPrintWhenGroupChanges, getStretchType, getWidth, getX, getY, isPrintInFirstWholeBand, isPrintRepeatedValues, isPrintWhenDetailOverflows, isRemoveLineWhenBlank, setBackcolor, setForecolor, setMode, setMode, 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.JRCloneable
clone
 
Methods inherited from interface net.sf.jasperreports.engine.JRCommonElement
getBackcolor, getForecolor, getOwnBackcolor, getOwnForecolor, getOwnMode
 
Methods inherited from interface net.sf.jasperreports.engine.JRStyleContainer
getDefaultStyleProvider, getStyle, getStyleNameReference
 
Methods inherited from interface net.sf.jasperreports.engine.JRPropertiesHolder
getParentProperties, getPropertiesMap, hasProperties
 

Field Detail

parentCrosstab

protected final JRCrosstab parentCrosstab

dataset

protected JRFillCrosstab.JRFillCrosstabDataset dataset

rowGroups

protected JRFillCrosstabRowGroup[] rowGroups

rowGroupsMap

protected java.util.Map rowGroupsMap

columnGroups

protected JRFillCrosstabColumnGroup[] columnGroups

columnGroupsMap

protected java.util.Map columnGroupsMap

measures

protected JRFillCrosstabMeasure[] measures

bucketingService

protected BucketingService bucketingService

variables

protected JRFillVariable[] variables

variablesMap

protected java.util.Map variablesMap

totalVariables

protected JRFillVariable[][][] totalVariables

retrieveTotal

protected boolean[][] retrieveTotal

parameters

protected JRFillCrosstabParameter[] parameters

parametersMap

protected java.util.Map parametersMap

crosstabEvaluator

protected JRCrosstabExpressionEvaluator crosstabEvaluator

crossCells

protected JRFillCrosstabCell[][] crossCells

headerCell

protected JRFillCellContents headerCell

whenNoDataCell

protected JRFillCellContents whenNoDataCell

hasData

protected boolean hasData

columnHeadersData

protected HeaderCell[][] columnHeadersData

rowHeadersData

protected HeaderCell[][] rowHeadersData

cellData

protected CrosstabCell[][] cellData

grandTotals

protected MeasureDefinition.MeasureValue[] grandTotals
Constructor Detail

JRFillCrosstab

public JRFillCrosstab(JRBaseFiller filler,
                      JRCrosstab crosstab,
                      JRFillObjectFactory factory)
Method Detail

getMode

public byte getMode()
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:
getMode in interface JRCommonElement
Overrides:
getMode in class JRFillElement
Returns:
MODE_OPAQUE or MODE_TRANSPARENT

loadEvaluator

protected void loadEvaluator(JasperReport jasperReport)

reset

protected void reset()
Overrides:
reset in class JRFillElement

evaluate

protected void evaluate(byte evaluation)
                 throws JRException
Specified by:
evaluate in class JRFillElement
Throws:
JRException

initEvaluator

protected void initEvaluator(byte evaluation)
                      throws JRException
Throws:
JRException

initBucketingService

protected void initBucketingService()

prepare

protected boolean prepare(int availableStretchHeight,
                          boolean isOverflow)
                   throws JRException
Overrides:
prepare in class JRFillElement
Throws:
JRException

fill

protected JRPrintElement fill()
Specified by:
fill in class JRFillElement

getJRTemplateRectangle

protected JRTemplateRectangle getJRTemplateRectangle()

rewind

protected void rewind()
Specified by:
rewind in class JRFillElement

getPrintElements

protected java.util.List getPrintElements()

mirrorPrintElements

protected void mirrorPrintElements(java.util.List printElements)

resolveElement

protected void resolveElement(JRPrintElement element,
                              byte evaluation)
Description copied from class: JRFillElement
Resolves an element.

Specified by:
resolveElement in class JRFillElement
Parameters:
element - the element
evaluation - the evaluation type

collectExpressions

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

visit

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

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

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

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

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

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

createClone

public JRFillCloneable createClone(JRFillCloneFactory factory)
Description copied from interface: JRFillCloneable
Creates a working clone of itself.

Specified by:
createClone in interface JRFillCloneable
Parameters:
factory - the clone factory to use while creating the clone
Returns:
a working clone of itself

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

getRunDirection

public byte getRunDirection()
Description copied from interface: JRCrosstab
Retrieves the run direction of this crosstab.

Specified by:
getRunDirection in interface JRCrosstab
Returns:
the run direction of this crosstab
See Also:
JRCrosstab.setRunDirection(byte)

setRunDirection

public void setRunDirection(byte direction)
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:
direction - one of RUN_DIRECTION_LTR and RUN_DIRECTION_RTL


© 2001-2006 JasperSoft Corporation www.jaspersoft.com