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 -
Method Summary
Modifier and TypeMethodDescriptionprotected final SizeSpecfinal SizeSpecGet the prepared size of the object.final SizeSpecprotected SizeSpecgetRenderSize(SizeSpec aPreparedSize) Overwrite this method to adopt prepared sizes (e.g. for min or max size) to get the render size.protected final voidThrow an exception, if this object was not yet prepared.protected final voidThrow an exception, if this object is already prepared.final voidINTERNAL method.protected final voidINTERNAL method.protected final IMPLTYPEinternalMarkAsPrepared(SizeSpec aPreparedSize) INTERNAL method.final booleanprotected abstract voidPL 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 final voidfinal SizeSpecprepare(PreparationContext aCtx) Prepare this element once for rendering.final voidrender(PageRenderContext aCtx) Second step: perform.setBasicDataFrom(IMPLTYPE aSource) For copying stuff internally.toString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor) Visit this object and all descendantsMethods inherited from class com.helger.pdflayout.base.AbstractPLObject
getDebugID, getID, onAfterSetID, 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.IPLHasOutline
getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSumMethods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, getDebugID, hasID, isVertSplittableMethods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
beforeRender, getPreparedHeight, getPreparedWidth, getRenderHeight, getRenderWidth
-
Constructor Details
-
AbstractPLRenderableObject
public AbstractPLRenderableObject()
-
-
Method Details
-
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
- 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
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:
-
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:
-
onPrepare
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
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
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:
-
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
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
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:
-
toString
- Overrides:
toStringin classAbstractPLObject<IMPLTYPE extends AbstractPLRenderableObject<IMPLTYPE>>
-