org.apache.fop.layoutmgr.table

Class GridUnit

Known Direct Subclasses:
EmptyGridUnit, PrimaryGridUnit

public class GridUnit
extends java.lang.Object

This class represents one grid unit inside a table.

Field Summary

static int
FIRST_IN_PART
Indicates that the grid unit is in the first row of the table part (header, footer, body).
static int
FIRST_IN_TABLE
Indicates that the grid unit is in the first row of the table.
static int
IN_FIRST_COLUMN
Indicates that the grid unit is in the first column.
static int
IN_LAST_COLUMN
Indicates that the grid unit is in the last column.
static int
KEEP_WITH_NEXT_PENDING
Indicates that the primary grid unit has a pending keep-with-next.
static int
KEEP_WITH_PREVIOUS_PENDING
Indicates that the primary grid unit has a pending keep-with-previous.
static int
LAST_IN_PART
Indicates that the grid unit is in the last row of the table part (header, footer, body).
static int
LAST_IN_TABLE
Indicates that the grid unit is in the last row of the table.

Constructor Summary

GridUnit(TableCell cell, TableColumn column, int startCol, int colSpanIndex)
Creates a new grid unit.
GridUnit(PrimaryGridUnit primary, TableCell cell, TableColumn column, int startCol, int colSpanIndex)
Creates a new grid unit.
GridUnit(PrimaryGridUnit primary, TableColumn column, int startCol, int colSpanIndex)
Creates a new grid unit.

Method Summary

