Package com.helger.pdflayout.element.box
Class AbstractPLBox<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>
- java.lang.Object
-
- com.helger.pdflayout.base.AbstractPLObject<IMPLTYPE>
-
- com.helger.pdflayout.base.AbstractPLRenderableObject<IMPLTYPE>
-
- com.helger.pdflayout.base.AbstractPLElement<IMPLTYPE>
-
- com.helger.pdflayout.base.AbstractPLBlockElement<IMPLTYPE>
-
- com.helger.pdflayout.element.box.AbstractPLBox<IMPLTYPE>
-
- Type Parameters:
IMPLTYPE- Implementation type
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IPLBlockElement<IMPLTYPE>,IPLElement<IMPLTYPE>,IPLHasBorder<IMPLTYPE>,IPLHasFillColor<IMPLTYPE>,IPLHasHorizontalAlignment<IMPLTYPE>,IPLHasMargin<IMPLTYPE>,IPLHasMarginBorderPadding<IMPLTYPE>,IPLHasOutline,IPLHasPadding<IMPLTYPE>,IPLHasVerticalAlignment<IMPLTYPE>,IPLObject<IMPLTYPE>,IPLRenderableObject<IMPLTYPE>,IPLSplittableObject<IMPLTYPE,IMPLTYPE>,IPLVisitable
- Direct Known Subclasses:
PLBox,PLTableCell
public abstract class AbstractPLBox<IMPLTYPE extends AbstractPLBox<IMPLTYPE>> extends AbstractPLBlockElement<IMPLTYPE> implements IPLSplittableObject<IMPLTYPE,IMPLTYPE>
A box is a simple element that encapsulates another element and has a padding, border and margin itself as well as it can align the contained element.- Author:
- Philip Helger
-
-
Field Summary
-
Fields inherited from interface com.helger.pdflayout.base.IPLBlockElement
DEFAULT_FULL_WIDTH
-
Fields inherited from interface com.helger.pdflayout.base.IPLElement
DEFAULT_MAX_SIZE, DEFAULT_MIN_SIZE
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasBorder
DEFAULT_BORDER
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasFillColor
DEFAULT_FILL_COLOR
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasHorizontalAlignment
DEFAULT_HORZ_ALIGNMENT
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasMargin
DEFAULT_MARGIN
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasPadding
DEFAULT_PADDING
-
Fields inherited from interface com.helger.pdflayout.base.IPLHasVerticalAlignment
DEFAULT_VERT_ALIGNMENT
-
Fields inherited from interface com.helger.pdflayout.base.IPLSplittableObject
DEFAULT_VERT_SPLITTABLE
-
-
Constructor Summary
Constructors Constructor Description AbstractPLBox(IPLRenderableObject<?> aElement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IPLRenderableObject<?>getElement()protected SizeSpecgetElementPreparedSize()protected SizeSpecgetRenderSize(SizeSpec aPreparedSize)Overwrite this method to adopt prepared sizes (e.g. for min or max size) to get the render size.booleanhasElement()protected voidinternalSetElementPreparedSize(SizeSpec aSize)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.IMPLTYPEsetBasicDataFrom(IMPLTYPE aSource)For copying stuff internally.IMPLTYPEsetElement(IPLRenderableObject<?> aElement)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.AbstractPLBlockElement
getHorzAlign, getVertAlign, isFullWidth, setFullWidth, setHorzAlign, setVertAlign
-
Methods inherited from class com.helger.pdflayout.base.AbstractPLElement
getBorder, getFillColor, getMargin, getMaxSize, getMinSize, getPadding, setBorder, setFillColor, setMargin, setMaxSize, setMinSize, setPadding
-
Methods inherited from class com.helger.pdflayout.base.AbstractPLRenderableObject
getPrepareAvailableSize, getPreparedSize, 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.IPLElement
getMaxHeight, getMaxSize, getMaxWidth, getMinHeight, getMinSize, getMinWidth, setExactHeight, setExactSize, setExactWidth, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinWidth
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasBorder
getBorder, getBorderBottomWidth, getBorderLeftWidth, getBorderRightWidth, getBorderTopWidth, getBorderXSumWidth, getBorderYSumWidth, setBorder, setBorder, setBorder, setBorder, setBorder, setBorderBottom, setBorderLeft, setBorderRight, setBorderTop, setBorderX, setBorderY
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasFillColor
getFillColor, hasFillColor, setFillColor
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasHorizontalAlignment
getIndentX
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasMargin
addMarginBottom, addMarginLeft, addMarginRight, addMarginTop, addMarginX, addMarginY, getMargin, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMarginXSum, getMarginYSum, setMargin, setMargin, setMargin, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMarginX, setMarginY
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasMarginBorderPadding
getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSum
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasPadding
addPaddingBottom, addPaddingLeft, addPaddingRight, addPaddingTop, addPaddingX, addPaddingY, getPadding, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPaddingXSum, getPaddingYSum, setPadding, setPadding, setPadding, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRight, setPaddingTop, setPaddingX, setPaddingY
-
Methods inherited from interface com.helger.pdflayout.base.IPLHasVerticalAlignment
getIndentY, getIndentY
-
Methods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, getDebugID, hasID
-
Methods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
beforeRender, getPreparedHeight, getPreparedSize, getPreparedWidth, getRenderHeight, getRenderSize, getRenderWidth, isPrepared, prepare, render
-
Methods inherited from interface com.helger.pdflayout.base.IPLSplittableObject
internalCreateNewVertSplitObject
-
-
-
-
Constructor Detail
-
AbstractPLBox
public AbstractPLBox(@Nullable IPLRenderableObject<?> aElement)
-
-
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 AbstractPLBox<IMPLTYPE>>- Overrides:
setBasicDataFromin classAbstractPLBlockElement<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
getElement
@Nullable public final IPLRenderableObject<?> getElement()
- Returns:
- The element passed in the constructor. May be
null.
-
hasElement
public final boolean hasElement()
- Returns:
trueif an element is contained,falseif not.
-
setElement
@Nonnull public final IMPLTYPE setElement(@Nullable IPLRenderableObject<?> aElement)
-
isVertSplittable
public final boolean isVertSplittable()
- Specified by:
isVertSplittablein interfaceIPLObject<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>- Specified by:
isVertSplittablein interfaceIPLSplittableObject<IMPLTYPE extends AbstractPLBox<IMPLTYPE>,IMPLTYPE extends AbstractPLBox<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 AbstractPLBox<IMPLTYPE>,IMPLTYPE extends AbstractPLBox<IMPLTYPE>>- Parameters:
bVertSplittable-trueif this element is splittable,falseotherwise.- 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 AbstractPLBox<IMPLTYPE>>- Parameters:
aVisitor- The visitor to use. May not benull.- Returns:
EChange.CHANGEDif something changed internally.- Throws:
IOException- on PDFBox error
-
getElementPreparedSize
@Nullable protected final SizeSpec getElementPreparedSize()
- Returns:
- The prepared size of the contained element. May be
nullif this box was not yet prepared or if no element is contained.
-
internalSetElementPreparedSize
protected final void internalSetElementPreparedSize(@Nullable SizeSpec aSize)
-
getRenderSize
@Nonnull protected SizeSpec getRenderSize(@Nonnull SizeSpec aPreparedSize)
Description copied from class:AbstractPLRenderableObjectOverwrite this method to adopt prepared sizes (e.g. for min or max size) to get the render size.- Overrides:
getRenderSizein classAbstractPLElement<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>- 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.
-
onPrepare
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 AbstractPLBox<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 AbstractPLBox<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 AbstractPLBox<IMPLTYPE>,IMPLTYPE extends AbstractPLBox<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
@OverridingMethodsMustInvokeSuper 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 AbstractPLBox<IMPLTYPE>>- Parameters:
aCtx- Rendering context. Nevernull.- Throws:
IOException- In case of a PDFBox error
-
toString
public String toString()
- Overrides:
toStringin classAbstractPLBlockElement<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>
-
-