@@ -74,7 +74,7 @@ This file is part of the iText (R) project.
74
74
75
75
/**
76
76
* A generic abstract root element for a PDF layout object hierarchy.
77
- *
77
+ *
78
78
* @param <T> this type
79
79
*/
80
80
public abstract class RootElement <T extends IPropertyContainer > extends ElementPropertyContainer <T > {
@@ -92,26 +92,28 @@ public abstract class RootElement<T extends IPropertyContainer> extends ElementP
92
92
93
93
/**
94
94
* Adds an element to the root. The element is immediately placed in the contents.
95
+ *
95
96
* @param element an element with spacial margins, tabbing, and alignment
96
97
* @return this element
97
98
* @see BlockElement
98
99
*/
99
- public <T2 extends IElement > RootElement < T > add (BlockElement <T2 > element ) {
100
+ public <T2 extends IElement > T add (BlockElement <T2 > element ) {
100
101
childElements .add (element );
101
102
ensureRootRendererNotNull ().addChild (element .createRendererSubTree ());
102
- return this ;
103
+ return ( T ) this ;
103
104
}
104
105
105
106
/**
106
107
* Adds an image to the root. The element is immediately placed in the contents.
108
+ *
107
109
* @param image a graphical image element
108
110
* @return this element
109
111
* @see Image
110
112
*/
111
- public RootElement < T > add (Image image ) {
113
+ public T add (Image image ) {
112
114
childElements .add (image );
113
115
ensureRootRendererNotNull ().addChild (image .createRendererSubTree ());
114
- return this ;
116
+ return ( T ) this ;
115
117
}
116
118
117
119
@ Override
@@ -182,7 +184,7 @@ public void setProperty(Property property, Object value) {
182
184
* Gets the rootRenderer attribute, a specialized {@link IRenderer} that
183
185
* acts as the root object that other {@link IRenderer renderers} descend
184
186
* from.
185
- *
187
+ *
186
188
* @return the {@link RootRenderer} attribute
187
189
*/
188
190
public RootRenderer getRenderer () {
@@ -191,99 +193,106 @@ public RootRenderer getRenderer() {
191
193
192
194
/**
193
195
* Convenience method to write a text aligned about the specified point
194
- * @param text text to be placed to the page
195
- * @param x the point about which the text will be aligned and rotated
196
- * @param y the point about which the text will be aligned and rotated
196
+ *
197
+ * @param text text to be placed to the page
198
+ * @param x the point about which the text will be aligned and rotated
199
+ * @param y the point about which the text will be aligned and rotated
197
200
* @param textAlign horizontal alignment about the specified point
198
201
* @return this object
199
202
*/
200
- public RootElement < T > showTextAligned (String text , float x , float y , TextAlignment textAlign ) {
203
+ public T showTextAligned (String text , float x , float y , TextAlignment textAlign ) {
201
204
return showTextAligned (text , x , y , textAlign , 0 );
202
205
}
203
206
204
207
/**
205
208
* Convenience method to write a text aligned about the specified point
206
- * @param text text to be placed to the page
207
- * @param x the point about which the text will be aligned and rotated
208
- * @param y the point about which the text will be aligned and rotated
209
+ *
210
+ * @param text text to be placed to the page
211
+ * @param x the point about which the text will be aligned and rotated
212
+ * @param y the point about which the text will be aligned and rotated
209
213
* @param textAlign horizontal alignment about the specified point
210
- * @param angle the angle of rotation applied to the text, in radians
214
+ * @param angle the angle of rotation applied to the text, in radians
211
215
* @return this object
212
216
*/
213
- public RootElement < T > showTextAligned (String text , float x , float y , TextAlignment textAlign , float angle ) {
217
+ public T showTextAligned (String text , float x , float y , TextAlignment textAlign , float angle ) {
214
218
return showTextAligned (text , x , y , textAlign , VerticalAlignment .BOTTOM , angle );
215
219
}
216
220
217
221
/**
218
222
* Convenience method to write a text aligned about the specified point
219
- * @param text text to be placed to the page
220
- * @param x the point about which the text will be aligned and rotated
221
- * @param y the point about which the text will be aligned and rotated
223
+ *
224
+ * @param text text to be placed to the page
225
+ * @param x the point about which the text will be aligned and rotated
226
+ * @param y the point about which the text will be aligned and rotated
222
227
* @param textAlign horizontal alignment about the specified point
223
228
* @param vertAlign vertical alignment about the specified point
224
- * @param angle the angle of rotation applied to the text, in radians
229
+ * @param angle the angle of rotation applied to the text, in radians
225
230
* @return this object
226
231
*/
227
- public RootElement < T > showTextAligned (String text , float x , float y , TextAlignment textAlign , VerticalAlignment vertAlign , float angle ) {
232
+ public T showTextAligned (String text , float x , float y , TextAlignment textAlign , VerticalAlignment vertAlign , float angle ) {
228
233
Paragraph p = new Paragraph (text );
229
234
return showTextAligned (p , x , y , pdfDocument .getNumberOfPages (), textAlign , vertAlign , angle );
230
235
}
231
236
232
237
/**
233
238
* Convenience method to write a kerned text aligned about the specified point
234
- * @param text text to be placed to the page
235
- * @param x the point about which the text will be aligned and rotated
236
- * @param y the point about which the text will be aligned and rotated
239
+ *
240
+ * @param text text to be placed to the page
241
+ * @param x the point about which the text will be aligned and rotated
242
+ * @param y the point about which the text will be aligned and rotated
237
243
* @param textAlign horizontal alignment about the specified point
238
244
* @param vertAlign vertical alignment about the specified point
239
- * @param angle the angle of rotation applied to the text, in radians
245
+ * @param angle the angle of rotation applied to the text, in radians
240
246
* @return this object
241
247
*/
242
- public RootElement < T > showTextAlignedKerned (String text , float x , float y , TextAlignment textAlign , VerticalAlignment vertAlign , float angle ) {
248
+ public T showTextAlignedKerned (String text , float x , float y , TextAlignment textAlign , VerticalAlignment vertAlign , float angle ) {
243
249
Paragraph p = new Paragraph (text ).setFontKerning (FontKerning .YES );
244
250
return showTextAligned (p , x , y , pdfDocument .getNumberOfPages (), textAlign , vertAlign , angle );
245
251
}
246
252
247
253
/**
248
254
* Convenience method to write a text aligned about the specified point
249
- * @param p paragraph of text to be placed to the page. By default it has no leading and is written in single line.
250
- * Set width to write multiline text.
251
- * @param x the point about which the text will be aligned and rotated
252
- * @param y the point about which the text will be aligned and rotated
255
+ *
256
+ * @param p paragraph of text to be placed to the page. By default it has no leading and is written in single line.
257
+ * Set width to write multiline text.
258
+ * @param x the point about which the text will be aligned and rotated
259
+ * @param y the point about which the text will be aligned and rotated
253
260
* @param textAlign horizontal alignment about the specified point
254
261
* @return this object
255
262
*/
256
- public RootElement < T > showTextAligned (Paragraph p , float x , float y , TextAlignment textAlign ) {
263
+ public T showTextAligned (Paragraph p , float x , float y , TextAlignment textAlign ) {
257
264
return showTextAligned (p , x , y , pdfDocument .getNumberOfPages (), textAlign , VerticalAlignment .BOTTOM , 0 );
258
265
}
259
266
260
267
/**
261
268
* Convenience method to write a text aligned about the specified point
262
- * @param p paragraph of text to be placed to the page. By default it has no leading and is written in single line.
263
- * Set width to write multiline text.
264
- * @param x the point about which the text will be aligned and rotated
265
- * @param y the point about which the text will be aligned and rotated
269
+ *
270
+ * @param p paragraph of text to be placed to the page. By default it has no leading and is written in single line.
271
+ * Set width to write multiline text.
272
+ * @param x the point about which the text will be aligned and rotated
273
+ * @param y the point about which the text will be aligned and rotated
266
274
* @param textAlign horizontal alignment about the specified point
267
275
* @param vertAlign vertical alignment about the specified point
268
276
* @return this object
269
277
*/
270
- public RootElement < T > showTextAligned (Paragraph p , float x , float y , TextAlignment textAlign , VerticalAlignment vertAlign ) {
278
+ public T showTextAligned (Paragraph p , float x , float y , TextAlignment textAlign , VerticalAlignment vertAlign ) {
271
279
return showTextAligned (p , x , y , pdfDocument .getNumberOfPages (), textAlign , vertAlign , 0 );
272
280
}
273
281
274
- /**
275
- * Convenience method to write a text aligned about the specified point
276
- * @param p paragraph of text to be placed to the page. By default it has no leading and is written in single line.
277
- * Set width to write multiline text.
278
- * @param x the point about which the text will be aligned and rotated
279
- * @param y the point about which the text will be aligned and rotated
280
- * @param pageNumber the page number to write the text
281
- * @param textAlign horizontal alignment about the specified point
282
- * @param vertAlign vertical alignment about the specified point
283
- * @param angle the angle of rotation applied to the text, in radians
284
- * @return this object
285
- */
286
- public RootElement <T > showTextAligned (Paragraph p , float x , float y , int pageNumber , TextAlignment textAlign , VerticalAlignment vertAlign , float angle ) {
282
+ /**
283
+ * Convenience method to write a text aligned about the specified point
284
+ *
285
+ * @param p paragraph of text to be placed to the page. By default it has no leading and is written in single line.
286
+ * Set width to write multiline text.
287
+ * @param x the point about which the text will be aligned and rotated
288
+ * @param y the point about which the text will be aligned and rotated
289
+ * @param pageNumber the page number to write the text
290
+ * @param textAlign horizontal alignment about the specified point
291
+ * @param vertAlign vertical alignment about the specified point
292
+ * @param angle the angle of rotation applied to the text, in radians
293
+ * @return this object
294
+ */
295
+ public T showTextAligned (Paragraph p , float x , float y , int pageNumber , TextAlignment textAlign , VerticalAlignment vertAlign , float angle ) {
287
296
Div div = new Div ();
288
297
div .setTextAlignment (textAlign ).setVerticalAlignment (vertAlign );
289
298
if (angle != 0 ) {
@@ -319,7 +328,7 @@ public RootElement<T> showTextAligned(Paragraph p, float x, float y, int pageNum
319
328
div .setRole (PdfName .Artifact );
320
329
this .add (div );
321
330
322
- return this ;
331
+ return ( T ) this ;
323
332
}
324
333
325
334
protected abstract RootRenderer ensureRootRendererNotNull ();
0 commit comments