com.businessobjects.rebean.wi
Interface TableCell

All Superinterfaces:
Alertable, Decoration, Unit

public interface TableCell
extends Unit, Decoration, Alertable

Warning: This interface is no longer functional from the SAP BusinessObjects 4.0 release onwards.

The TableCell object represents a single cell in a table.


Method Summary
 double estimateMinimalHeight()
          Estimates the minimal height, in the current unit, for this cell.
 CellMatrix getCellMatrix()
          Returns the CellMatrix this cell is part of.
 int getColSpan()
          Returns the number of columns spanned by this cell.
 int getColumn()
          Returns the column in which this cell is placed in the cell matrix.
 CellContentType getContentType()
          Returns the TableCell object's content type.
 ReportExpression getExpr()
          Returns the ReportExpression displayed by this cell.
 FormatNumber getFormatNumber()
          Returns the format for values in this cell.
 double getHeight()
          Returns the height of the current TableCell.
 double getHorizontalPadding()
          Returns the cell's horizontal padding.
 java.lang.String getID()
          Returns the ID of this cell.
 ReportExpression getNestedExpr()
          Returns the ReportExpression displayed by this cell.
 double getPadding()
          Deprecated. Use TableCell.getVerticalPadding() and TableCell.getHorizontalPadding() instead.
 int getRow()
          Returns the index of the row in which this cell is placed in the cell matrix.
 int getRowSpan()
          Returns the number of rows spanned by this cell.
 java.lang.String getText()
          Returns a text representation of this cell.
 double getVerticalPadding()
          Returns the cell's vertical padding.
 double getWidth()
          Return the cell width.
 boolean hasCalculation()
          Returns true if the cell contains a calculation.
 boolean isAutoFitHeight()
          Returns true if the height of the cell depends on the content.
 boolean isAutoFitWidth()
          Returns true if this cell's width is dependent on its content.
 boolean isCustomFormula()
          Returns true if this TableCell contains a custom formula.
 void setAutoFitHeight(boolean b)
          It is set to true when the TableCell height is to be adjusted to fit its content.
 void setAutoFitWidth(boolean b)
          It is set to true when the TableCell width is to be adjusted to fit its content.
 void setColSpan(int span)
          Sets the number of columns spanned by this cell.
 void setColumnAutoFitWidth(boolean b)
          Sets or unsets the autoFitWidth property on all cells in this table that end in the same column.
 void setContentType(CellContentType t)
          Changes the TableCell object's type.
 void setExpr(ReportExpression expr)
          Changes the report expression this cell displays.
 void setFormatNumber(FormatNumber format)
          Sets the format for values in this cell.
 void setHeight(double size)
          Changes the TableCell height.
 void setHorizontalPadding(double padding)
          Changes the cell's horizontal padding.
 void setPadding(double padding)
          Changes the padding in the cell.
 void setRowAutoFitHeight(boolean b)
          Sets the autoFitHeight property to b for all table cells in the same row in the table.
 void setRowSpan(int span)
          Sets the number of rows spanned by this cell.
 void setText(java.lang.String text)
          Changes the contents of this cell to a simple text string.
 void setVerticalPadding(double padding)
          Changes the cell's vertical padding If this value is negative, the default TableFormBase.getCellPadding() value will be applied.
 void setWidth(double size)
          Changes the current width of the current TableCell.
 
Methods inherited from interface com.businessobjects.rebean.wi.Unit
getUnit, setUnit
 
Methods inherited from interface com.businessobjects.rebean.wi.Decoration
getAlignment, getAttributes, getBackgroundAlignment, getFont, setAlignment, setAttributes, setBackgroundAlignment, setFont
 
Methods inherited from interface com.businessobjects.rebean.wi.Alertable
getAlerters
 

Method Detail

getID

java.lang.String getID()
Returns the ID of this cell.

Returns:
The ID of this cell.

getCellMatrix

CellMatrix getCellMatrix()
Returns the CellMatrix this cell is part of.

Returns:
The CellMatrix this cell is part of, or null if this cell has been removed from its table.
See Also:
CellMatrix

getWidth

double getWidth()
Return the cell width.

Note : the width is returned in the the current Unit format. You can retrieve the current Unit format using Unit.getUnit().

Returns:
The width of the cell.
Throws:
ReportException - Thrown when this cell has been removed from the table.
See Also:
Unit

setWidth

void setWidth(double size)
Changes the current width of the current TableCell.

Note: Calling setWidth changes the width of all cells in the same column.

