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_WIDTHFields inherited from interface com.helger.pdflayout.base.IPLElement
DEFAULT_MAX_SIZE, DEFAULT_MIN_SIZEFields inherited from interface com.helger.pdflayout.base.IPLHasBorder
DEFAULT_BORDERFields inherited from interface com.helger.pdflayout.base.IPLHasFillColor
DEFAULT_FILL_COLORFields inherited from interface com.helger.pdflayout.base.IPLHasHorizontalAlignment
DEFAULT_HORZ_ALIGNMENTFields inherited from interface com.helger.pdflayout.base.IPLHasMargin
DEFAULT_MARGINFields inherited from interface com.helger.pdflayout.base.IPLHasPadding
DEFAULT_PADDINGFields inherited from interface com.helger.pdflayout.base.IPLHasVerticalAlignment
DEFAULT_VERT_ALIGNMENTFields inherited from interface com.helger.pdflayout.base.IPLSplittableObject
DEFAULT_VERT_SPLITTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal IPLRenderableObject<?>protected final SizeSpecprotected SizeSpecgetRenderSize(SizeSpec aPreparedSize) Overwrite this method to adopt prepared sizes (e.g. for min or max size) to get the render size.final booleanprotected final voidfinal booleanprotected voidPL 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.setBasicDataFrom(IMPLTYPE aSource) For copying stuff internally.final IMPLTYPEsetElement(IPLRenderableObject<?> aElement) final IMPLTYPEsetVertSplittable(boolean bVertSplittable) Change the vertical splitability of this object.splitElementVert(float fAvailableWidth, float fAvailableHeight) Split this element vertically into sub-elements according to the available height.toString()com.helger.commons.state.EChangevisit(IPLVisitor aVisitor) Visit this object and all descendantsMethods inherited from class com.helger.pdflayout.base.AbstractPLBlockElement
getHorzAlign, getVertAlign, isFullWidth, setFullWidth, setHorzAlign, setVertAlignMethods inherited from class com.helger.pdflayout.base.AbstractPLElement
getBorder, getFillColor, getMargin, getMaxSize, getMinSize, getPadding, setBorder, setFillColor, setMargin, setMaxSize, setMinSize, setPaddingMethods inherited from class com.helger.pdflayout.base.AbstractPLRenderableObject
getPrepareAvailableSize, getPreparedSize, getRenderSize, internalCheckAlreadyPrepared, internalCheckNotPrepared, internalMarkAsNotPrepared, internalMarkAsNotPreparedDontPropagate, internalMarkAsPrepared, isPrepared, onRenderSizeChange, prepare, renderMethods 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.IPLElement
getMaxHeight, getMaxSize, getMaxWidth, getMinHeight, getMinSize, getMinWidth, setExactHeight, setExactSize, setExactWidth, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinWidthMethods 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, setBorderYMethods inherited from interface com.helger.pdflayout.base.IPLHasFillColor
getFillColor, hasFillColor, setFillColorMethods inherited from interface com.helger.pdflayout.base.IPLHasHorizontalAlignment
getIndentXMethods 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, setMarginYMethods inherited from interface com.helger.pdflayout.base.IPLHasMarginBorderPadding
getOutlineBottom, getOutlineLeft, getOutlineRight, getOutlineTop, getOutlineXSum, getOutlineYSumMethods 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, setPaddingYMethods inherited from interface com.helger.pdflayout.base.IPLHasVerticalAlignment
getIndentY, getIndentYMethods inherited from interface com.helger.pdflayout.base.IPLObject
getAsSplittable, getDebugID, hasIDMethods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
beforeRender, getPreparedHeight, getPreparedSize, getPreparedWidth, getRenderHeight, getRenderSize, getRenderWidth, isPrepared, prepare, renderMethods inherited from interface com.helger.pdflayout.base.IPLSplittableObject
internalCreateNewVertSplitObject
-
Constructor Details
-
AbstractPLBox
-
-
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 AbstractPLBox<IMPLTYPE>>- Overrides:
setBasicDataFromin classAbstractPLBlockElement<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
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
-
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
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
- Returns:
- The prepared size of the contained element. May be
nullif this box was not yet prepared or if no element is contained.
-
internalSetElementPreparedSize
-
getRenderSize
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
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
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
- Overrides:
toStringin classAbstractPLBlockElement<IMPLTYPE extends AbstractPLBox<IMPLTYPE>>
-