Class PLTable
java.lang.Object
com.helger.pdflayout.base.AbstractPLObject<IMPLTYPE>
com.helger.pdflayout.base.AbstractPLRenderableObject<PLTable>
com.helger.pdflayout.element.table.PLTable
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.commons.traits.IGenericImplTrait<PLTable>,IPLHasMargin<PLTable>,IPLHasOutline,IPLObject<PLTable>,IPLRenderableObject<PLTable>,IPLSplittableObject<PLTable,,PLTable> IPLVisitable
public class PLTable
extends AbstractPLRenderableObject<PLTable>
implements IPLSplittableObject<PLTable,PLTable>, IPLHasMargin<PLTable>
A special table with a repeating header
- Author:
- Philip Helger
-
Field Summary
Fields inherited from interface com.helger.pdflayout.base.IPLHasMargin
DEFAULT_MARGINFields inherited from interface com.helger.pdflayout.base.IPLSplittableObject
DEFAULT_VERT_SPLITTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAndReturnRow(PLTableCell... aCells) addAndReturnRow(Iterable<? extends PLTableCell> aCells) Add a new table row with auto height.addAndReturnRow(Iterable<? extends PLTableCell> aCells, HeightSpec aHeight) Add a new table row.addRow()Deprecated.addRow(PLTableCell... aCells) Add a new table row with auto height.addRow(PLTableRow aRow) addRow(PLTableRow aRow, HeightSpec aHeight) addRow(Iterable<? extends PLTableCell> aCells) Add a new table row with auto height.addRow(Iterable<? extends PLTableCell> aCells, HeightSpec aHeight) Add a new table row.static PLTablecreateWithEvenlySizedColumns(int nColumnCount) Create a new table with evenly sized columns.static PLTablecreateWithPercentage(float... aPercentages) Create a new table with the specified percentages.voidforEachCell(Consumer<? super PLTableCell> aConsumer) voidforEachRow(int nStartRowIncl, int nEndRowIncl, Consumer<? super PLTableRow> aConsumer) voidforEachRow(int nStartRowIncl, int nEndRowIncl, ObjIntConsumer<? super PLTableRow> aConsumer) voidforEachRow(Consumer<? super PLTableRow> aConsumer) voidforEachRowByIndex(ObjIntConsumer<? super PLTableRow> aConsumer) com.helger.commons.collection.impl.ICommonsList<WidthSpec>getCellAtIndex(int nRowIndex, int nColIndex) intintfinal MarginSpecgetRowAtIndex(int nIndex) intCreate a new object of the same type as this object.final booleanprotected voidCallback invoked after an ID change.protected voidPL objects need to overwrite this method to reset their preparation state.protected SizeSpeconPrepare(PreparationContext aCtx) The abstract method that must be implemented by all subclasses.protected voidonRender(PageRenderContext aCtx) Abstract method to be implemented by subclasses.setBasicDataFrom(PLTable aSource) For copying stuff internally.setHeaderRowCount(int nHeaderRowCount) final PLTablesetMargin(MarginSpec aMargin) Set the margin values.final PLTablesetVertSplittable(boolean bVertSplittable) Change the vertical splitability of this object.splitElementVert(float fAvailableWidth, float fAvailableHeight) Split this element vertically into sub-elements according to the available height.toString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor) Visit this object and all descendantsMethods inherited from class com.helger.pdflayout.base.AbstractPLRenderableObject
getPrepareAvailableSize, getPreparedSize, getRenderSize, getRenderSize, internalCheckAlreadyPrepared, internalCheckNotPrepared, internalMarkAsNotPrepared, internalMarkAsNotPreparedDontPropagate, internalMarkAsPrepared, isPrepared, onRenderSizeChange, prepare, renderMethods inherited from class com.helger.pdflayout.base.AbstractPLObject
getDebugID, getID, setIDMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsTMethods inherited from interface com.helger.commons.id.IHasID
getIDMethods inherited from interface com.helger.pdflayout.base.IPLHasMargin
addMarginBottom, addMarginLeft, addMarginRight, addMarginTop, addMarginX, addMarginY, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMarginXSum, getMarginYSum, getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSum, setMargin, setMargin, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMarginX, setMarginYMethods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, getDebugID, hasIDMethods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
beforeRender, getPreparedHeight, getPreparedWidth, getRenderHeight, getRenderWidth
-
Constructor Details
-
PLTable
@Deprecated @DevelopersNote("This ctor is only present to indicate if the varargs ctor would be used without parameters") public PLTable()Deprecated.Don't use that constructor. UsePLTable(Iterable)orPLTable(WidthSpec...)!!! -
PLTable
- Parameters:
aWidths- Must all be of the same type! "auto" width is not allowed - only "star" may be used.
-
PLTable
- Parameters:
aWidths- Must all be of the same type! "auto" width is not allowed - only "star" may be used.
-
-
Method Details
-
onAfterSetID
Description copied from class:AbstractPLObjectCallback invoked after an ID change. Overwrite this method to do local actions (if needed)- Overrides:
onAfterSetIDin classAbstractPLObject<PLTable>
-
setBasicDataFrom
@Nonnull @OverridingMethodsMustInvokeSuper public PLTable setBasicDataFrom(@Nonnull PLTable aSource) Description copied from interface:IPLObjectFor copying stuff internally. Must always call super method- Specified by:
setBasicDataFromin interfaceIPLObject<PLTable>- Overrides:
setBasicDataFromin classAbstractPLRenderableObject<PLTable>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
getMargin
- Specified by:
getMarginin interfaceIPLHasMargin<PLTable>- Returns:
- The current margin. Never
null.
-
setMargin
Description copied from interface:IPLHasMarginSet the margin values.- Specified by:
setMarginin interfaceIPLHasMargin<PLTable>- Parameters:
aMargin- Margin to use. May not benull.- Returns:
- this
-
getAllWidths
@Nonnull @Nonempty @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<WidthSpec> getAllWidths()- Returns:
- A copy of the list with all widths as specified in the constructor.
Neither
nullnor empty.
-
getColumnCount
- Returns:
- The number of columns in the table. Always ≥ 0.
-
setHeaderRowCount
-
getHeaderRowCount
-
addAndReturnRow
-
addAndReturnRow
Add a new table row with auto height. All contained elements are added with the specified width in the constructor.nullelements are represented as empty cells.- Parameters:
aCells- The cells to add. May not benull.- Returns:
- the added table row and never
null.
-
addAndReturnRow
@Nonnull public PLTableRow addAndReturnRow(@Nonnull Iterable<? extends PLTableCell> aCells, @Nonnull HeightSpec aHeight) Add a new table row. All contained elements are added with the specified width in the constructor.nullelements are represented as empty cells.- Parameters:
aCells- The cells to add. May not benullbut may containnullvalues.aHeight- Row height to be used. May not benull.- Returns:
- the added table row and never
null.
-
addRow
-
addRow
-
addRow
Deprecated.Don't call this.- Returns:
- this for chaining
-
addRow
Add a new table row with auto height. All contained elements are added with the specified width in the constructor.nullelements are represented as empty cells.- Parameters:
aCells- The cells to add. May not benull.- Returns:
- this
-
addRow
Add a new table row with auto height. All contained elements are added with the specified width in the constructor.nullelements are represented as empty cells.- Parameters:
aCells- The cells to add. May not benull.- Returns:
- this
-
addRow
@Nonnull public PLTable addRow(@Nonnull Iterable<? extends PLTableCell> aCells, @Nonnull HeightSpec aHeight) Add a new table row. All contained elements are added with the specified width in the constructor.nullelements are represented as empty cells.- Parameters:
aCells- The cells to add. May not benull.aHeight- Row height to be used.- Returns:
- this
-
forEachRow
-
forEachRowByIndex
-
forEachRow
public void forEachRow(int nStartRowIncl, int nEndRowIncl, @Nonnull Consumer<? super PLTableRow> aConsumer) -
forEachRow
public void forEachRow(int nStartRowIncl, int nEndRowIncl, @Nonnull ObjIntConsumer<? super PLTableRow> aConsumer) -
getRowCount
-
forEachCell
-
getRowAtIndex
-
getCellAtIndex
-
visit
@Nonnull public com.helger.commons.state.EChange visit(@Nonnull IPLVisitor aVisitor) throws IOException Description copied from interface:IPLVisitableVisit this object and all descendants- Specified by:
visitin interfaceIPLVisitable- Overrides:
visitin classAbstractPLRenderableObject<PLTable>- Parameters:
aVisitor- The visitor to use. May not benull.- Returns:
EChange.CHANGEDif something changed internally.- Throws:
IOException- on PDFBox error
-
onPrepare
Description copied from class:AbstractPLRenderableObjectThe abstract method that must be implemented by all subclasses. It is ensured that this method is called only once per instance!- Specified by:
onPreparein classAbstractPLRenderableObject<PLTable>- Parameters:
aCtx- Preparation context. Nevernull.- Returns:
- The size of the rendered element without padding, border and
margin. May not be
null.
-
onMarkAsNotPrepared
protected void onMarkAsNotPrepared()Description copied from class:AbstractPLRenderableObjectPL objects need to overwrite this method to reset their preparation state. They also need to propagate this to their children!- Specified by:
onMarkAsNotPreparedin classAbstractPLRenderableObject<PLTable>
-
isVertSplittable
public final boolean isVertSplittable()- Specified by:
isVertSplittablein interfaceIPLObject<PLTable>- Specified by:
isVertSplittablein interfaceIPLSplittableObject<PLTable,PLTable> - Returns:
trueif this element is vertically splittable,falseotherwise. The default isIPLSplittableObject.DEFAULT_VERT_SPLITTABLE.
-
setVertSplittable
Description copied from interface:IPLSplittableObjectChange the vertical splitability of this object.- Specified by:
setVertSplittablein interfaceIPLSplittableObject<PLTable,PLTable> - Parameters:
bVertSplittable-trueif this element is splittable,falseotherwise.- Returns:
- this for chaining
-
internalCreateNewVertSplitObject
Description copied from interface:IPLSplittableObjectCreate a new object of the same type as this object.- Specified by:
internalCreateNewVertSplitObjectin interfaceIPLSplittableObject<PLTable,PLTable> - Parameters:
aBase- The source object to copy data from.- Returns:
- Never
null.
-
splitElementVert
Description copied from interface:IPLSplittableObjectSplit this element vertically into sub-elements according to the available height. Splitting is always done after preparation and must return prepared objects!- Specified by:
splitElementVertin interfaceIPLSplittableObject<PLTable,PLTable> - Parameters:
fAvailableWidth- The available width without outline of the element.fAvailableHeight- The available height without outline of this element. Must be ≥ 0.- Returns:
nullif splitting makes no sense.
-
onRender
Description copied from class:AbstractPLRenderableObjectAbstract method to be implemented by subclasses.- Specified by:
onRenderin classAbstractPLRenderableObject<PLTable>- Parameters:
aCtx- Rendering context. Nevernull.- Throws:
IOException- In case of a PDFBox error
-
toString
- Overrides:
toStringin classAbstractPLRenderableObject<PLTable>
-
createWithPercentage
@Nonnull @ReturnsMutableCopy public static PLTable createWithPercentage(@Nonnull @Nonempty float... aPercentages) Create a new table with the specified percentages.- Parameters:
aPercentages- The array to use. The sum of all percentages should be ≤ 100. May neither benullnor empty.- Returns:
- The created
PLTableand nevernull.
-
createWithEvenlySizedColumns
@Nonnull @ReturnsMutableCopy public static PLTable createWithEvenlySizedColumns(@Nonnegative int nColumnCount) Create a new table with evenly sized columns.- Parameters:
nColumnCount- The number of columns to use. Must be > 0.- Returns:
- The created
PLTableand nevernull.
-