Package com.itextpdf.layout.element
Class BlockElement<T extends IElement>
- java.lang.Object
-
- com.itextpdf.commons.actions.sequence.AbstractIdentifiableElement
-
- com.itextpdf.layout.ElementPropertyContainer<T>
-
- com.itextpdf.layout.element.AbstractElement<T>
-
- com.itextpdf.layout.element.BlockElement<T>
-
- Type Parameters:
T
- the type of the implementation
- All Implemented Interfaces:
IAbstractElement
,IBlockElement
,IElement
,IPropertyContainer
,IAccessibleElement
public abstract class BlockElement<T extends IElement> extends AbstractElement<T> implements IAccessibleElement, IBlockElement
ABlockElement
will try to take up as much horizontal space as available to it on the canvas or page. The concept is comparable to the block element in HTML. Also like in HTML, the visual representation of the object can be delimited by padding, a border, and/or a margin.
-
-
Field Summary
-
Fields inherited from class com.itextpdf.layout.element.AbstractElement
childElements, nextRenderer, styles
-
Fields inherited from class com.itextpdf.layout.ElementPropertyContainer
properties
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BlockElement()
Creates a BlockElement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T1> T1
getDefaultProperty(int property)
Gets the default property from this entity.UnitValue
getHeight()
Gets the height property of a block element.UnitValue
getMarginBottom()
Gets the current bottom margin width of the element.UnitValue
getMarginLeft()
Gets the current left margin width of the element.UnitValue
getMarginRight()
Gets the current right margin width of the element.UnitValue
getMarginTop()
Gets the current top margin width of the element.UnitValue
getPaddingBottom()
Gets the current bottom padding width of the element.UnitValue
getPaddingLeft()
Gets the current left padding width of the element.UnitValue
getPaddingRight()
Gets the current right padding width of the element.UnitValue
getPaddingTop()
Gets the current top padding width of the element.UnitValue
getWidth()
Gets the width property of a block element.java.lang.Boolean
isKeepTogether()
Returns whether theBlockElement
should be kept together as much as possible.java.lang.Boolean
isKeepWithNext()
Returns whether the end of thisBlockElement
and the start of the next sibling of this element should be placed in the same area.T
setHeight(float height)
Sets the height property a block element as a point-value.T
setHeight(UnitValue height)
Sets the height property of a block element with aUnitValue
.T
setKeepTogether(boolean keepTogether)
Sets whether theBlockElement
should be kept together as much as possible.T
setKeepWithNext(boolean keepWithNext)
Sets whether the end of thisBlockElement
and the start of the next sibling of this element should be placed in the same area.T
setMargin(float commonMargin)
Sets all margins around the element to the same width.T
setMarginBottom(float value)
Sets the bottom margin width of the element.T
setMarginLeft(float value)
Sets the left margin width of the element.T
setMarginRight(float value)
Sets the right margin width of the element.T
setMargins(float marginTop, float marginRight, float marginBottom, float marginLeft)
Sets the margins around the element to a series of new widths.T
setMarginTop(float value)
Sets the top margin width of the element.T
setMaxHeight(float maxHeight)
Sets the max-height of a block element as point-unit value.T
setMaxHeight(UnitValue maxHeight)
Sets the max-height property of a block element with aUnitValue
.T
setMaxWidth(float maxWidth)
Sets the max-width of a block element as point-unit value.T
setMaxWidth(UnitValue maxWidth)
Sets the max-width property of a block element with aUnitValue
.T
setMinHeight(float minHeight)
Sets the min-height of a block element as point-unit value.T
setMinHeight(UnitValue minHeight)
Sets the min-height property of a block element with aUnitValue
.T
setMinWidth(float minWidth)
Sets the min-width of a block element as point-unit value.T
setMinWidth(UnitValue minWidth)
Sets the min-width property of a block element with aUnitValue
.T
setNeutralRole()
Give this element a neutral role.T
setPadding(float commonPadding)
Sets all paddings around the element to the same width.T
setPaddingBottom(float value)
Sets the bottom padding width of the element.T
setPaddingLeft(float value)
Sets the left padding width of the element.T
setPaddingRight(float value)
Sets the right padding width of the element.T
setPaddings(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft)
Sets the paddings around the element to a series of new widths.T
setPaddingTop(float value)
Sets the top padding width of the element.T
setRotationAngle(double angleInRadians)
Sets the rotation angle.T
setRotationAngle(float angleInRadians)
Sets the rotation radAngle.T
setSpacingRatio(float ratio)
Sets a ratio which determines in which proportion will word spacing and character spacing be applied when horizontal alignment is justified.T
setVerticalAlignment(VerticalAlignment verticalAlignment)
Sets the vertical alignment of the element.T
setWidth(float width)
Sets the width property of a block element, measured in points.T
setWidth(UnitValue width)
Sets the width property of a block element with aUnitValue
.-
Methods inherited from class com.itextpdf.layout.element.AbstractElement
addStyle, createRendererSubTree, getChildren, getProperty, getRenderer, hasProperty, isEmpty, makeNewRenderer, setAction, setNextRenderer, setPageNumber
-
Methods inherited from class com.itextpdf.layout.ElementPropertyContainer
deleteOwnProperty, getOwnProperty, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, hasOwnProperty, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBaseDirection, setBold, setBorder, setBorderBottom, setBorderBottomLeftRadius, setBorderBottomRightRadius, setBorderLeft, setBorderRadius, setBorderRight, setBorderTop, setBorderTopLeftRadius, setBorderTopRightRadius, setCharacterSpacing, setDestination, setFixedPosition, setFixedPosition, setFixedPosition, setFixedPosition, setFont, setFontColor, setFontColor, setFontColor, setFontFamily, setFontFamily, setFontKerning, setFontScript, setFontSize, setHorizontalAlignment, setHyphenation, setItalic, setLineThrough, setOpacity, setProperty, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.itextpdf.layout.element.IAbstractElement
getChildren
-
Methods inherited from interface com.itextpdf.layout.tagging.IAccessibleElement
getAccessibilityProperties
-
Methods inherited from interface com.itextpdf.layout.element.IElement
createRendererSubTree, getRenderer, setNextRenderer
-
Methods inherited from interface com.itextpdf.layout.IPropertyContainer
deleteOwnProperty, getOwnProperty, getProperty, hasOwnProperty, hasProperty, setProperty
-
-
-
-
Method Detail
-
getDefaultProperty
public <T1> T1 getDefaultProperty(int property)
Description copied from interface:IPropertyContainer
Gets the default property from this entity.- Specified by:
getDefaultProperty
in interfaceIPropertyContainer
- Overrides:
getDefaultProperty
in classElementPropertyContainer<T extends IElement>
- Type Parameters:
T1
- the return type associated with the property- Parameters:
property
- the property to be retrieved- Returns:
- the default property value. If the default property is not defined,
null
will be returned
-
getMarginLeft
public UnitValue getMarginLeft()
Gets the current left margin width of the element.- Returns:
- the left margin width, as a
UnitValue
object
-
setMarginLeft
public T setMarginLeft(float value)
Sets the left margin width of the element.- Parameters:
value
- the new left margin width- Returns:
- this element
-
getMarginRight
public UnitValue getMarginRight()
Gets the current right margin width of the element.- Returns:
- the right margin width, as a
UnitValue
object
-
setMarginRight
public T setMarginRight(float value)
Sets the right margin width of the element.- Parameters:
value
- the new right margin width- Returns:
- this element
-
getMarginTop
public UnitValue getMarginTop()
Gets the current top margin width of the element.- Returns:
- the top margin width, as a
UnitValue
object
-
setMarginTop
public T setMarginTop(float value)
Sets the top margin width of the element.- Parameters:
value
- the new top margin width- Returns:
- this element
-
getMarginBottom
public UnitValue getMarginBottom()
Gets the current bottom margin width of the element.- Returns:
- the bottom margin width, as a
UnitValue
object
-
setMarginBottom
public T setMarginBottom(float value)
Sets the bottom margin width of the element.- Parameters:
value
- the new bottom margin width- Returns:
- this element
-
setMargin
public T setMargin(float commonMargin)
Sets all margins around the element to the same width.- Parameters:
commonMargin
- the new margin width- Returns:
- this element
-
setMargins
public T setMargins(float marginTop, float marginRight, float marginBottom, float marginLeft)
Sets the margins around the element to a series of new widths.- Parameters:
marginTop
- the new margin top widthmarginRight
- the new margin right widthmarginBottom
- the new margin bottom widthmarginLeft
- the new margin left width- Returns:
- this element
-
getPaddingLeft
public UnitValue getPaddingLeft()
Gets the current left padding width of the element.- Returns:
- the left padding width, as a
UnitValue
object
-
setPaddingLeft
public T setPaddingLeft(float value)
Sets the left padding width of the element.- Parameters:
value
- the new left padding width- Returns:
- this element
-
getPaddingRight
public UnitValue getPaddingRight()
Gets the current right padding width of the element.- Returns:
- the right padding width, as a
UnitValue
object
-
setPaddingRight
public T setPaddingRight(float value)
Sets the right padding width of the element.- Parameters:
value
- the new right padding width- Returns:
- this element
-
getPaddingTop
public UnitValue getPaddingTop()
Gets the current top padding width of the element.- Returns:
- the top padding width, as a
UnitValue
object
-
setPaddingTop
public T setPaddingTop(float value)
Sets the top padding width of the element.- Parameters:
value
- the new top padding width- Returns:
- this element
-
getPaddingBottom
public UnitValue getPaddingBottom()
Gets the current bottom padding width of the element.- Returns:
- the bottom padding width, as a
UnitValue
object
-
setPaddingBottom
public T setPaddingBottom(float value)
Sets the bottom padding width of the element.- Parameters:
value
- the new bottom padding width- Returns:
- this element
-
setPadding
public T setPadding(float commonPadding)
Sets all paddings around the element to the same width.- Parameters:
commonPadding
- the new padding width- Returns:
- this element
-
setPaddings
public T setPaddings(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft)
Sets the paddings around the element to a series of new widths.- Parameters:
paddingTop
- the new padding top widthpaddingRight
- the new padding right widthpaddingBottom
- the new padding bottom widthpaddingLeft
- the new padding left width- Returns:
- this element
-
setVerticalAlignment
public T setVerticalAlignment(VerticalAlignment verticalAlignment)
Sets the vertical alignment of the element.- Parameters:
verticalAlignment
- the vertical alignment setting- Returns:
- this element
-
setSpacingRatio
public T setSpacingRatio(float ratio)
Sets a ratio which determines in which proportion will word spacing and character spacing be applied when horizontal alignment is justified.- Parameters:
ratio
- the ratio coefficient. It must be between 0 and 1, inclusive. It means that ratio part of the free space will be compensated by word spacing, and 1-ratio part of the free space will be compensated by character spacing. If ratio is 1, additional character spacing will not be applied. If ratio is 0, additional word spacing will not be applied.- Returns:
- this element
-
isKeepTogether
public java.lang.Boolean isKeepTogether()
Returns whether theBlockElement
should be kept together as much as possible.- Returns:
- the current value of the
Property.KEEP_TOGETHER
property
-
setKeepTogether
public T setKeepTogether(boolean keepTogether)
Sets whether theBlockElement
should be kept together as much as possible.- Parameters:
keepTogether
- the new value of theProperty.KEEP_TOGETHER
property- Returns:
- this element
-
isKeepWithNext
public java.lang.Boolean isKeepWithNext()
Returns whether the end of thisBlockElement
and the start of the next sibling of this element should be placed in the same area.- Returns:
- the current value of the
Property.KEEP_WITH_NEXT
property
-
setKeepWithNext
public T setKeepWithNext(boolean keepWithNext)
Sets whether the end of thisBlockElement
and the start of the next sibling of this element should be placed in the same area. Note that this will only work for high-level elements, i.e. elements added to theRootElement
.- Parameters:
keepWithNext
- the new value of theProperty.KEEP_WITH_NEXT
property- Returns:
- this element
-
setRotationAngle
public T setRotationAngle(float angleInRadians)
Sets the rotation radAngle.- Parameters:
angleInRadians
- the new rotation radAngle, as afloat
, in radians- Returns:
- this element
-
setRotationAngle
public T setRotationAngle(double angleInRadians)
Sets the rotation angle.- Parameters:
angleInRadians
- the new rotation angle, as adouble
, in radians- Returns:
- this element
-
setWidth
public T setWidth(float width)
Sets the width property of a block element, measured in points.- Parameters:
width
- a value measured in points.- Returns:
- this Element.
-
setWidth
public T setWidth(UnitValue width)
Sets the width property of a block element with aUnitValue
.- Parameters:
width
- aUnitValue
object- Returns:
- this Element.
-
getWidth
public UnitValue getWidth()
Gets the width property of a block element.- Returns:
- the width of the element, with a value and a measurement unit.
- See Also:
UnitValue
-
setHeight
public T setHeight(UnitValue height)
Sets the height property of a block element with aUnitValue
.- Parameters:
height
- aUnitValue
object- Returns:
- this Element.
-
setHeight
public T setHeight(float height)
Sets the height property a block element as a point-value.- Parameters:
height
- a floating point value for the new height- Returns:
- the block element itself.
-
getHeight
public UnitValue getHeight()
Gets the height property of a block element.- Returns:
- the height of the element, as a floating point value. Null if the property is not present
-
setMaxHeight
public T setMaxHeight(float maxHeight)
Sets the max-height of a block element as point-unit value.- Parameters:
maxHeight
- a floating point value for the new max-height- Returns:
- the block element itself
-
setMaxHeight
public T setMaxHeight(UnitValue maxHeight)
Sets the max-height property of a block element with aUnitValue
.- Parameters:
maxHeight
- aUnitValue
object- Returns:
- the block element itself
-
setMinHeight
public T setMinHeight(UnitValue minHeight)
Sets the min-height property of a block element with aUnitValue
.- Parameters:
minHeight
- aUnitValue
object- Returns:
- the block element itself
-
setMinHeight
public T setMinHeight(float minHeight)
Sets the min-height of a block element as point-unit value.- Parameters:
minHeight
- a floating point value for the new min-height- Returns:
- the block element itself
-
setMaxWidth
public T setMaxWidth(UnitValue maxWidth)
Sets the max-width property of a block element with aUnitValue
.- Parameters:
maxWidth
- aUnitValue
object- Returns:
- the block element itself
-
setMaxWidth
public T setMaxWidth(float maxWidth)
Sets the max-width of a block element as point-unit value.- Parameters:
maxWidth
- a floating point value for the new max-width- Returns:
- the block element itself
-
setMinWidth
public T setMinWidth(UnitValue minWidth)
Sets the min-width property of a block element with aUnitValue
.- Parameters:
minWidth
- aUnitValue
object- Returns:
- the block element itself
-
setMinWidth
public T setMinWidth(float minWidth)
Sets the min-width of a block element as point-unit value.- Parameters:
minWidth
- a floating point value for the new min-width- Returns:
- the block element itself
-
setNeutralRole
public T setNeutralRole()
Give this element a neutral role. See alsoAccessibilityProperties.setRole(String)
.- Returns:
- this Element
-
-