Class PdfShading
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.colorspace.PdfShading
-
- Direct Known Subclasses:
PdfShading.Axial
,PdfShading.CoonsPatchMesh
,PdfShading.FreeFormGouraudShadedTriangleMesh
,PdfShading.FunctionBased
,PdfShading.LatticeFormGouraudShadedTriangleMesh
,PdfShading.Radial
,PdfShading.TensorProductPatchMesh
public abstract class PdfShading extends PdfObjectWrapper<PdfDictionary>
The abstract PdfShading class that represents the Shading Dictionary PDF object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PdfShading.Axial
The class that extendsPdfShading
class and is in charge of Shading Dictionary with axial type, that define a colour blend that varies along a linear axis between two endpoints and extends indefinitely perpendicular to that axis.static class
PdfShading.CoonsPatchMesh
The class that extendsPdfShading
class and is in charge of Shading Dictionary with Coons Patch mesh type.static class
PdfShading.FreeFormGouraudShadedTriangleMesh
The class that extendsPdfShading
class and is in charge of Shading Dictionary with free-form Gouraud-shaded triangle mesh type.static class
PdfShading.FunctionBased
The class that extendsPdfShading
class and is in charge of Shading Dictionary with function-based type, that defines color at every point in the domain by a specified mathematical function.static class
PdfShading.LatticeFormGouraudShadedTriangleMesh
The class that extendsPdfShading
class and is in charge of Shading Dictionary with lattice-form Gouraud-shaded triangle mesh type.static class
PdfShading.Radial
The class that extendsPdfShading
class and is in charge of Shading Dictionary with radial type, that define a colour blend that varies between two circles.(package private) static class
PdfShading.ShadingType
constants of shading type (see ISO-320001 Table 78)static class
PdfShading.TensorProductPatchMesh
The class that extendsPdfShading
class and is in charge of Shading Dictionary with Tensor-Product Patch mesh type.
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdfShading(PdfDictionary pdfObject)
Creates thePdfShading
object from the existingPdfDictionary
.protected
PdfShading(PdfDictionary pdfObject, int type, PdfColorSpace colorSpace)
Creates thePdfShading
object from the existingPdfDictionary
, using provided type and colorspace.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e.PdfObject
getColorSpace()
Gets the color space in which colour values shall be expressed.PdfObject
getFunction()
Gets the function PdfObject that represents color transitions across the shading geometry.int
getShadingType()
Gets the shading type.protected boolean
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.static PdfShading
makeShading(PdfDictionary shadingDictionary)
Creates thePdfShading
object from the existingPdfDictionary
with corresponding type.void
setFunction(IPdfFunction function)
Sets the function that represents color transitions across the shading geometry as one object.void
setFunction(IPdfFunction[] functions)
Sets the function object that represents color transitions across the shading geometry as an array of functions.-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
-
-
-
Constructor Detail
-
PdfShading
protected PdfShading(PdfDictionary pdfObject)
Creates thePdfShading
object from the existingPdfDictionary
.- Parameters:
pdfObject
-PdfDictionary
from which thePdfShading
object will be created.
-
PdfShading
protected PdfShading(PdfDictionary pdfObject, int type, PdfColorSpace colorSpace)
Creates thePdfShading
object from the existingPdfDictionary
, using provided type and colorspace.- Parameters:
pdfObject
-PdfDictionary
from which thePdfShading
object will be created.type
- type with which thisPdfShading
object will be created.colorSpace
-PdfColorSpace
with which thisPdfShading
object will be created.
-
-
Method Detail
-
makeShading
public static PdfShading makeShading(PdfDictionary shadingDictionary)
Creates thePdfShading
object from the existingPdfDictionary
with corresponding type.- Parameters:
shadingDictionary
-PdfDictionary
from which thePdfShading
object will be created.- Returns:
- Created
PdfShading
object.
-
getShadingType
public int getShadingType()
Gets the shading type.- Returns:
- int value of
PdfName.ShadingType
.
-
getColorSpace
public PdfObject getColorSpace()
Gets the color space in which colour values shall be expressed.- Returns:
PdfObject
Color space
-
getFunction
public PdfObject getFunction()
Gets the function PdfObject that represents color transitions across the shading geometry.- Returns:
PdfObject
Function
-
setFunction
public void setFunction(IPdfFunction function)
Sets the function that represents color transitions across the shading geometry as one object.- Parameters:
function
- TheIPdfFunction
to set.
-
setFunction
public void setFunction(IPdfFunction[] functions)
Sets the function object that represents color transitions across the shading geometry as an array of functions.- Parameters:
functions
- The array ofIPdfFunction
to be set.
-
flush
public void flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e. it has an indirect reference. Basically this means that before flushing you need to explicitly callPdfObjectWrapper.makeIndirect(PdfDocument)
. For example: wrapperInstance.makeIndirect(document).flush(); Note that not every wrapper require this, only those that have such warning in documentation.- Overrides:
flush
in classPdfObjectWrapper<PdfDictionary>
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
-