Parameters:
size - The new cell width in the current unit. You can retrieve the current Unit format using Unit.getUnit().
Throws:
java.lang.IllegalArgumentException - when size < 0
ReportException - Thrown when this cell has been removed from the table.
See Also:
Unit

getHeight

double getHeight()
Returns the height of the current TableCell. The hight is returned in the the current Unit format. You can retrieve the current Unit format using Unit.getUnit().

Returns:
the height of the cell
Throws:
ReportException - Thrown when this cell has been removed from the table.
See Also:
Unit

setHeight

void setHeight(double size)
Changes the TableCell height.

Note: Calling setHeight changes the height of all cells in the same row.

Parameters:
size - The new height in the current unit. You can retrieve the current Unit format using Unit.getUnit().
Throws:
java.lang.IllegalArgumentException - when size < 0
ReportException - Thrown when this cell has been removed from the table.

isAutoFitWidth

boolean isAutoFitWidth()
Returns true if this cell's width is dependent on its content.

Returns:
true when the width of the cell is adjusted to fit the cell's content.

setAutoFitWidth

void setAutoFitWidth(boolean b)
It is set to true when the TableCell width is to be adjusted to fit its content.

When set to true, the cell width serves as a minimal value; it will be extended if the content does not fit in.

Parameters:
b - Set to true for the cell width to be adjusted to fit content.
Since:
12.0

isAutoFitHeight

boolean isAutoFitHeight()
Returns true if the height of the cell depends on the content.

Returns:
true when the height of the cell is adjusted to fit content

setAutoFitHeight

void setAutoFitHeight(boolean b)
It is set to true when the TableCell height is to be adjusted to fit its content.

When set to true, the cell height serves as a minimal height; it will be extended if the content does not fit in.

Parameters:
b - Set to true for the cell height to be adjusted to fit content.
Since:
12.0

getHorizontalPadding

double getHorizontalPadding()
Returns the cell's horizontal padding.

Note: the default padding is 3 points, or 1/24 inch.

Returns:
The horizontal padding in the cell in the current Unit. You can retrieve the current Unit format using Unit.getUnit().
Since:
11.5

setHorizontalPadding

void setHorizontalPadding(double padding)
Changes the cell's horizontal padding.

If this value is negative, the default TableFormBase.getCellPadding() value will be applied.

Parameters:
padding - The new padding in the cell in the current Unit. You can retrieve the current Unit format using Unit.getUnit().
Since:
11.5

getVerticalPadding

double getVerticalPadding()
Returns the cell's vertical padding.

Note: the default padding is 1.5 points, or 1/48 inch.

Returns:
the vertical padding in the cell in the current Unit. You can retrieve the current Unit format using Unit.getUnit().
Since:
11.5

setVerticalPadding

void setVerticalPadding(double padding)
Changes the cell's vertical padding

If this value is negative, the default TableFormBase.getCellPadding() value will be applied.

Parameters:
padding - The new cell padding in the current Unit. You can retrieve the current Unit format using Unit.getUnit().
Since:
11.5

getPadding

double getPadding()
Deprecated. Use TableCell.getVerticalPadding() and TableCell.getHorizontalPadding() instead.

Returns the padding in the cell.

If TableCell.getVerticalPadding() returns a different value from TableCell.getHorizontalPadding(), this method will return -1. If both values are equal, this method will return that value, in the current Unit. You can retrieve the current Unit format using Unit.getUnit().

Returns:
The padding in the cell, or -1 if this cell has different values for horizontal and vertical padding.

setPadding

void setPadding(double padding)
Changes the padding in the cell. This method calls TableCell.setVerticalPadding(double) and TableCell.setHorizontalPadding(double) with the given value.

Parameters:
padding - The new padding in the cell, in the current Unit. You can retrieve the current Unit format using Unit.getUnit().
Throws:
java.lang.IllegalArgumentException - Thrown when padding < 0.
See Also:
TableCell.getPadding(), TableFormBase.setCellPadding(double)

getExpr

ReportExpression getExpr()
Returns the ReportExpression displayed by this cell.

Note: this will usually be a formula; use getNestedExpr() to return a ReportExpression from the ReportDictionary.

Returns:
the report expression this cell displays
See Also:
ReportDictionary, ReportExpression

getNestedExpr

ReportExpression getNestedExpr()
Returns the ReportExpression displayed by this cell. Unless the expression is a complex formula such as =[Revenue] / COUNT([Month]), getNestedExpr always returns the base expression displayed in the cell.

Returns:
The nested expression. Returns null if no ReportExpression is present.

setExpr

