Skip to content

Commit 0a36cd3

Browse files
committed
Minor fixes
1 parent b479f46 commit 0a36cd3

File tree

2 files changed

+59
-51
lines changed

2 files changed

+59
-51
lines changed

layout/src/main/java/com/itextpdf/layout/RootElement.java

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ This file is part of the iText (R) project.
7474

7575
/**
7676
* A generic abstract root element for a PDF layout object hierarchy.
77-
*
77+
*
7878
* @param <T> this type
7979
*/
8080
public abstract class RootElement<T extends IPropertyContainer> extends ElementPropertyContainer<T> {
@@ -92,26 +92,28 @@ public abstract class RootElement<T extends IPropertyContainer> extends ElementP
9292

9393
/**
9494
* Adds an element to the root. The element is immediately placed in the contents.
95+
*
9596
* @param element an element with spacial margins, tabbing, and alignment
9697
* @return this element
9798
* @see BlockElement
9899
*/
99-
public <T2 extends IElement> RootElement<T> add(BlockElement<T2> element) {
100+
public <T2 extends IElement> T add(BlockElement<T2> element) {
100101
childElements.add(element);
101102
ensureRootRendererNotNull().addChild(element.createRendererSubTree());
102-
return this;
103+
return (T) this;
103104
}
104105

105106
/**
106107
* Adds an image to the root. The element is immediately placed in the contents.
108+
*
107109
* @param image a graphical image element
108110
* @return this element
109111
* @see Image
110112
*/
111-
public RootElement<T> add(Image image) {
113+
public T add(Image image) {
112114
childElements.add(image);
113115
ensureRootRendererNotNull().addChild(image.createRendererSubTree());
114-
return this;
116+
return (T) this;
115117
}
116118

117119
@Override
@@ -182,7 +184,7 @@ public void setProperty(Property property, Object value) {
182184
* Gets the rootRenderer attribute, a specialized {@link IRenderer} that
183185
* acts as the root object that other {@link IRenderer renderers} descend
184186
* from.
185-
*
187+
*
186188
* @return the {@link RootRenderer} attribute
187189
*/
188190
public RootRenderer getRenderer() {
@@ -191,99 +193,106 @@ public RootRenderer getRenderer() {
191193

192194
/**
193195
* 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
197200
* @param textAlign horizontal alignment about the specified point
198201
* @return this object
199202
*/
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) {
201204
return showTextAligned(text, x, y, textAlign, 0);
202205
}
203206

204207
/**
205208
* 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
209213
* @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
211215
* @return this object
212216
*/
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) {
214218
return showTextAligned(text, x, y, textAlign, VerticalAlignment.BOTTOM, angle);
215219
}
216220

217221
/**
218222
* 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
222227
* @param textAlign horizontal alignment about the specified point
223228
* @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
225230
* @return this object
226231
*/
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) {
228233
Paragraph p = new Paragraph(text);
229234
return showTextAligned(p, x, y, pdfDocument.getNumberOfPages(), textAlign, vertAlign, angle);
230235
}
231236

232237
/**
233238
* 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
237243
* @param textAlign horizontal alignment about the specified point
238244
* @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
240246
* @return this object
241247
*/
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) {
243249
Paragraph p = new Paragraph(text).setFontKerning(FontKerning.YES);
244250
return showTextAligned(p, x, y, pdfDocument.getNumberOfPages(), textAlign, vertAlign, angle);
245251
}
246252

247253
/**
248254
* 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
253260
* @param textAlign horizontal alignment about the specified point
254261
* @return this object
255262
*/
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) {
257264
return showTextAligned(p, x, y, pdfDocument.getNumberOfPages(), textAlign, VerticalAlignment.BOTTOM, 0);
258265
}
259266

260267
/**
261268
* 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
266274
* @param textAlign horizontal alignment about the specified point
267275
* @param vertAlign vertical alignment about the specified point
268276
* @return this object
269277
*/
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) {
271279
return showTextAligned(p, x, y, pdfDocument.getNumberOfPages(), textAlign, vertAlign, 0);
272280
}
273281

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) {
287296
Div div = new Div();
288297
div.setTextAlignment(textAlign).setVerticalAlignment(vertAlign);
289298
if (angle != 0) {
@@ -319,7 +328,7 @@ public RootElement<T> showTextAligned(Paragraph p, float x, float y, int pageNum
319328
div.setRole(PdfName.Artifact);
320329
this.add(div);
321330

322-
return this;
331+
return (T) this;
323332
}
324333

325334
protected abstract RootRenderer ensureRootRendererNotNull();

layout/src/main/java/com/itextpdf/layout/renderer/ListRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
8888
for (IRenderer symbolRenderer : symbolRenderers) {
8989
maxSymbolWidth = Math.max(maxSymbolWidth, symbolRenderer.getOccupiedArea().getBBox().getWidth());
9090
}
91-
Float symbolIndent = (Float)modelElement.getProperty(Property.LIST_SYMBOL_INDENT);
91+
Float symbolIndent = modelElement.getProperty(Property.LIST_SYMBOL_INDENT);
9292
listItemNum = 0;
9393
for (IRenderer childRenderer : childRenderers) {
9494
childRenderer.deleteOwnProperty(Property.MARGIN_LEFT);
@@ -116,7 +116,6 @@ protected IRenderer makeListSymbolRenderer(int index, IRenderer renderer) {
116116
} else if (defaultListSymbol instanceof ListNumberingType) {
117117
ListNumberingType numberingType = (ListNumberingType) defaultListSymbol;
118118
String numberText;
119-
com.itextpdf.layout.element.List listModelElement = (com.itextpdf.layout.element.List) getModelElement();
120119
switch (numberingType) {
121120
case DECIMAL:
122121
numberText = String.valueOf(index);

0 commit comments

Comments
 (0)