Package com.itextpdf.layout
Class Style
- java.lang.Object
-
- com.itextpdf.commons.actions.sequence.AbstractIdentifiableElement
-
- com.itextpdf.layout.ElementPropertyContainer<Style>
-
- com.itextpdf.layout.Style
-
- All Implemented Interfaces:
IPropertyContainer
public class Style extends ElementPropertyContainer<Style>
Container object for style properties of an element. A style can be used as an effective way to define multiple equal properties to several elements. Used inAbstractElement
. The properties set via Style have a lower priority than directly set properties. For example, if the same property is set directly and added via Style, then, no matter in which order they are set, the one set directly will be chosen.
-
-
Field Summary
-
Fields inherited from class com.itextpdf.layout.ElementPropertyContainer
properties
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnitValue
getHeight()
Gets the height property of the 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 the element.java.lang.Boolean
isKeepTogether()
Returns whether theBlockElement
should be kept together as much as possible.Style
setHeight(float height)
Sets the height property the element as a point-value.Style
setHeight(UnitValue height)
Sets the height property of the element with aUnitValue
.Style
setKeepTogether(boolean keepTogether)
Sets whether theBlockElement
should be kept together as much as possible.Style
setMargin(float commonMargin)
Sets all margins around the element to the same width.Style
setMarginBottom(float value)
Sets the bottom margin width of the element.Style
setMarginLeft(float value)
Sets the left margin width of the element.Style
setMarginRight(float value)
Sets the right margin width of the element.Style
setMargins(float marginTop, float marginRight, float marginBottom, float marginLeft)
Sets the margins around the element to a series of new widths.Style
setMarginTop(float value)
Sets the top margin width of the element.Style
setMaxHeight(float maxHeight)
Sets the max-height of the element as point-unit value.Style
setMaxHeight(UnitValue maxHeight)
Sets the max-height property of the element with aUnitValue
.Style
setMaxWidth(float maxWidth)
Sets the max-width of the element as point-unit value.Style
setMaxWidth(UnitValue maxWidth)
Sets the max-width property of the element with aUnitValue
.Style
setMinHeight(float minHeight)
Sets the min-height of the element as point-unit value.Style
setMinHeight(UnitValue minHeight)
Sets the min-height property of the element with aUnitValue
.Style
setMinWidth(float minWidth)
Sets the min-width of the element as point-unit value.Style
setMinWidth(UnitValue minWidth)
Sets the min-width property of the element with aUnitValue
.Style
setPadding(float commonPadding)
Sets all paddings around the element to the same width.Style
setPaddingBottom(float value)
Sets the bottom padding width of the element.Style
setPaddingLeft(float value)
Sets the left padding width of the element.Style
setPaddingRight(float value)
Sets the right padding width of the element.Style
setPaddings(float paddingTop, float paddingRight, float paddingBottom, float paddingLeft)
Sets the paddings around the element to a series of new widths.Style
setPaddingTop(float value)
Sets the top padding width of the element.Style
setRotationAngle(double angle)
Sets the rotation angle.Style
setRotationAngle(float radAngle)
Sets the rotation radAngle.Style
setSpacingRatio(float ratio)
Sets a ratio which determines in which proportion will word spacing and character spacing be applied when horizontal alignment is justified.Style
setVerticalAlignment(VerticalAlignment verticalAlignment)
Sets the vertical alignment of the element.Style
setWidth(float width)
Sets the width property of the element, measured in points.Style
setWidth(UnitValue width)
Sets the width property of the element with aUnitValue
.-
Methods inherited from class com.itextpdf.layout.ElementPropertyContainer
deleteOwnProperty, getDefaultProperty, getOwnProperty, getProperty, getSplitCharacters, getStrokeColor, getStrokeWidth, getTextRenderingMode, hasOwnProperty, hasProperty, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundColor, setBackgroundImage, setBackgroundImage, setBaseDirection, 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, setLineThrough, setOpacity, setProperty, setRelativePosition, setSplitCharacters, setStrokeColor, setStrokeWidth, setTextAlignment, setTextRenderingMode, setUnderline, setUnderline, setUnderline, setUnderline, setWordSpacing, simulateBold, simulateItalic
-
-
-
-
Constructor Detail
-
Style
public Style()
-
Style
public Style(Style style)
-
-
Method Detail
-
getMarginLeft
public UnitValue getMarginLeft()
Gets the current left margin width of the element.- Returns:
- the left margin width, as a
UnitValue
object
-
setMarginLeft
public Style 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 Style 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 Style 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 Style setMarginBottom(float value)
Sets the bottom margin width of the element.- Parameters:
value
- the new bottom margin width- Returns:
- this element
-
setMargin
public Style setMargin(float commonMargin)
Sets all margins around the element to the same width.- Parameters:
commonMargin
- the new margin width- Returns:
- this element
-
setMargins
public Style 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 Style 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 Style 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 Style 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 Style setPaddingBottom(float value)
Sets the bottom padding width of the element.- Parameters:
value
- the new bottom padding width- Returns:
- this element
-
setPadding
public Style setPadding(float commonPadding)
Sets all paddings around the element to the same width.- Parameters:
commonPadding
- the new padding width- Returns:
- this element
-
setPaddings
public Style 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 Style setVerticalAlignment(VerticalAlignment verticalAlignment)
Sets the vertical alignment of the element.- Parameters:
verticalAlignment
- the vertical alignment setting- Returns:
- this element
-
setSpacingRatio
public Style 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 Style 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
-
setRotationAngle
public Style setRotationAngle(float radAngle)
Sets the rotation radAngle.- Parameters:
radAngle
- the new rotation radAngle, as afloat
- Returns:
- this element
-
setRotationAngle
public Style setRotationAngle(double angle)
Sets the rotation angle.- Parameters:
angle
- the new rotation angle, as adouble
- Returns:
- this element
-
setWidth
public Style setWidth(float width)
Sets the width property of the element, measured in points.- Parameters:
width
- a value measured in points.- Returns:
- this Element.
-
setWidth
public Style setWidth(UnitValue width)
Sets the width property of the element with aUnitValue
.- Parameters:
width
- aUnitValue
object- Returns:
- this Element.
-
getWidth
public UnitValue getWidth()
Gets the width property of the element.- Returns:
- the width of the element, with a value and a measurement unit.
- See Also:
UnitValue
-
setHeight
public Style setHeight(UnitValue height)
Sets the height property of the element with aUnitValue
.- Parameters:
height
- aUnitValue
object- Returns:
- this Element.
-
setHeight
public Style setHeight(float height)
Sets the height property the 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 the element.- Returns:
- the height of the element, as a floating point value. Null if the property is not present
-
setMaxHeight
public Style setMaxHeight(float maxHeight)
Sets the max-height of the element as point-unit value.- Parameters:
maxHeight
- a floating point value for the new max-height- Returns:
- the block element itself
-
setMaxHeight
public Style setMaxHeight(UnitValue maxHeight)
Sets the max-height property of the element with aUnitValue
.- Parameters:
maxHeight
- aUnitValue
object- Returns:
- the block element itself
-
setMinHeight
public Style setMinHeight(UnitValue minHeight)
Sets the min-height property of the element with aUnitValue
.- Parameters:
minHeight
- aUnitValue
object- Returns:
- the block element itself
-
setMinHeight
public Style setMinHeight(float minHeight)
Sets the min-height of the element as point-unit value.- Parameters:
minHeight
- a floating point value for the new min-height- Returns:
- the block element itself
-
setMaxWidth
public Style setMaxWidth(UnitValue maxWidth)
Sets the max-width property of the element with aUnitValue
.- Parameters:
maxWidth
- aUnitValue
object- Returns:
- the block element itself
-
setMaxWidth
public Style setMaxWidth(float maxWidth)
Sets the max-width of the element as point-unit value.- Parameters:
maxWidth
- a floating point value for the new max-width- Returns:
- the block element itself
-
setMinWidth
public Style setMinWidth(UnitValue minWidth)
Sets the min-width property of the element with aUnitValue
.- Parameters:
minWidth
- aUnitValue
object- Returns:
- the block element itself
-
setMinWidth
public Style setMinWidth(float minWidth)
Sets the min-width of the element as point-unit value.- Parameters:
minWidth
- a floating point value for the new min-width- Returns:
- the block element itself
-
-