void setExpr(ReportExpression expr)
Changes the report expression this cell displays. If it is not a FormulaExpression, the expression will automatically be transformed to a formula =expr.

Note: if the expression is not in one of the table's axes, it might be added, depending on its type.

Parameters:
expr - The report expression this cell should now display. Returns null when the cell should become empty.

hasCalculation

boolean hasCalculation()
Returns true if the cell contains a calculation.

Returns:
true when the cell contains a calculation

getFormatNumber

FormatNumber getFormatNumber()
Returns the format for values in this cell.

Returns:
The format for values in this cell. Returns null for the default format.

setFormatNumber

void setFormatNumber(FormatNumber format)
Sets the format for values in this cell.

Parameters:
format - The format for values in this cell. Returns null for the default format.

getText

java.lang.String getText()
Returns a text representation of this cell.

This will return the same value as getExpr().getName() if there is an expression. If their is no expression, the text stored in this cell is returned, for example, "Sum:".

Returns:
the contents of this cell, in a String representation

setText

void setText(java.lang.String text)
Changes the contents of this cell to a simple text string.

After calling this method, getExpr() and getNestedExpr() always return null.

Parameters:
text - The text to be show in this cell, or null to display and empty cell.

getContentType

CellContentType getContentType()
Returns the TableCell object's content type.

Possible types are:

Returns:
a CellContentType object
Since:
11.5
See Also:
CellContentType

setContentType

void setContentType(CellContentType t)
Changes the TableCell object's type.

Parameters:
CellContentType -
Since:
11.5
See Also:
CellContentType

isCustomFormula

boolean isCustomFormula()
Returns true if this TableCell contains a custom formula.

A formula is custom when it has been set in a TableCell using TableCell.setExpr(ReportExpression).

Whether a formula is custom or not does not depend on the formula itself, but also on its position in a block. If, at the place in which the block is positioned, the formula is not standard, it is a custom formula. For example, in a vertical table, a header cell with the formula =NameOf([Country]) will be a custom formula if the body cell in the same column is not =[Country].

Returns:
true if the expression in this cell is a custom formula, for this particular cell
Throws:
ReportException - Thrown when this cell has been removed from the table.
Since:
11.5
See Also:
ReportCell.isCustomFormula(), GraphAxisProperties.isCustomFormula(int)

getColSpan

int getColSpan()
Returns the number of columns spanned by this cell.

Returns:
The number of columns spanned by this cell.
Since:
11.5

setColSpan

void setColSpan(int span)
Sets the number of columns spanned by this cell.

When the column span is increased, it erases the cells to its right in the table. The number of cells erased is the amount necessary to compensate for the increased column span.

A column can only be increased to span the current cell matrix; setting a span to a number greater than the number of cells in this cell matrix will result in an IllegalArgumentException.

Once the column span for a cell is increased, for all matrix positions that are covered by that cell, CellMatrix.getCell(int, int) will return the same cell. See TableCell.getRow() for more information.

If the increased span overlaps other spanning cells, those cells will be split into separate cells. That is to say, they will be given a row span and a column span of 1.

Parameters:
span - The number of columns this cell should span.
Throws:
java.lang.IllegalArgumentException - When span < 1 or getColumn() + span > getCellMatrix().getColumnCount().
Since:
11.5

getRowSpan

int getRowSpan()
Returns the number of rows spanned by this cell.

Returns:
The number of rows spanned by this cell.
Since:
11.5

setRowSpan

void setRowSpan(int span)
Sets the number of rows spanned by this cell.

When the row span is increased it erases the cells below it in the table. The number of cells erased the amount necessary to compensate for the increased span.

A row can only be increased to span the current cell matrix; setting a span to include rows that are not in this cell matrix will result in an IllegalArgumentException.

Once the row span for a cell is increased, for all matrix positions that are covered by that cell, CellMatrix.getCell(int, int) will return the same cell. See TableCell.getRow() for more information.

If the increased span overlaps other spanning cells, those cells will be split into separate cells. That is to say, they will be given a row span and a column span of 1.

Parameters:
span - The number of rows this cell should span.
Throws:
java.lang.IllegalArgumentException - When span < 1 or getColumn() + span > getCellMatrix().getColumnCount().
Since:
11.5

getRow

int getRow()
Returns the index of the row in which this cell is placed in the cell matrix.

