Class AbstractPLVBox<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>
- java.lang.Object
-
- com.helger.pdflayout.base.AbstractPLObject<IMPLTYPE>
-
- com.helger.pdflayout.base.AbstractPLRenderableObject<IMPLTYPE>
-
- com.helger.pdflayout.element.vbox.AbstractPLVBox<IMPLTYPE>
-
- Type Parameters:
IMPLTYPE- Implementation type
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IPLHasOutline,IPLObject<IMPLTYPE>,IPLRenderableObject<IMPLTYPE>,IPLSplittableObject<IMPLTYPE,IMPLTYPE>,IPLVisitable
- Direct Known Subclasses:
PLVBox
public abstract class AbstractPLVBox<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>> extends AbstractPLRenderableObject<IMPLTYPE> implements IPLSplittableObject<IMPLTYPE,IMPLTYPE>
Vertical box - groups several rows.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_FULL_WIDTH-
Fields inherited from interface com.helger.pdflayout.base.IPLSplittableObject
DEFAULT_VERT_SPLITTABLE
-
-
Constructor Summary
Constructors Constructor Description AbstractPLVBox()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PLVBoxRowaddAndReturnRow(int nIndex, IPLRenderableObject<?> aElement, HeightSpec aHeight)Add a row to this VBox.PLVBoxRowaddAndReturnRow(IPLRenderableObject<?> aElement)Add a row to this VBox using auto height.PLVBoxRowaddAndReturnRow(IPLRenderableObject<?> aElement, HeightSpec aHeight)Add a row to this VBox.IMPLTYPEaddRow(int nIndex, IPLRenderableObject<?> aElement, HeightSpec aHeight)Add a row to this VBox.IMPLTYPEaddRow(IPLRenderableObject<?> aElement)Add a row to this VBox using auto height.IMPLTYPEaddRow(IPLRenderableObject<?> aElement, HeightSpec aHeight)Add a row to this VBox.booleancontainsAnyVertSplittableElement()voidforEachRow(Consumer<? super PLVBoxRow> aConsumer)voidforEachRowByIndex(ObjIntConsumer<? super PLVBoxRow> aConsumer)com.helger.commons.collection.impl.ICommonsList<PLVBoxRow>getAllRows()HeightSpecgetDefaultHeight()PLVBoxRowgetFirstRow()IPLRenderableObject<?>getFirstRowElement()intgetHeaderRowCount()PLVBoxRowgetLastRow()IPLRenderableObject<?>getLastRowElement()PLVBoxRowgetRowAtIndex(int nIndex)Get the row at the specified index.intgetRowCount()IPLRenderableObject<?>getRowElementAtIndex(int nIndex)Get the element in the row at the specified index.Iterable<PLVBoxRow>getRows()booleanisFullWidth()booleanisVertSplittable()protected voidonMarkAsNotPrepared()PL 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.IMPLTYPEremoveRow(int nIndex)Remove the row with the specified index.IMPLTYPEsetBasicDataFrom(IMPLTYPE aSource)For copying stuff internally.IMPLTYPEsetFullWidth(boolean bFullWidth)Set usage of full width.IMPLTYPEsetHeaderRowCount(int nHeaderRowCount)Set the number of header rows in this table.IMPLTYPEsetVertSplittable(boolean bVertSplittable)Change the vertical splitability of this object.PLSplitResultsplitElementVert(float fAvailableWidth, float fAvailableHeight)Split this element vertically into sub-elements according to the available height.StringtoString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor)Visit this object and all descendants-
Methods inherited from class com.helger.pdflayout.base.AbstractPLRenderableObject
getPrepareAvailableSize, getPreparedSize, getRenderSize, getRenderSize, internalCheckAlreadyPrepared, internalCheckNotPrepared, internalMarkAsNotPrepared, internalMarkAsNotPreparedDontPropagate, internalMarkAsPrepared, isPrepared, onRenderSizeChange, prepare, render
-
Methods inherited from class com.helger.pdflayout.base.AbstractPLObject
getDebugID, getID, onAfterSetID, setID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasOutline
getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSum
-
Methods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, getDebugID, hasID
-
Methods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
beforeRender, getPreparedHeight, getPreparedWidth, getRenderHeight, getRenderWidth
-
Methods inherited from interface com.helger.pdflayout.base.IPLSplittableObject
internalCreateNewVertSplitObject
-
-
-
-
Field Detail
-
DEFAULT_FULL_WIDTH
public static final boolean DEFAULT_FULL_WIDTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
setBasicDataFrom
@Nonnull @OverridingMethodsMustInvokeSuper public IMPLTYPE setBasicDataFrom(@Nonnull IMPLTYPE aSource)
Description copied from interface:IPLObjectFor copying stuff internally. Must always call super method- Specified by:
setBasicDataFromin interfaceIPLObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Overrides:
setBasicDataFromin classAbstractPLRenderableObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
getRowCount
@Nonnegative public int getRowCount()
- Returns:
- The number of rows. Always ≥ 0.
-
getAllRows
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<PLVBoxRow> getAllRows()
- Returns:
- All rows. Never
null.
-
forEachRowByIndex
public void forEachRowByIndex(@Nonnull ObjIntConsumer<? super PLVBoxRow> aConsumer)
-
getRowAtIndex
@Nullable public PLVBoxRow getRowAtIndex(@Nonnegative int nIndex)
Get the row at the specified index.- Parameters:
nIndex- The index to use. Should be ≥ 0.- Returns:
nullif an invalid index was provided.
-
getFirstRow
@Nullable public PLVBoxRow getFirstRow()
- Returns:
- The first row or
nullif no row is present.
-
getLastRow
@Nullable public PLVBoxRow getLastRow()
- Returns:
- The last row or
nullif no row is present.
-
getRowElementAtIndex
@Nullable public IPLRenderableObject<?> getRowElementAtIndex(@Nonnegative int nIndex)
Get the element in the row at the specified index.- Parameters:
nIndex- The index to use. Should be ≥ 0.- Returns:
nullif an invalid index was provided.
-
getFirstRowElement
@Nullable public IPLRenderableObject<?> getFirstRowElement()
- Returns:
- The element in the first row or
nullif no row is present.
-
getLastRowElement
@Nullable public IPLRenderableObject<?> getLastRowElement()
- Returns:
- The element in the last row or
nullif no row is present.
-
getDefaultHeight
@Nonnull public HeightSpec getDefaultHeight()
- Returns:
- The default height to be used for rows if none is provided. May not
be
null.
-
addAndReturnRow
@Nonnull public PLVBoxRow addAndReturnRow(@Nonnull IPLRenderableObject<?> aElement)
Add a row to this VBox using auto height.- Parameters:
aElement- The row to be added. May not benull.- Returns:
- the created row
-
addAndReturnRow
@Nonnull public final PLVBoxRow addAndReturnRow(@Nonnull IPLRenderableObject<?> aElement, @Nonnull HeightSpec aHeight)
Add a row to this VBox.- Parameters:
aElement- The row to be added. May not benull.aHeight- The height specification to use. May not benull.- Returns:
- the created row
-
addRow
@Nonnull public IMPLTYPE addRow(@Nonnull IPLRenderableObject<?> aElement)
Add a row to this VBox using auto height.- Parameters:
aElement- The row to be added. May not benull.- Returns:
- this
-
addRow
@Nonnull public final IMPLTYPE addRow(@Nonnull IPLRenderableObject<?> aElement, @Nonnull HeightSpec aHeight)
Add a row to this VBox.- Parameters:
aElement- The row to be added. May not benull.aHeight- The height specification to use. May not benull.- Returns:
- this for chaining
-
addAndReturnRow
@Nonnull public PLVBoxRow addAndReturnRow(@Nonnegative int nIndex, @Nonnull IPLRenderableObject<?> aElement, @Nonnull HeightSpec aHeight)
Add a row to this VBox.- Parameters:
nIndex- The index where the row should be added. Must be ≥ 0.aElement- The row to be added. May not benull.aHeight- The height specification to use. May not benull.- Returns:
- the created row. Never
null.
-
addRow
@Nonnull public IMPLTYPE addRow(@Nonnegative int nIndex, @Nonnull IPLRenderableObject<?> aElement, @Nonnull HeightSpec aHeight)
Add a row to this VBox.- Parameters:
nIndex- The index where the row should be added. Must be ≥ 0.aElement- The row to be added. May not benull.aHeight- The height specification to use. May not benull.- Returns:
- this for chaining
-
removeRow
@Nonnull public IMPLTYPE removeRow(@Nonnegative int nIndex)
Remove the row with the specified index.- Parameters:
nIndex- The index to be removed.- Returns:
- this for chaining
-
isVertSplittable
public final boolean isVertSplittable()
- Specified by:
isVertSplittablein interfaceIPLObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Specified by:
isVertSplittablein interfaceIPLSplittableObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>,IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Returns:
trueif this element is vertically splittable,falseotherwise. The default isIPLSplittableObject.DEFAULT_VERT_SPLITTABLE.
-
setVertSplittable
@Nonnull public final IMPLTYPE setVertSplittable(boolean bVertSplittable)
Description copied from interface:IPLSplittableObjectChange the vertical splitability of this object.- Specified by:
setVertSplittablein interfaceIPLSplittableObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>,IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Parameters:
bVertSplittable-trueif this element is splittable,falseotherwise.- Returns:
- this for chaining
-
getHeaderRowCount
@Nonnegative public final int getHeaderRowCount()
- Returns:
- The number of header rows. By default 0. Always ≥ 0.
-
setHeaderRowCount
@Nonnull public final IMPLTYPE setHeaderRowCount(@Nonnegative int nHeaderRowCount)
Set the number of header rows in this table. Header rows get repeated on every page upon rendering.- Parameters:
nHeaderRowCount- The number of header rows, to be repeated by page. Must be ≥ 0.- Returns:
- this
-
containsAnyVertSplittableElement
public boolean containsAnyVertSplittableElement()
-
isFullWidth
public final boolean isFullWidth()
- Returns:
- Should the VBox occupy the full width? The default is
DEFAULT_FULL_WIDTH.
-
setFullWidth
@Nonnull public final IMPLTYPE setFullWidth(boolean bFullWidth)
Set usage of full width.- Parameters:
bFullWidth-trueto enable full width,falseto use only what is available.- Returns:
- this for chaining
-
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<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Parameters:
aVisitor- The visitor to use. May not benull.- Returns:
EChange.CHANGEDif something changed internally.- Throws:
IOException- on PDFBox error
-
onPrepare
@OverridingMethodsMustInvokeSuper protected SizeSpec onPrepare(@Nonnull PreparationContext aCtx)
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<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- 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<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>
-
splitElementVert
@Nullable public PLSplitResult splitElementVert(float fAvailableWidth, float fAvailableHeight)
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<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>,IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- 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
protected void onRender(@Nonnull PageRenderContext aCtx) throws IOException
Description copied from class:AbstractPLRenderableObjectAbstract method to be implemented by subclasses.- Specified by:
onRenderin classAbstractPLRenderableObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>- Parameters:
aCtx- Rendering context. Nevernull.- Throws:
IOException- In case of a PDFBox error
-
toString
public String toString()
- Overrides:
toStringin classAbstractPLRenderableObject<IMPLTYPE extends AbstractPLVBox<IMPLTYPE>>
-
-