@@ -68,28 +68,31 @@ public class BackgroundImage {
68
68
*/
69
69
@ Deprecated
70
70
protected boolean repeatY ;
71
-
72
71
protected AbstractLinearGradientBuilder linearGradientBuilder ;
73
72
74
73
private BlendMode blendMode = DEFAULT_BLEND_MODE ;
75
74
76
75
private BackgroundPosition position ;
76
+ private BackgroundSize backgroundSize ;
77
77
78
78
/**
79
79
* Creates a new {@link BackgroundImage} instance.
80
80
*
81
81
* @param image background-image property. {@link PdfXObject} instance.
82
82
* @param repeat background-repeat property. {@link BackgroundRepeat} instance.
83
83
* @param position background-position property. {@link BackgroundPosition} instance.
84
+ * @param backgroundSize background-size property. {@link BackgroundSize} instance.
84
85
* @param linearGradientBuilder background-image property. {@link AbstractLinearGradientBuilder} instance.
85
86
* @param blendMode the image's blend mode. {@link BlendMode} instance.
86
87
*/
87
88
protected BackgroundImage (PdfXObject image , BackgroundRepeat repeat , BackgroundPosition position ,
88
- AbstractLinearGradientBuilder linearGradientBuilder , BlendMode blendMode ) {
89
+ BackgroundSize backgroundSize , AbstractLinearGradientBuilder linearGradientBuilder ,
90
+ BlendMode blendMode ) {
89
91
this .image = image ;
90
92
this .repeatX = repeat .isRepeatX ();
91
93
this .repeatY = repeat .isRepeatY ();
92
94
this .position = position ;
95
+ this .backgroundSize = backgroundSize ;
93
96
this .linearGradientBuilder = linearGradientBuilder ;
94
97
if (blendMode != null ) {
95
98
this .blendMode = blendMode ;
@@ -106,7 +109,7 @@ protected BackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundP
106
109
*/
107
110
@ Deprecated
108
111
public BackgroundImage (final PdfImageXObject image , final BackgroundRepeat repeat , final BlendMode blendMode ) {
109
- this (image , repeat , new BackgroundPosition (), null , blendMode );
112
+ this (image , repeat , new BackgroundPosition (), new BackgroundSize (), null , blendMode );
110
113
}
111
114
112
115
/**
@@ -119,7 +122,7 @@ public BackgroundImage(final PdfImageXObject image, final BackgroundRepeat repea
119
122
*/
120
123
@ Deprecated
121
124
public BackgroundImage (final PdfFormXObject image , final BackgroundRepeat repeat , final BlendMode blendMode ) {
122
- this (image , repeat , new BackgroundPosition (), null , blendMode );
125
+ this (image , repeat , new BackgroundPosition (), new BackgroundSize (), null , blendMode );
123
126
}
124
127
125
128
/**
@@ -131,7 +134,7 @@ public BackgroundImage(final PdfFormXObject image, final BackgroundRepeat repeat
131
134
*/
132
135
@ Deprecated
133
136
public BackgroundImage (final PdfImageXObject image , final BackgroundRepeat repeat ) {
134
- this (image , repeat , new BackgroundPosition (), null , DEFAULT_BLEND_MODE );
137
+ this (image , repeat , new BackgroundPosition (), new BackgroundSize (), null , DEFAULT_BLEND_MODE );
135
138
}
136
139
137
140
/**
@@ -143,7 +146,7 @@ public BackgroundImage(final PdfImageXObject image, final BackgroundRepeat repea
143
146
*/
144
147
@ Deprecated
145
148
public BackgroundImage (final PdfFormXObject image , final BackgroundRepeat repeat ) {
146
- this (image , repeat , new BackgroundPosition (), null , DEFAULT_BLEND_MODE );
149
+ this (image , repeat , new BackgroundPosition (), new BackgroundSize (), null , DEFAULT_BLEND_MODE );
147
150
}
148
151
149
152
/**
@@ -154,7 +157,7 @@ public BackgroundImage(final PdfFormXObject image, final BackgroundRepeat repeat
154
157
*/
155
158
@ Deprecated
156
159
public BackgroundImage (final PdfImageXObject image ) {
157
- this (image , new BackgroundRepeat (), new BackgroundPosition (), null , DEFAULT_BLEND_MODE );
160
+ this (image , new BackgroundRepeat (), new BackgroundPosition (), new BackgroundSize (), null , DEFAULT_BLEND_MODE );
158
161
}
159
162
160
163
/**
@@ -165,7 +168,7 @@ public BackgroundImage(final PdfImageXObject image) {
165
168
*/
166
169
@ Deprecated
167
170
public BackgroundImage (final PdfFormXObject image ) {
168
- this (image , new BackgroundRepeat (), new BackgroundPosition (), null , DEFAULT_BLEND_MODE );
171
+ this (image , new BackgroundRepeat (), new BackgroundPosition (), new BackgroundSize (), null , DEFAULT_BLEND_MODE );
169
172
}
170
173
171
174
/**
@@ -178,7 +181,8 @@ public BackgroundImage(final PdfFormXObject image) {
178
181
*/
179
182
@ Deprecated
180
183
public BackgroundImage (final PdfImageXObject image , final boolean repeatX , final boolean repeatY ) {
181
- this (image , new BackgroundRepeat (repeatX , repeatY ), new BackgroundPosition (), null , DEFAULT_BLEND_MODE );
184
+ this (image , new BackgroundRepeat (repeatX , repeatY ), new BackgroundPosition (), new BackgroundSize (),
185
+ null , DEFAULT_BLEND_MODE );
182
186
}
183
187
184
188
/**
@@ -191,7 +195,8 @@ public BackgroundImage(final PdfImageXObject image, final boolean repeatX, final
191
195
*/
192
196
@ Deprecated
193
197
public BackgroundImage (final PdfFormXObject image , final boolean repeatX , final boolean repeatY ) {
194
- this (image , new BackgroundRepeat (repeatX , repeatY ), new BackgroundPosition (), null , DEFAULT_BLEND_MODE );
198
+ this (image , new BackgroundRepeat (repeatX , repeatY ), new BackgroundPosition (), new BackgroundSize (),
199
+ null , DEFAULT_BLEND_MODE );
195
200
}
196
201
197
202
/**
@@ -216,7 +221,8 @@ public BackgroundImage(final AbstractLinearGradientBuilder linearGradientBuilder
216
221
*/
217
222
@ Deprecated
218
223
public BackgroundImage (final AbstractLinearGradientBuilder linearGradientBuilder , final BlendMode blendMode ) {
219
- this (null , new BackgroundRepeat (false , false ), new BackgroundPosition (), linearGradientBuilder , blendMode );
224
+ this (null , new BackgroundRepeat (false , false ), new BackgroundPosition (), new BackgroundSize ()
225
+ , linearGradientBuilder , blendMode );
220
226
}
221
227
222
228
public PdfImageXObject getImage () {
@@ -252,10 +258,45 @@ public boolean isRepeatY() {
252
258
return repeatY ;
253
259
}
254
260
261
+ /**
262
+ * Gets the background size property.
263
+ *
264
+ * @return {@link BackgroundSize} instance
265
+ */
266
+ public BackgroundSize getBackgroundSize () {
267
+ return backgroundSize ;
268
+ }
269
+
270
+ /**
271
+ * Gets initial image width.
272
+ */
273
+ public float getImageWidth () {
274
+ return (float ) image .getWidth ();
275
+ }
276
+
277
+ /**
278
+ * Gets initial image height.
279
+ */
280
+ public float getImageHeight () {
281
+ return (float ) image .getHeight ();
282
+ }
283
+
284
+ /**
285
+ * Gets initial image width.
286
+ *
287
+ * @deprecated To be removed in 7.2. Use {@link BackgroundImage#getImageWidth()} instead.
288
+ */
289
+ @ Deprecated
255
290
public float getWidth () {
256
291
return (float ) image .getWidth ();
257
292
}
258
293
294
+ /**
295
+ * Gets initial image height.
296
+ *
297
+ * @deprecated To be removed in 7.2. Use {@link BackgroundImage#getImageHeight()} instead.
298
+ */
299
+ @ Deprecated
259
300
public float getHeight () {
260
301
return (float ) image .getHeight ();
261
302
}
@@ -279,6 +320,7 @@ public static class Builder {
279
320
private BackgroundPosition position = new BackgroundPosition ();
280
321
private BackgroundRepeat repeat = new BackgroundRepeat ();
281
322
private BlendMode blendMode = DEFAULT_BLEND_MODE ;
323
+ private BackgroundSize backgroundSize = new BackgroundSize ();
282
324
283
325
public Builder () {
284
326
}
@@ -347,13 +389,26 @@ public Builder setBackgroundBlendMode(BlendMode blendMode) {
347
389
return this ;
348
390
}
349
391
392
+ /**
393
+ * Set the image's backgroundSize.
394
+ *
395
+ * @param backgroundSize {@link BackgroundSize} to be set.
396
+ * @return this {@link Builder}.
397
+ */
398
+ public Builder setBackgroundSize (BackgroundSize backgroundSize ) {
399
+ if (backgroundSize != null ) {
400
+ this .backgroundSize = backgroundSize ;
401
+ }
402
+ return this ;
403
+ }
404
+
350
405
/**
351
406
* Builds new {@link BackgroundImage} using set fields.
352
407
*
353
408
* @return new {@link BackgroundImage}.
354
409
*/
355
410
public BackgroundImage build () {
356
- return new BackgroundImage (image , repeat , position , linearGradientBuilder , blendMode );
411
+ return new BackgroundImage (image , repeat , position , backgroundSize , linearGradientBuilder , blendMode );
357
412
}
358
413
}
359
414
}
0 commit comments