Package com.itextpdf.layout.properties
Class BackgroundImage
- java.lang.Object
-
- com.itextpdf.layout.properties.BackgroundImage
-
public class BackgroundImage extends java.lang.Object
Class to hold background-image property.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BackgroundImage.Builder
BackgroundImage
builder class.
-
Field Summary
Fields Modifier and Type Field Description private BackgroundBox
backgroundClip
private BackgroundBox
backgroundOrigin
private BackgroundSize
backgroundSize
private BlendMode
blendMode
private static BlendMode
DEFAULT_BLEND_MODE
private static float
EPS
protected PdfXObject
image
protected AbstractLinearGradientBuilder
linearGradientBuilder
private static UnitValue
PERCENT_VALUE_100
private BackgroundPosition
position
private BackgroundRepeat
repeat
-
Constructor Summary
Constructors Modifier Constructor Description private
BackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundPosition position, BackgroundSize backgroundSize, AbstractLinearGradientBuilder linearGradientBuilder, BlendMode blendMode, BackgroundBox clip, BackgroundBox origin)
Creates a newBackgroundImage
instance.BackgroundImage(BackgroundImage backgroundImage)
Creates a copy of passedBackgroundImage
instance.
-
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 BackgroundSize
calculateBackgroundSizeForArea(BackgroundImage image, float areaWidth, float areaHeight)
private static BackgroundSize
createBackgroundSizeWithMaxValueSide(boolean maxWidth)
BackgroundBox
getBackgroundClip()
Gets background-clip.BackgroundBox
getBackgroundOrigin()
Gets background-origin.BackgroundPosition
getBackgroundPosition()
Gets background-position.BackgroundSize
getBackgroundSize()
Gets the background size property.BlendMode
getBlendMode()
Get the image's blend mode.PdfFormXObject
getForm()
Gets initial image if it is instanceofPdfFormXObject
, otherwise returns null.PdfImageXObject
getImage()
Gets initial image if it is instanceofPdfImageXObject
, otherwise returns null.float
getImageHeight()
Gets initial image height.float
getImageWidth()
Gets initial image width.AbstractLinearGradientBuilder
getLinearGradientBuilder()
Gets linearGradientBuilder.BackgroundRepeat
getRepeat()
Gets imageBackgroundRepeat
instance.boolean
isBackgroundSpecified()
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 passedBackgroundImage
instance.- Parameters:
backgroundImage
-BackgroundImage
for cloning
-
BackgroundImage
private BackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundPosition position, BackgroundSize backgroundSize, AbstractLinearGradientBuilder linearGradientBuilder, BlendMode blendMode, BackgroundBox clip, BackgroundBox origin)
Creates a newBackgroundImage
instance.- Parameters:
image
- background-image property.PdfXObject
instance.repeat
- background-repeat property.BackgroundRepeat
instance.position
- background-position property.BackgroundPosition
instance.backgroundSize
- background-size property.BackgroundSize
instance.linearGradientBuilder
- background-image property.AbstractLinearGradientBuilder
instance.blendMode
- the image's blend mode.BlendMode
instance.clip
- background-clip property.BackgroundBox
instance.origin
- background-origin property.BackgroundBox
instance.
-
-
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:
true
if background is specified, otherwise false
-
getBackgroundSize
public BackgroundSize getBackgroundSize()
Gets the background size property.- Returns:
BackgroundSize
instance
-
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 imageBackgroundRepeat
instance.- Returns:
- the image background repeat
-
getBlendMode
public BlendMode getBlendMode()
Get the image's blend mode.- Returns:
- the
BlendMode
representation 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)
-
-