Class AbstractPLHBox<IMPLTYPE extends AbstractPLHBox<IMPLTYPE>>
- java.lang.Object
-
- com.helger.pdflayout.base.AbstractPLObject<IMPLTYPE>
-
- com.helger.pdflayout.base.AbstractPLRenderableObject<IMPLTYPE>
-
- com.helger.pdflayout.element.hbox.AbstractPLHBox<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:
PLHBox,PLTableRow
public abstract class AbstractPLHBox<IMPLTYPE extends AbstractPLHBox<IMPLTYPE>> extends AbstractPLRenderableObject<IMPLTYPE> implements IPLSplittableObject<IMPLTYPE,IMPLTYPE>
Horizontal box - groups several columns. Each column was a width with one of the supported types:- absolute - the width is explicitly specified in user units
- percentage - the width is specified in percentage of the surrounding element
- star - the width of all columns with this type is evenly spaced on the available width. So if at least one 'star' width column is available, the hbox uses the complete available width.
- auto - the width of the column is determined by the width of the content. The maximum width assigned to this column type is the same as for 'star' width columns.
- Author:
- Philip Helger
-
-
Field Summary
-
Fields inherited from interface com.helger.pdflayout.base.IPLSplittableObject
DEFAULT_VERT_SPLITTABLE
-
-
Constructor Summary
Constructors Constructor Description AbstractPLHBox()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PLHBoxColumnaddAndReturnColumn(int nIndex, IPLRenderableObject<?> aElement, WidthSpec aWidth)PLHBoxColumnaddAndReturnColumn(IPLRenderableObject<?> aElement, WidthSpec aWidth)IMPLTYPEaddColumn(int nIndex, IPLRenderableObject<?> aElement, WidthSpec aWidth)IMPLTYPEaddColumn(IPLRenderableObject<?> aElement, WidthSpec aWidth)booleancontainsAnyVertSplittableElement()voidforEachColumn(Consumer<? super PLHBoxColumn> aConsumer)voidforEachColumnByIndex(ObjIntConsumer<? super PLHBoxColumn> aConsumer)com.helger.commons.collection.impl.ICommonsList<PLHBoxColumn>getAllColumns()PLHBoxColumngetColumnAtIndex(int nIndex)intgetColumnCount()IPLRenderableObject<?>getColumnElementAtIndex(int nIndex)Iterable<PLHBoxColumn>getColumns()PLHBoxColumngetFirstColumn()IPLRenderableObject<?>getFirstColumnElement()PLHBoxColumngetLastColumn()IPLRenderableObject<?>getLastColumnElement()protected AbstractPLRenderableObject<?>internalCreateVertSplitEmptyElement(IPLRenderableObject<?> aSrcObject, float fWidth, float fHeight)Create an empty element that is to be used as a place holder for splitting.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.IMPLTYPEremoveColumn(int nIndex)IMPLTYPEsetBasicDataFrom(IMPLTYPE aSource)For copying stuff internally.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
-
-
-
-
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 AbstractPLHBox<IMPLTYPE>>- Overrides:
setBasicDataFromin classAbstractPLRenderableObject<IMPLTYPE extends AbstractPLHBox<IMPLTYPE>>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
getColumnCount
@Nonnegative public int getColumnCount()
- Returns:
- The number of columns. Always ≥ 0.
-
getAllColumns
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<PLHBoxColumn> getAllColumns()
- Returns:
- All columns. Never
null.
-
getColumns
@Nonnull @ReturnsMutableCopy public Iterable<PLHBoxColumn> getColumns()
- Returns:
- All columns. Never
null.
-
forEachColumn
public void forEachColumn(@Nonnull Consumer<? super PLHBoxColumn> aConsumer)
-
forEachColumnByIndex
public void forEachColumnByIndex(@Nonnull ObjIntConsumer<? super PLHBoxColumn> aConsumer)
-
getColumnAtIndex
@Nullable public PLHBoxColumn getColumnAtIndex(@Nonnegative int nIndex)
-
getFirstColumn
@Nullable public PLHBoxColumn getFirstColumn()
-
getLastColumn
@Nullable public PLHBoxColumn getLastColumn()
-
getColumnElementAtIndex
@Nullable public IPLRenderableObject<?> getColumnElementAtIndex(@Nonnegative int nIndex)
-
getFirstColumnElement
@Nullable public IPLRenderableObject<?> getFirstColumnElement()
-
getLastColumnElement
@Nullable public IPLRenderableObject<?> getLastColumnElement()
-
addAndReturnColumn
@Nonnull public PLHBoxColumn addAndReturnColumn(@Nonnull IPLRenderableObject<?> aElement, @Nonnull WidthSpec aWidth)
-
addColumn
@Nonnull public IMPLTYPE addColumn(@Nonnull IPLRenderableObject<?> aElement, @Nonnull WidthSpec aWidth)
-
addAndReturnColumn
@Nonnull public PLHBoxColumn addAndReturnColumn(@CheckForSigned int nIndex, @Nonnull IPLRenderableObject<?> aElement, @Nonnull WidthSpec aWidth)
-
addColumn
@Nonnull public IMPLTYPE addColumn(@CheckForSigned int nIndex, @Nonnull IPLRenderableObject<?> aElement, @Nonnull WidthSpec aWidth)
-
removeColumn
@Nonnull public IMPLTYPE removeColumn(@Nonnegative int nIndex)
-
isVertSplittable
public final boolean isVertSplittable()
- Specified by:
isVertSplittablein interfaceIPLObject<IMPLTYPE extends AbstractPLHBox<IMPLTYPE>>- Specified by:
isVertSplittablein interfaceIPLSplittableObject<IMPLTYPE extends AbstractPLHBox<IMPLTYPE>,IMPLTYPE extends AbstractPLHBox<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 AbstractPLHBox<IMPLTYPE>,IMPLTYPE extends AbstractPLHBox<IMPLTYPE>>- Parameters:
bVertSplittable-trueif this element is splittable,falseotherwise.- Returns:
- this for chaining
-
containsAnyVertSplittableElement
public boolean containsAnyVertSplittableElement()
-
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 AbstractPLHBox<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 AbstractPLHBox<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 AbstractPLHBox<IMPLTYPE>>
-
internalCreateVertSplitEmptyElement
@Nonnull protected AbstractPLRenderableObject<?> internalCreateVertSplitEmptyElement(@Nonnull IPLRenderableObject<?> aSrcObject, float fWidth, float fHeight)
Create an empty element that is to be used as a place holder for splitting. The returned object must be prepared!- Parameters:
aSrcObject- Source element of the hbox to be splitfWidth- Column widthfHeight- Column height- Returns:
- Never
null.
-
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 AbstractPLHBox<IMPLTYPE>,IMPLTYPE extends AbstractPLHBox<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 AbstractPLHBox<IMPLTYPE>>- Parameters:
aCtx- Rendering context. Nevernull.- Throws:
IOException- In case of a PDFBox error
-
toString
public String toString()
- Overrides:
toStringin classAbstractPLRenderableObject<IMPLTYPE extends AbstractPLHBox<IMPLTYPE>>
-
-