Package com.itextpdf.layout.properties
Class BackgroundImage
- java.lang.Object
-
- com.itextpdf.layout.properties.BackgroundImage
-
public class BackgroundImage extends java.lang.ObjectClass to hold background-image property.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBackgroundImage.BuilderBackgroundImagebuilder class.
-
Field Summary
Fields Modifier and Type Field Description private BackgroundBoxbackgroundClipprivate BackgroundBoxbackgroundOriginprivate BackgroundSizebackgroundSizeprivate BlendModeblendModeprivate static BlendModeDEFAULT_BLEND_MODEprivate static floatEPSprotected PdfXObjectimageprotected AbstractLinearGradientBuilderlinearGradientBuilderprivate static UnitValuePERCENT_VALUE_100private BackgroundPositionpositionprivate BackgroundRepeatrepeat
-
Constructor Summary
Constructors Modifier Constructor Description privateBackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundPosition position, BackgroundSize backgroundSize, AbstractLinearGradientBuilder linearGradientBuilder, BlendMode blendMode, BackgroundBox clip, BackgroundBox origin)Creates a newBackgroundImageinstance.BackgroundImage(BackgroundImage backgroundImage)Creates a copy of passedBackgroundImageinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description float[]calculateBackgroundImageSize(float areaWidth, float areaHeight)Calculates width and height values for background image with a given area params.private static BackgroundSizecalculateBackgroundSizeForArea(BackgroundImage image, float areaWidth, float areaHeight)private static BackgroundSizecreateBackgroundSizeWithMaxValueSide(boolean maxWidth)BackgroundBoxgetBackgroundClip()Gets background-clip.BackgroundBoxgetBackgroundOrigin()Gets background-origin.BackgroundPositiongetBackgroundPosition()Gets background-position.BackgroundSizegetBackgroundSize()Gets the background size property.BlendModegetBlendMode()Get the image's blend mode.PdfFormXObjectgetForm()Gets initial image if it is instanceofPdfFormXObject, otherwise returns null.PdfImageXObjectgetImage()Gets initial image if it is instanceofPdfImageXObject, otherwise returns null.floatgetImageHeight()Gets initial image height.floatgetImageWidth()Gets initial image width.AbstractLinearGradientBuildergetLinearGradientBuilder()Gets linearGradientBuilder.BackgroundRepeatgetRepeat()Gets imageBackgroundRepeatinstance.booleanisBackgroundSpecified()Returns is background specified.protected float[]resolveWidthAndHeight(java.lang.Float width, java.lang.Float height, float areaWidth, float areaHeight)Resolves the final size of the background image in specified area.
-
-
-
Field Detail
-
PERCENT_VALUE_100
private static final UnitValue PERCENT_VALUE_100
-
EPS
private static final float EPS
- See Also:
- Constant Field Values
-
DEFAULT_BLEND_MODE
private static final BlendMode DEFAULT_BLEND_MODE
-
image
protected PdfXObject image
-
linearGradientBuilder
protected AbstractLinearGradientBuilder linearGradientBuilder
-
blendMode
private BlendMode blendMode
-
repeat
private final BackgroundRepeat repeat
-
position
private final BackgroundPosition position
-
backgroundSize
private final BackgroundSize backgroundSize
-
backgroundClip
private final BackgroundBox backgroundClip
-
backgroundOrigin
private final BackgroundBox backgroundOrigin
-
-
Constructor Detail
-
BackgroundImage
public BackgroundImage(BackgroundImage backgroundImage)
Creates a copy of passedBackgroundImageinstance.- Parameters:
backgroundImage-BackgroundImagefor cloning
-
BackgroundImage
private BackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundPosition position, BackgroundSize backgroundSize, AbstractLinearGradientBuilder linearGradientBuilder, BlendMode blendMode, BackgroundBox clip, BackgroundBox origin)
Creates a newBackgroundImageinstance.- Parameters:
image- background-image property.PdfXObjectinstance.repeat- background-repeat property.BackgroundRepeatinstance.position- background-position property.BackgroundPositioninstance.backgroundSize- background-size property.BackgroundSizeinstance.linearGradientBuilder- background-image property.AbstractLinearGradientBuilderinstance.blendMode- the image's blend mode.BlendModeinstance.clip- background-clip property.BackgroundBoxinstance.origin- background-origin property.BackgroundBoxinstance.
-
-
Method Detail
-
getImage
public PdfImageXObject getImage()
Gets initial image if it is instanceofPdfImageXObject, otherwise returns null.- Returns:
PdfImageXObject
-
getForm
public PdfFormXObject getForm()
Gets initial image if it is instanceofPdfFormXObject, otherwise returns null.- Returns:
PdfFormXObject
-
calculateBackgroundImageSize
public float[] calculateBackgroundImageSize(float areaWidth, float areaHeight)Calculates width and height values for background image with a given area params.- Parameters:
areaWidth- width of the area of this imagesareaHeight- height of the area of this images- Returns:
- array of two float values. NOTE that first value defines width, second defines height
-
getBackgroundPosition
public BackgroundPosition getBackgroundPosition()
Gets background-position.- Returns:
BackgroundPosition
-
getLinearGradientBuilder
public AbstractLinearGradientBuilder getLinearGradientBuilder()
Gets linearGradientBuilder.- Returns:
AbstractLinearGradientBuilder
-
isBackgroundSpecified
public boolean isBackgroundSpecified()
Returns is background specified.- Returns:
trueif background is specified, otherwise false
-
getBackgroundSize
public BackgroundSize getBackgroundSize()
Gets the background size property.- Returns:
BackgroundSizeinstance
-
getImageWidth
public float getImageWidth()
Gets initial image width.- Returns:
- the initial image width
-
getImageHeight
public float getImageHeight()
Gets initial image height.- Returns:
- the initial image height
-
getRepeat
public BackgroundRepeat getRepeat()
Gets imageBackgroundRepeatinstance.- Returns:
- the image background repeat
-
getBlendMode
public BlendMode getBlendMode()
Get the image's blend mode.- Returns:
- the
BlendModerepresentation of the image's blend mode
-
getBackgroundClip
public BackgroundBox getBackgroundClip()
Gets background-clip.- Returns:
BackgroundBox
-
getBackgroundOrigin
public BackgroundBox getBackgroundOrigin()
Gets background-origin.- Returns:
BackgroundBox
-
resolveWidthAndHeight
protected float[] resolveWidthAndHeight(java.lang.Float width, java.lang.Float height, float areaWidth, float areaHeight)Resolves the final size of the background image in specified area.- Parameters:
width- the intrinsic background image widthheight- the intrinsic background image heightareaWidth- the area width in which background will be placedareaHeight- the area height in which background will be placed- Returns:
- the final size of the background image
-
calculateBackgroundSizeForArea
private static BackgroundSize calculateBackgroundSizeForArea(BackgroundImage image, float areaWidth, float areaHeight)
-
createBackgroundSizeWithMaxValueSide
private static BackgroundSize createBackgroundSizeWithMaxValueSide(boolean maxWidth)
-
-