Skip to content

Commit 0acb474

Browse files
committed
Propagate PdfShading class into independent classes
DEVSIX-4657
1 parent 57b5d09 commit 0acb474

22 files changed

+1776
-1509
lines changed

kernel/src/main/java/com/itextpdf/kernel/colors/gradients/AbstractLinearGradientBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ This file is part of the iText (R) project.
3636
import com.itextpdf.kernel.pdf.PdfDocument;
3737
import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs;
3838
import com.itextpdf.kernel.pdf.colorspace.PdfPattern;
39-
import com.itextpdf.kernel.pdf.colorspace.PdfShading;
39+
import com.itextpdf.kernel.pdf.colorspace.shading.PdfAxialShading;
4040
import com.itextpdf.kernel.pdf.function.AbstractPdfFunction;
4141
import com.itextpdf.kernel.pdf.function.IPdfFunction;
4242
import com.itextpdf.kernel.pdf.function.PdfType2Function;
@@ -166,7 +166,7 @@ public Color buildColor(Rectangle targetBoundingBox, AffineTransform contextTran
166166
}
167167
}
168168

169-
PdfShading.Axial axial = createAxialShading(baseCoordinatesVector, this.stops, this.spreadMethod,
169+
PdfAxialShading axial = createAxialShading(baseCoordinatesVector, this.stops, this.spreadMethod,
170170
targetBoundingBox);
171171
if (axial == null) {
172172
return null;
@@ -273,7 +273,7 @@ protected static Point[] createCoordinatesForNewDomain(double[] newDomain, Point
273273
return targetCoords;
274274
}
275275

276-
private static PdfShading.Axial createAxialShading(Point[] baseCoordinatesVector,
276+
private static PdfAxialShading createAxialShading(Point[] baseCoordinatesVector,
277277
List<GradientColorStop> stops, GradientSpreadMethod spreadMethod, Rectangle targetBoundingBox) {
278278
double baseVectorLength = baseCoordinatesVector[1].distance(baseCoordinatesVector[0]);
279279

@@ -315,7 +315,7 @@ private static PdfShading.Axial createAxialShading(Point[] baseCoordinatesVector
315315
actualCoordinates = createCoordinatesForNewDomain(coordinatesDomain, baseCoordinatesVector);
316316
}
317317

318-
return new PdfShading.Axial(
318+
return new PdfAxialShading(
319319
new PdfDeviceCs.Rgb(),
320320
createCoordsPdfArray(actualCoordinates),
321321
new PdfArray(coordinatesDomain),

kernel/src/main/java/com/itextpdf/kernel/pdf/PdfResources.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This file is part of the iText (R) project.
2525
import com.itextpdf.kernel.font.PdfFont;
2626
import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace;
2727
import com.itextpdf.kernel.pdf.colorspace.PdfPattern;
28-
import com.itextpdf.kernel.pdf.colorspace.PdfShading;
28+
import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading;
2929
import com.itextpdf.kernel.pdf.extgstate.PdfExtGState;
3030
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
3131
import com.itextpdf.kernel.pdf.xobject.PdfImageXObject;
@@ -35,7 +35,6 @@ This file is part of the iText (R) project.
3535
import java.util.Map;
3636
import java.util.Set;
3737
import java.util.TreeSet;
38-
import static java.util.Collections.emptySet;
3938

4039
/**
4140
* Wrapper class that represent resource dictionary - that define named resources
@@ -253,12 +252,12 @@ public PdfPattern getPattern(PdfName name) {
253252
}
254253

255254
/**
256-
* Adds {@link PdfShading} object to the resources.
255+
* Adds {@link AbstractPdfShading} object to the resources.
257256
*
258-
* @param shading the {@link PdfShading} to add.
257+
* @param shading the {@link AbstractPdfShading} to add.
259258
* @return added shading resource name.
260259
*/
261-
public PdfName addShading(PdfShading shading) {
260+
public PdfName addShading(AbstractPdfShading shading) {
262261
return addResource(shading, shadingNamesGen);
263262
}
264263

@@ -272,9 +271,9 @@ public PdfName addShading(PdfDictionary shading) {
272271
return addResource(shading, shadingNamesGen);
273272
}
274273

275-
public PdfShading getShading(PdfName name) {
274+
public AbstractPdfShading getShading(PdfName name) {
276275
PdfObject shading = getResourceObject(PdfName.Shading, name);
277-
return shading instanceof PdfDictionary ? PdfShading.makeShading((PdfDictionary) shading) : null;
276+
return shading instanceof PdfDictionary ? AbstractPdfShading.makeShading((PdfDictionary) shading) : null;
278277
}
279278

280279
protected boolean isReadOnly() {

kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/PdfCanvas.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This file is part of the iText (R) project.
6060
import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace;
6161
import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs;
6262
import com.itextpdf.kernel.pdf.colorspace.PdfPattern;
63-
import com.itextpdf.kernel.pdf.colorspace.PdfShading;
63+
import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading;
6464
import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs;
6565
import com.itextpdf.kernel.pdf.extgstate.PdfExtGState;
6666
import com.itextpdf.kernel.pdf.layer.IPdfOCG;
@@ -1280,7 +1280,7 @@ public PdfCanvas circle(double x, double y, double r) {
12801280
* @param shading a shading object to be painted
12811281
* @return current canvas.
12821282
*/
1283-
public PdfCanvas paintShading(PdfShading shading) {
1283+
public PdfCanvas paintShading(AbstractPdfShading shading) {
12841284
PdfName shadingName = resources.addShading(shading);
12851285
contentStream.getOutputStream().write((PdfObject) shadingName).writeSpace().writeBytes(sh);
12861286
return this;

kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfPattern.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This file is part of the iText (R) project.
3131
import com.itextpdf.kernel.pdf.PdfObjectWrapper;
3232
import com.itextpdf.kernel.pdf.PdfResources;
3333
import com.itextpdf.kernel.pdf.PdfStream;
34+
import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading;
3435

3536
/**
3637
* Dictionary wrapper that represent special type of color space, that uses pattern objects
@@ -427,39 +428,39 @@ public Shading(PdfDictionary pdfObject) {
427428
/**
428429
* Creates a new instance of Shading Pattern.
429430
*
430-
* @param shading the {@link PdfShading} that specifies the details of a particular
431+
* @param shading the {@link AbstractPdfShading} that specifies the details of a particular
431432
* gradient fill
432433
*/
433-
public Shading(com.itextpdf.kernel.pdf.colorspace.PdfShading shading) {
434+
public Shading(AbstractPdfShading shading) {
434435
super(new PdfDictionary());
435436
getPdfObject().put(PdfName.Type, PdfName.Pattern);
436437
getPdfObject().put(PdfName.PatternType, new PdfNumber(2));
437438
getPdfObject().put(PdfName.Shading, shading.getPdfObject());
438439
}
439440

440441
/**
441-
* Gets the dictionary of the pattern's {@link PdfShading}.
442+
* Gets the dictionary of the pattern's {@link AbstractPdfShading}.
442443
*
443-
* @return the dictionary of the pattern's {@link PdfShading}
444+
* @return the dictionary of the pattern's {@link AbstractPdfShading}
444445
*/
445446
public PdfDictionary getShading() {
446447
return (PdfDictionary) getPdfObject().get(PdfName.Shading);
447448
}
448449

449450
/**
450-
* Sets the {@link PdfShading} that specifies the details of a particular gradient fill.
451+
* Sets the {@link AbstractPdfShading} that specifies the details of a particular gradient fill.
451452
*
452-
* @param shading the {@link PdfShading} that specifies the details of a particular gradient fill
453+
* @param shading the {@link AbstractPdfShading} that specifies the details of a particular gradient fill
453454
*/
454-
public void setShading(com.itextpdf.kernel.pdf.colorspace.PdfShading shading) {
455+
public void setShading(AbstractPdfShading shading) {
455456
getPdfObject().put(PdfName.Shading, shading.getPdfObject());
456457
setModified();
457458
}
458459

459460
/**
460461
* Sets the dictionary which specifies the details of a particular gradient fill.
461462
*
462-
* @param shading the dictionary of the pattern's {@link PdfShading}
463+
* @param shading the dictionary of the pattern's {@link AbstractPdfShading}
463464
*/
464465
public void setShading(PdfDictionary shading) {
465466
getPdfObject().put(PdfName.Shading, shading);

0 commit comments

Comments
 (0)