Package com.helger.pdflayout.base
Class AbstractPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>
- java.lang.Object
-
- com.helger.pdflayout.base.AbstractPLObject<IMPLTYPE>
-
- com.helger.pdflayout.base.AbstractPLRenderableObject<IMPLTYPE>
-
- Type Parameters:
IMPLTYPE- The implementation type of this class.
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IPLHasOutline,IPLObject<IMPLTYPE>,IPLRenderableObject<IMPLTYPE>,IPLVisitable
- Direct Known Subclasses:
AbstractPLElement,AbstractPLHBox,AbstractPLVBox,PLBulletPointList,PLPageBreak,PLSpacerX,PLSpacerY,PLTable
public abstract class AbstractPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>> extends AbstractPLObject<IMPLTYPE> implements IPLRenderableObject<IMPLTYPE>
Abstract layout object that supports rendering.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description AbstractPLRenderableObject()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected SizeSpecgetPrepareAvailableSize()SizeSpecgetPreparedSize()Get the prepared size of the object.SizeSpecgetRenderSize()protected SizeSpecgetRenderSize(SizeSpec aPreparedSize)Overwrite this method to adopt prepared sizes (e.g. for min or max size) to get the render size.protected voidinternalCheckAlreadyPrepared()Throw an exception, if this object was not yet prepared.protected voidinternalCheckNotPrepared()Throw an exception, if this object is already prepared.voidinternalMarkAsNotPrepared()INTERNAL method.protected voidinternalMarkAsNotPreparedDontPropagate()INTERNAL method.protected IMPLTYPEinternalMarkAsPrepared(SizeSpec aPreparedSize)INTERNAL method.booleanisPrepared()protected abstract voidonMarkAsNotPrepared()PL objects need to overwrite this method to reset their preparation state.protected abstract SizeSpeconPrepare(PreparationContext aCtx)The abstract method that must be implemented by all subclasses.protected abstract voidonRender(PageRenderContext aCtx)Abstract method to be implemented by subclasses.protected voidonRenderSizeChange()SizeSpecprepare(PreparationContext aCtx)Prepare this element once for rendering.voidrender(PageRenderContext aCtx)Second step: perform.IMPLTYPEsetBasicDataFrom(IMPLTYPE aSource)For copying stuff internally.StringtoString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor)Visit this object and all descendants-
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, isVertSplittable
-
Methods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
beforeRender, getPreparedHeight, getPreparedWidth, getRenderHeight, getRenderWidth
-
-
-
-
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 AbstractPLRenderableObject<IMPLTYPE>>- Overrides:
setBasicDataFromin classAbstractPLObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
visit
@OverrideOnDemand @OverridingMethodsMustInvokeSuper @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- Parameters:
aVisitor- The visitor to use. May not benull.- Returns:
EChange.CHANGEDif something changed internally.- Throws:
IOException- on PDFBox error
-
internalCheckAlreadyPrepared
protected final void internalCheckAlreadyPrepared()
Throw an exception, if this object was not yet prepared.- Throws:
IllegalStateException- if not yet prepared
-
internalCheckNotPrepared
protected final void internalCheckNotPrepared()
Throw an exception, if this object is already prepared.- Throws:
IllegalStateException- if already prepared
-
isPrepared
public final boolean isPrepared()
- Specified by:
isPreparedin interfaceIPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>- Returns:
trueif this object was already prepared,falseotherwise.
-
getPrepareAvailableSize
@Nullable protected final SizeSpec getPrepareAvailableSize()
- Returns:
- The size used to perform the preparation. Is
nullif this object was not yet prepared. This is required, if a text needs to be prepared more than once (e.g. text with placeholders).
-
getPreparedSize
@Nullable public final SizeSpec getPreparedSize()
Description copied from interface:IPLRenderableObjectGet the prepared size of the object. This is the minimum space the content of the object needs given the available size constraints. This does NOT consider min- and max-size.- Specified by:
getPreparedSizein interfaceIPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>- Returns:
- The prepared size or
nullif this object was not yet prepared. - See Also:
isPrepared()
-
getRenderSize
@Nullable public final SizeSpec getRenderSize()
- Specified by:
getRenderSizein interfaceIPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>- Returns:
- The render size or
nullif this object was not yet prepared. The render size includes the min/max size. - See Also:
IPLRenderableObject.isPrepared()
-
onPrepare
@Nonnull protected abstract SizeSpec onPrepare(@Nonnull PreparationContext aCtx)
The abstract method that must be implemented by all subclasses. It is ensured that this method is called only once per instance!- Parameters:
aCtx- Preparation context. Nevernull.- Returns:
- The size of the rendered element without padding, border and
margin. May not be
null.
-
getRenderSize
@Nonnull @OverrideOnDemand protected SizeSpec getRenderSize(@Nonnull SizeSpec aPreparedSize)
Overwrite this method to adopt prepared sizes (e.g. for min or max size) to get the render size.- Parameters:
aPreparedSize- The originally prepared size.- Returns:
- The modified prepared size or the unchanged prepared size if no
changes are necessary. May not be
null.
-
onRenderSizeChange
protected final void onRenderSizeChange()
-
prepare
@Nonnull public final SizeSpec prepare(@Nonnull PreparationContext aCtx)
Description copied from interface:IPLRenderableObjectPrepare this element once for rendering.- Specified by:
preparein interfaceIPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>- Parameters:
aCtx- The preparation context- Returns:
- The net size of the rendered object without margin, border and
margin. May not be
null. - See Also:
IPLRenderableObject.render(PageRenderContext)
-
onMarkAsNotPrepared
protected abstract void onMarkAsNotPrepared()
PL objects need to overwrite this method to reset their preparation state. They also need to propagate this to their children!
-
internalMarkAsNotPreparedDontPropagate
protected final void internalMarkAsNotPreparedDontPropagate()
INTERNAL method. Do not call from outside! This resets the preparation state.
-
internalMarkAsNotPrepared
public final void internalMarkAsNotPrepared()
INTERNAL method. Do not call from outside! This resets the preparation state.
-
internalMarkAsPrepared
@Nonnull protected final IMPLTYPE internalMarkAsPrepared(@Nonnull SizeSpec aPreparedSize)
INTERNAL method. Do not call from outside!- Parameters:
aPreparedSize- The new prepared size without margin, border and padding.- Returns:
- this
-
onRender
@OverrideOnDemand protected abstract void onRender(@Nonnull PageRenderContext aCtx) throws IOException
Abstract method to be implemented by subclasses.- Parameters:
aCtx- Rendering context. Nevernull.- Throws:
IOException- In case of a PDFBox error
-
render
@Nonnegative public final void render(@Nonnull PageRenderContext aCtx) throws IOException
Description copied from interface:IPLRenderableObjectSecond step: perform. This renders the previously prepared object to the PDF content stream present in the rendering context.- Specified by:
renderin interfaceIPLRenderableObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>- Parameters:
aCtx- Rendering context- Throws:
IOException- In case of a PDFBox error- See Also:
IPLRenderableObject.prepare(PreparationContext)
-
toString
public String toString()
- Overrides:
toStringin classAbstractPLObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>
-
-