Note: for a given row, myRow, and column, myColumn, the result from myCellMatrix.getCell(myRow, myColumn).getRow() may be different to myRow. This can occur when the cell at position (myRow, myColumn) has a row span greater than 1. This is demonstrated in the following code:

 TableCell myCell = myCellMatrix.getCell(0, 0);
 myCell.setRowSpan(2);
 //Get the cell at row 1:
 TableCell myCell2 = myCellMatrix.getCell(1, 0);
 //Note: myCell == myCell2 because of the row span of myCell
 //also: myCell.getRow() == myCell2.getRow() == 0
 

One typical use of this method is a loop to act on cells in a matrix: using the algorithm below, we are certain that each cell is processed only once, even in the case where cells span several rows and/or columns.

 final int rows = myCellMatrix.getRowCount();
 final int columns = myCellMatrix.getColumnCount();
 int colspan = 1;
 for (int row = 0; row < rows; ++row) {
    for (int column = 0; column < columns; column += colspan) {
        TableCell cell = myCellMatrix.getCell(row, column);
        colspan = cell.getColSpan();
        if (cell.getRow() == row) {
            // do something with cell
        }
    }
 }

Returns:
The index of the row in which this cell is placed in the cell matrix.
Since:
11.5

getColumn

int getColumn()
Returns the column in which this cell is placed in the cell matrix.

Returns:
The column in which this cell is placed in the cell matrix.
Since:
11.5
See Also:
TableCell.getRow()

setRowAutoFitHeight

void setRowAutoFitHeight(boolean b)
Sets the autoFitHeight property to b for all table cells in the same row in the table. Because this method scans the entire table, cells in other matrices can be impacted too.

If any of the impacted cells has TableCell.getRowSpan() > 1, that cell's autofit will be changed only if it ends in the same table row as this cell.

For example, given a table with the following structure:

    +-----+-----+-----+
    |  A  |  B  |  C  |
    +-----+     +-----+
    |  D  |     |  E  |
    +-----+-----+     |
    |  F  |  G  |     |
    +-----+-----+-----+
 
When called on cell A, cells A and C will be updated. When called on cell B, cells B and D will be updated. Likewise, cells E, F and G will always be updated together.

Parameters:
b - When true, all cells ending in the same row in the table will have their height depend on their contents. When false, all cells ending in this row will have fixed height.
Since:
12.0

setColumnAutoFitWidth

void setColumnAutoFitWidth(boolean b)
Sets or unsets the autoFitWidth property on all cells in this table that end in the same column.

Parameters:
b - When true, all cells ending in the same column in the table will have their width depend on their contents. When false, all cells ending in this column will have fixed width.
Since:
12.0
See Also:
TableCell.setRowAutoFitHeight(boolean)

estimateMinimalHeight

double estimateMinimalHeight()
Estimates the minimal height, in the current unit, for this cell. This height can later be applied using TableCell.setHeight(double).

This method will check all table cells ending in the same row, so that the height of tose cells would at least allow one line of text in the current font size to fit.

For example, given a table with the following structure:

    +-----+-----+-----+
    |  A  |  B  |  C  |
    +-----+     +-----+
    |  D  |     |  E  |
    +-----+-----+     |
    |  F  |  G  |     |
    +-----+-----+-----+
 
When called on cell A, the contents of cells A and C will be taken into account, but the height of cell B will also be impacted if the returned minimal height is applied to cell A.
    double minHeightA = cellA.estimateMinimalHeight();
    // Cells A and C are checked for the above calculation.

    // If cellA.getHeight() > minHeightA, the next line will decrease
    // B's height too.
    cellA.setHeight(minHeightA);

    // If B's font size is very big in comparison to A and C, it could
    // now happen that cellB.getHeight() < cellB.estimateMinimalHeight().
 
When called on cell B, cells B and D will be taken into account, but E's height will also be impacted if the returned height is applied to B. Likewise, cells E, F and G will always be checked together.

A typical use of this method is to implement some standard behavior for applying auto fit height to a row of cells.

 private void onDoubleClick(MyEvent e) {
     if (e.isBottomOfCell()) {
         TableCell cell = e.getCell();
         cell.setRowAutoFitHeight(true);
         // apply some minimal height
         cell.setHeight(cell.estimateMinimalHeight());
     }
 }
 
Calling this method is particularly useful when an entire row contains empty cells; this will ensure the empty row will at least have some minimal height.

Returns:
The minimal height for this cell's row, so that all cells ending in the same row might be large enough to fit their contents.
Since:
12.0
See Also:
TableCell.setRowAutoFitHeight(boolean), TableCell.getVerticalPadding(), TableCell.getRowSpan(), Decoration.getFont(), Font.getSize(), TableFormBase.getCellSpacing()