void
assignBorderForSeparateBorderModel()
Assigns the borders from the given cell to this cell info.
GridUnit
createNextRowSpanningGridUnit()
TableBody
getBody()
CommonBorderPaddingBackground
getBorders()
TableCell
getCell()
int
getColSpanIndex()
TableColumn
getColumn()
boolean
getFlag(int which)
Returns a flag for this GridUnit.
CommonBorderPaddingBackground.BorderInfo
getOriginalBorderInfoForCell(int side)
Returns a BorderInfo instance for a side of the currently applicable cell before border resolution (i.e.
PrimaryGridUnit
getPrimary()
Returns the before-start grid unit of the cell containing this grid unit.
TableRow
getRow()
int
getRowSpanIndex()
int
getStartCol()
Table
getTable()
boolean
hasBorders()
boolean
isEmpty()
Does this grid unit belong to an empty cell?
boolean
isLastGridUnitColSpan()
boolean
isLastGridUnitRowSpan()
boolean
isPrimary()
Is this grid unit the before-start grid unit of the cell?
void
resolveBorder(GridUnit other, int side)
Resolve collapsing borders for the given cell.
void
resolveBorder(GridUnit other, int side, int resFlags)
Resolve collapsing borders for the given cell.
void
setFlag(int which, boolean value)
Sets a flag on a GridUnit.
void
setRow(TableRow row)
Sets the table-row FO, if applicable.
String
toString()

Field Details

FIRST_IN_PART

public static final int FIRST_IN_PART
Indicates that the grid unit is in the first row of the table part (header, footer, body).
Field Value:
3

FIRST_IN_TABLE

public static final int FIRST_IN_TABLE
Indicates that the grid unit is in the first row of the table.
Field Value:
2

IN_FIRST_COLUMN

public static final int IN_FIRST_COLUMN
Indicates that the grid unit is in the first column.
Field Value:
0

IN_LAST_COLUMN

public static final int IN_LAST_COLUMN
Indicates that the grid unit is in the last column.
Field Value:
1

KEEP_WITH_NEXT_PENDING

public static final int KEEP_WITH_NEXT_PENDING
Indicates that the primary grid unit has a pending keep-with-next.
Field Value:
6

KEEP_WITH_PREVIOUS_PENDING

public static final int KEEP_WITH_PREVIOUS_PENDING
Indicates that the primary grid unit has a pending keep-with-previous.
Field Value:
7

LAST_IN_PART

public static final int LAST_IN_PART
Indicates that the grid unit is in the last row of the table part (header, footer, body).
Field Value:
4

LAST_IN_TABLE

public static final int LAST_IN_TABLE
Indicates that the grid unit is in the last row of the table.
Field Value:
5

Constructor Details

GridUnit

public GridUnit(TableCell cell,
                TableColumn column,
                int startCol,
                int colSpanIndex)
Creates a new grid unit.
Parameters:
cell - table cell which occupies this grid unit
column - table column this grid unit belongs to
startCol - index of the column this grid unit belongs to
colSpanIndex - index of this grid unit in the span, in column direction

GridUnit

protected GridUnit(PrimaryGridUnit primary,
                   TableCell cell,
                   TableColumn column,
                   int startCol,
                   int colSpanIndex)
Creates a new grid unit.
Parameters:
primary - the before-start grid unit of the cell containing this grid unit
cell - table cell which occupies this grid unit
column - table column this grid unit belongs to
startCol - index of the column this grid unit belongs to
colSpanIndex - index of this grid unit in the span, in column direction

GridUnit

public GridUnit(PrimaryGridUnit primary,
                TableColumn column,
                int startCol,
                int colSpanIndex)
Creates a new grid unit.
Parameters:
primary - the before-start grid unit of the cell containing this grid unit
column - table column this grid unit belongs to
startCol - index of the column this grid unit belongs to
colSpanIndex - index of this grid unit in the span, in column direction

Method Details

assignBorderForSeparateBorderModel

public void assignBorderForSeparateBorderModel()
Assigns the borders from the given cell to this cell info. Used in case of separate border model.

createNextRowSpanningGridUnit

public GridUnit createNextRowSpanningGridUnit()
Returns:
the grid unit just below this grid unit if the cell is spanning.

getBody

public TableBody getBody()

getBorders

public CommonBorderPaddingBackground getBorders()
Returns:
the resolved normal borders for this grid unit

getCell

public TableCell getCell()

getColSpanIndex

public int getColSpanIndex()
Returns:
the index of the grid unit inside a cell in column direction

getColumn

public TableColumn getColumn()

getFlag

public boolean getFlag(int which)
Returns a flag for this GridUnit.
Parameters:
which - the requested flag
Returns:
the value of the flag

getOriginalBorderInfoForCell

public CommonBorderPaddingBackground.BorderInfo getOriginalBorderInfoForCell(int side)
Returns a BorderInfo instance for a side of the currently applicable cell before border resolution (i.e. the value from the FO). A return value of null indicates an empty cell. See CollapsingBorderModel(EyeCatching) where this method is used.
Parameters:
side - for which side to return the BorderInfo
Returns:
the requested BorderInfo instance or null if the grid unit is an empty cell

getPrimary

public PrimaryGridUnit getPrimary()
Returns the before-start grid unit of the cell containing this grid unit.
Returns:
the before-start grid unit of the cell containing this grid unit.

getRow

public TableRow getRow()

getRowSpanIndex

public int getRowSpanIndex()
Returns:
the index of the grid unit inside a cell in row direction

getStartCol

public int getStartCol()

getTable

public Table getTable()

hasBorders

public boolean hasBorders()
Returns:
true if the grid unit has any borders.

isEmpty

public boolean isEmpty()
Does this grid unit belong to an empty cell?
Returns:
true if this grid unit belongs to an empty cell

isLastGridUnitColSpan

public boolean isLastGridUnitColSpan()
Returns:
true if the grid unit is the last in column spanning direction

isLastGridUnitRowSpan

public boolean isLastGridUnitRowSpan()
Returns:
true if the grid unit is the last in row spanning direction

isPrimary

public boolean isPrimary()
Is this grid unit the before-start grid unit of the cell?
Returns:
true if this grid unit is the before-start grid unit of the cell

resolveBorder

public void resolveBorder(GridUnit other,
                          int side)
Resolve collapsing borders for the given cell. Used in case of the collapsing border model.
Parameters:
other - neighbouring grid unit if any
side - the side to resolve (one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END)

resolveBorder

public void resolveBorder(GridUnit other,
                          int side,
                          int resFlags)
Resolve collapsing borders for the given cell. Used in case of the collapsing border model.
Parameters:
other - neighbouring grid unit if any
side - the side to resolve (one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
resFlags - flags for the border resolution

setFlag

public void setFlag(int which,
                    boolean value)
Sets a flag on a GridUnit.
Parameters:
which - the flag to set
value - the new value for the flag

setRow

public void setRow(TableRow row)
Sets the table-row FO, if applicable.
Parameters:
row - the table-row FO

toString

public String toString()
See Also:
java.lang.Object.toString()

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.