Class AbstractPLText<IMPLTYPE extends AbstractPLText<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.AbstractPLInlineElement<IMPLTYPE>
com.helger.pdflayout.element.text.AbstractPLText<IMPLTYPE>
- Type Parameters:
IMPLTYPE- Implementation type
- All Implemented Interfaces:
com.helger.commons.id.IHasID<String>,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IPLElement<IMPLTYPE>,IPLHasBorder<IMPLTYPE>,IPLHasFillColor<IMPLTYPE>,IPLHasHorizontalAlignment<IMPLTYPE>,IPLHasMargin<IMPLTYPE>,IPLHasMarginBorderPadding<IMPLTYPE>,IPLHasOutline,IPLHasPadding<IMPLTYPE>,IPLInlineElement<IMPLTYPE>,IPLObject<IMPLTYPE>,IPLRenderableObject<IMPLTYPE>,IPLSplittableObject<IMPLTYPE,,IMPLTYPE> IPLVisitable
- Direct Known Subclasses:
PLText
public abstract class AbstractPLText<IMPLTYPE extends AbstractPLText<IMPLTYPE>>
extends AbstractPLInlineElement<IMPLTYPE>
implements IPLHasHorizontalAlignment<IMPLTYPE>, IPLSplittableObject<IMPLTYPE,IMPLTYPE>
Render text
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatstatic final intstatic final booleanprotected com.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec>protected com.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec>protected floatprotected floatprotected intFields 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.IPLSplittableObject
DEFAULT_VERT_SPLITTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.helger.commons.state.EChangeCalled after the page was created but before the content stream is created.com.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec>static StringgetCleanedPLText(String sText) final floatprotected final floatgetDisplayHeightOfLineCount(int nLineCount, boolean bLineSpacingAlsoOnLastLine) final FontSpecfinal EHorzAlignmentfinal floatfinal intintfinal StringgetText()final booleanfinal booleanhasText()final booleanfinal 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 IMPLTYPEsetCustomAscentFirstLine(float fCustomAscentFirstLine) Set a custom ascent to the first linefinal IMPLTYPEsetHorzAlign(EHorzAlignment eHorzAlign) Set the horizontal alignment of this element.final IMPLTYPEsetLineSpacing(float fLineSpacing) Set the line spacing to use.final IMPLTYPEsetMaxRows(int nMaxRows) Set the maximum number of rows to render.final IMPLTYPEsetReplacePlaceholder(boolean bReplacePlaceholder) Change whether placeholders should be replaced or not.final IMPLTYPEsetVertSplittable(boolean bVertSplittable) Change the vertical splitability of this object.splitElementVert(float fElementWidth, float fAvailableHeight) Split this element vertically into sub-elements according to the available height.toString()Methods inherited from class com.helger.pdflayout.base.AbstractPLElement
getBorder, getFillColor, getMargin, getMaxSize, getMinSize, getPadding, getRenderSize, 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, render, visitMethods 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.IPLObject
getAsSplittable, getDebugID, hasIDMethods inherited from interface com.helger.pdflayout.base.IPLRenderableObject
getPreparedHeight, getPreparedSize, getPreparedWidth, getRenderHeight, getRenderSize, getRenderWidth, isPrepared, prepare, renderMethods inherited from interface com.helger.pdflayout.base.IPLSplittableObject
internalCreateNewVertSplitObjectMethods inherited from interface com.helger.pdflayout.base.IPLVisitable
visit
-
Field Details
-
DEFAULT_LINE_SPACING
public static final float DEFAULT_LINE_SPACING- See Also:
-
DEFAULT_MAX_ROWS
public static final int DEFAULT_MAX_ROWS- See Also:
-
DEFAULT_REPLACE_PLACEHOLDERS
public static final boolean DEFAULT_REPLACE_PLACEHOLDERS- See Also:
-
m_fTextHeight
protected float m_fTextHeight -
m_fDescent
protected float m_fDescent -
m_nPreparedLineCountUnmodified
protected int m_nPreparedLineCountUnmodified -
m_aPreparedLinesUnmodified
protected com.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec> m_aPreparedLinesUnmodified -
m_aPreparedLines
-
-
Constructor Details
-
AbstractPLText
-
-
Method Details
-
getCleanedPLText
-
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 AbstractPLText<IMPLTYPE>>- Overrides:
setBasicDataFromin classAbstractPLInlineElement<IMPLTYPE extends AbstractPLText<IMPLTYPE>>- Parameters:
aSource- Source object to copy from. May not benull.- Returns:
- this for chaining
-
getText
- Returns:
- The original text provided in the constructor, with newlines
unified. Never
null.
-
hasText
public final boolean hasText()- Returns:
trueif the contained text has at least one character,falseif it is empty.
-
hasNoText
public final boolean hasNoText()- Returns:
trueif the text provided in the constructor contains no character,falseotherwise.
-
getFontSpec
- Returns:
- The font specification to be used as provided in the constructor.
Never
null.
-
getLineSpacing
public final float getLineSpacing()- Returns:
- The line height factor. Defaults to
DEFAULT_LINE_SPACINGwhich means 100%.
-
setLineSpacing
Set the line spacing to use. The line spacing is the distance between 2 consecutive lines. The line spacing is not considered if there is a single line of text.- Parameters:
fLineSpacing- A value of 1 means 100%, 1.05 means 105% etc. Must be > 0.- Returns:
- this for chaining
-
getHorzAlign
- Specified by:
getHorzAlignin interfaceIPLHasHorizontalAlignment<IMPLTYPE extends AbstractPLText<IMPLTYPE>>- Returns:
- The horizontal alignment of this element. By default it is
EHorzAlignment.DEFAULT. Nevernull. The horizontal alignment may only be applied to contained children!
-
setHorzAlign
Description copied from interface:IPLHasHorizontalAlignmentSet the horizontal alignment of this element. The horizontal alignment may only be applied to contained children!- Specified by:
setHorzAlignin interfaceIPLHasHorizontalAlignment<IMPLTYPE extends AbstractPLText<IMPLTYPE>>- Parameters:
eHorzAlign- The new horizontal alignment. May not benull.- Returns:
- this
-
getMaxRows
- Returns:
- The maximum number of rows to be rendered. If this value is ≤ 0
than all rows are rendered. The default value is
DEFAULT_MAX_ROWSmeaning all rows are rendered.
-
setMaxRows
Set the maximum number of rows to render.- Parameters:
nMaxRows- Maximum number of rows. If ≤ 0 than all lines are rendered.- Returns:
- this for chaining
-
isVertSplittable
public final boolean isVertSplittable()- Specified by:
isVertSplittablein interfaceIPLObject<IMPLTYPE extends AbstractPLText<IMPLTYPE>>- Specified by:
isVertSplittablein interfaceIPLSplittableObject<IMPLTYPE extends AbstractPLText<IMPLTYPE>,IMPLTYPE extends AbstractPLText<IMPLTYPE>> - Returns:
trueif this element is splittable,falseotherwise.
-
setVertSplittable
Description copied from interface:IPLSplittableObjectChange the vertical splitability of this object.- Specified by:
setVertSplittablein interfaceIPLSplittableObject<IMPLTYPE extends AbstractPLText<IMPLTYPE>,IMPLTYPE extends AbstractPLText<IMPLTYPE>> - Parameters:
bVertSplittable-trueif this element is splittable,falseotherwise.- Returns:
- this for chaining
-
isReplacePlaceholder
public final boolean isReplacePlaceholder()- Returns:
trueif placeholders should be replaced,falseotherwise. The default value isDEFAULT_REPLACE_PLACEHOLDERSso false.
-
setReplacePlaceholder
Change whether placeholders should be replaced or not. Enabling this slows down the execution of rendering. Enable this only if absolutely necessary.- Parameters:
bReplacePlaceholder-trueif placeholders should be replaced,falseotherwise.- Returns:
- this for chaining
-
getCustomAscentFirstLine
public final float getCustomAscentFirstLine()- Returns:
- A custom ascent to the first line. Defaults to 0.
- Since:
- 5.1.0
-
setCustomAscentFirstLine
Set a custom ascent to the first line- Parameters:
fCustomAscentFirstLine- The value to use. 0 means no change.- Returns:
- this for chaining
- Since:
- 5.1.0
-
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 AbstractPLText<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 AbstractPLText<IMPLTYPE>>
-
getPreparedLineCountUnmodified
- Returns:
- The total number of prepared lines, not taking the maxRows into consideration. Always ≥ 0.
-
getAllPreparedLinesUnmodified
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<TextAndWidthSpec> getAllPreparedLinesUnmodified() -
getDisplayHeightOfLineCount
protected final float getDisplayHeightOfLineCount(@Nonnegative int nLineCount, boolean bLineSpacingAlsoOnLastLine) -
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 AbstractPLText<IMPLTYPE>,IMPLTYPE extends AbstractPLText<IMPLTYPE>> - Parameters:
fElementWidth- 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.
-
beforeRender
@Nonnull public com.helger.commons.state.EChange beforeRender(@Nonnull PagePreRenderContext aCtx) throws IOException Description copied from interface:IPLRenderableObjectCalled after the page was created but before the content stream is created. This is e.g. used for images to create their XObjects upfront.- Specified by:
beforeRenderin interfaceIPLRenderableObject<IMPLTYPE extends AbstractPLText<IMPLTYPE>>- Parameters:
aCtx- The current page render context. Nevernull.- Returns:
EChange.CHANGEDif something changed. May not benull.- Throws:
IOException- In case of a PDFBox error
-
onRender
Description copied from class:AbstractPLRenderableObjectAbstract method to be implemented by subclasses.- Specified by:
onRenderin classAbstractPLRenderableObject<IMPLTYPE extends AbstractPLText<IMPLTYPE>>- Parameters:
aCtx- Rendering context. Nevernull.- Throws:
IOException- In case of a PDFBox error
-
toString
- Overrides:
toStringin classAbstractPLElement<IMPLTYPE extends AbstractPLText<IMPLTYPE>>
-