Skip to content

Commit 7d63a17

Browse files
committed
Make BlockRendrer abstract class; restore inherited return type.
1 parent 179d099 commit 7d63a17

36 files changed

+175
-276
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public Document add(AreaBreak areaBreak) {
128128
}
129129

130130
@Override
131-
public Document add(BlockElement element) {
131+
public <T extends IElement> Document add(BlockElement<T> element) {
132132
checkClosingStatus();
133133
super.add(element);
134134
if (element instanceof ILargeElement) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,28 @@ public interface IPropertyContainer {
7171
/**
7272
* Gets the property from this entity. Compared to {@link #getOwnProperty(Property)},
7373
* this method can check parent's properties, styles, etc, depending on the origin of the instance
74-
* @param <T> the return type associated with the property
74+
* @param <T1> the return type associated with the property
7575
* @param property the property to be retrieved
7676
* @return the value of the given property. {@code null} will be returned if the property value was not found
7777
*/
78-
<T> T getProperty(Property property);
78+
<T1> T1 getProperty(Property property);
7979

8080
/**
8181
* Gets own property from this entity. The property must have been set earlier to this entity.
8282
* If the property is not found, {@code null} will be returned.
83-
* @param <T> the return type associated with the property
83+
* @param <T1> the return type associated with the property
8484
* @param property the property to be retrieved
8585
* @return the value of the given own property. {@code null} will be returned if the property value was not found
8686
*/
87-
<T> T getOwnProperty(Property property);
87+
<T1> T1 getOwnProperty(Property property);
8888

8989
/**
9090
* Gets the default property from this entity.
91-
* @param <T> the return type associated with the property
91+
* @param <T1> the return type associated with the property
9292
* @param property the property to be retrieved
9393
* @return the default property value. If the default property is not defined, {@code null} will be returned
9494
*/
95-
<T> T getDefaultProperty(Property property);
95+
<T1> T1 getDefaultProperty(Property property);
9696

9797
/**
9898
* Sets a property for this entity.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public abstract class RootElement<T extends IPropertyContainer> extends ElementP
9696
* @return this element
9797
* @see BlockElement
9898
*/
99-
public RootElement<T> add(BlockElement element) {
99+
public <T2 extends IElement> RootElement<T> add(BlockElement<T2> element) {
100100
childElements.add(element);
101101
ensureRootRendererNotNull().addChild(element.createRendererSubTree());
102102
return this;

layout/src/main/java/com/itextpdf/layout/element/AbstractElement.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ public T addStyle(Style style) {
142142
*/
143143
protected void propagateArtifactRoleToChildElements() {
144144
for (IElement child : childElements) {
145-
if (child instanceof AbstractElement) {
146-
if (child instanceof IAccessibleElement) {
147-
((IAccessibleElement) child).setRole(PdfName.Artifact);
148-
}
145+
if (child instanceof IAccessibleElement) {
146+
((IAccessibleElement) child).setRole(PdfName.Artifact);
149147
}
150148
}
151149
}

layout/src/main/java/com/itextpdf/layout/element/AreaBreak.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ This file is part of the iText (R) project.
4848
import com.itextpdf.layout.property.AreaBreakType;
4949
import com.itextpdf.layout.property.Property;
5050
import com.itextpdf.layout.renderer.AreaBreakRenderer;
51+
import com.itextpdf.layout.renderer.IRenderer;
5152

5253
/**
5354
* A layout object that terminates the current content area and creates a new
5455
* one. If no {@link PageSize} is given, the new content area will have the same
5556
* size as the current one.
5657
*/
57-
public class AreaBreak extends AbstractElement {
58+
public class AreaBreak extends AbstractElement<AreaBreak> {
5859

5960
protected PageSize pageSize;
6061

@@ -109,7 +110,7 @@ public AreaBreakType getType() {
109110
}
110111

111112
@Override
112-
protected AreaBreakRenderer makeNewRenderer() {
113+
protected IRenderer makeNewRenderer() {
113114
return new AreaBreakRenderer(this);
114115
}
115116
}

layout/src/main/java/com/itextpdf/layout/element/BlockElement.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ This file is part of the iText (R) project.
4747
import com.itextpdf.kernel.pdf.tagutils.IAccessibleElement;
4848
import com.itextpdf.layout.property.Property;
4949
import com.itextpdf.layout.property.VerticalAlignment;
50-
import com.itextpdf.layout.renderer.BlockRenderer;
5150

5251
/**
5352
* A {@link BlockElement} will try to take up as much horizontal space as
@@ -340,9 +339,4 @@ public T setRotationAngle(double angle) {
340339
setProperty(Property.ROTATION_ANGLE, (float) angle);
341340
return (T) this;
342341
}
343-
344-
@Override
345-
protected BlockRenderer makeNewRenderer() {
346-
return new BlockRenderer(this);
347-
}
348342
}

layout/src/main/java/com/itextpdf/layout/element/Cell.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public Cell () {
105105
* @return a cell renderer for this element
106106
*/
107107
@Override
108-
public CellRenderer getRenderer() {
108+
public IRenderer getRenderer() {
109109
CellRenderer cellRenderer = null;
110110
if (nextRenderer != null) {
111111
if (nextRenderer instanceof CellRenderer) {
@@ -143,7 +143,7 @@ public int getColspan() {
143143
* @param element a {@link BlockElement}
144144
* @return this Element
145145
*/
146-
public Cell add(BlockElement element) {
146+
public <T extends IElement> Cell add(BlockElement<T> element) {
147147
childElements.add(element);
148148
return this;
149149
}
@@ -240,7 +240,7 @@ public AccessibilityProperties getAccessibilityProperties() {
240240
}
241241

242242
@Override
243-
protected CellRenderer makeNewRenderer() {
243+
protected IRenderer makeNewRenderer() {
244244
return new CellRenderer(this);
245245
}
246246

layout/src/main/java/com/itextpdf/layout/element/Div.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ This file is part of the iText (R) project.
4646

4747
import com.itextpdf.kernel.pdf.PdfName;
4848
import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties;
49+
import com.itextpdf.layout.renderer.DivRenderer;
50+
import com.itextpdf.layout.renderer.IRenderer;
4951

5052
/**
5153
* A {@link Div} is a container object that defines a section in a document,
@@ -65,7 +67,7 @@ public class Div extends BlockElement<Div> {
6567
* @param element a {@link BlockElement}
6668
* @return this Element
6769
*/
68-
public Div add(BlockElement element) {
70+
public <T extends IElement> Div add(BlockElement<T> element) {
6971
childElements.add(element);
7072
return this;
7173
}
@@ -101,4 +103,9 @@ public AccessibilityProperties getAccessibilityProperties() {
101103
}
102104
return tagProperties;
103105
}
106+
107+
@Override
108+
protected IRenderer makeNewRenderer() {
109+
return new DivRenderer(this);
110+
}
104111
}

layout/src/main/java/com/itextpdf/layout/element/LineSeparator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This file is part of the iText (R) project.
4848
import com.itextpdf.kernel.pdf.canvas.draw.ILineDrawer;
4949
import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties;
5050
import com.itextpdf.layout.property.Property;
51-
import com.itextpdf.layout.renderer.BlockRenderer;
51+
import com.itextpdf.layout.renderer.IRenderer;
5252
import com.itextpdf.layout.renderer.LineSeparatorRenderer;
5353

5454
/**
@@ -70,7 +70,7 @@ public LineSeparator(ILineDrawer lineDrawer) {
7070
}
7171

7272
@Override
73-
protected BlockRenderer makeNewRenderer() {
73+
protected IRenderer makeNewRenderer() {
7474
return new LineSeparatorRenderer(this);
7575
}
7676

layout/src/main/java/com/itextpdf/layout/element/Link.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This file is part of the iText (R) project.
4949
import com.itextpdf.kernel.pdf.action.PdfAction;
5050
import com.itextpdf.kernel.pdf.annot.PdfLinkAnnotation;
5151
import com.itextpdf.kernel.pdf.navigation.PdfDestination;
52+
import com.itextpdf.layout.renderer.IRenderer;
5253
import com.itextpdf.layout.renderer.LinkRenderer;
5354

5455
/**
@@ -101,7 +102,7 @@ public PdfLinkAnnotation getLinkAnnotation() {
101102
}
102103

103104
@Override
104-
protected LinkRenderer makeNewRenderer() {
105+
protected IRenderer makeNewRenderer() {
105106
return new LinkRenderer(this, text);
106107
}
107108
}

0 commit comments

Comments
 (0)