Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.graphics.shading

public abstract Class PDShading

extends Object
implements COSObjectable
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.common.COSObjectable
Known Direct Subclasses
org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType1, org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType2, org.apache.pdfbox.pdmodel.graphics.shading.PDTriangleBasedShadingType
Imports
java.awt.Paint, java.awt.geom.AffineTransform, .Rectangle2D, java.io.IOException, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSName, org.apache.pdfbox.pdmodel.common.COSObjectable, .PDRectangle, org.apache.pdfbox.pdmodel.common.function.PDFunction, org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace, org.apache.pdfbox.util.Matrix

A Shading Resource.

Field Summary

Modifier and TypeField and Description
private COSArray
private PDRectangle
private PDColorSpace
private final COSDictionary
private PDFunction
private PDFunction[]
public static final int
SHADING_TYPE1

shading type 1 = function based shading.

public static final int
SHADING_TYPE2

shading type 2 = axial shading.

public static final int
SHADING_TYPE3

shading type 3 = radial shading.

public static final int
SHADING_TYPE4

shading type 4 = Free-Form Gouraud-Shaded Triangle Meshes.

public static final int
SHADING_TYPE5

shading type 5 = Lattice-Form Gouraud-Shaded Triangle Meshes.

public static final int
SHADING_TYPE6

shading type 6 = Coons Patch Meshes.

public static final int
SHADING_TYPE7

shading type 7 = Tensor-Product Patch Meshes.

Constructor Summary

AccessConstructor and Description
public
PDShading()

Default constructor.

public
PDShading(COSDictionary
the dictionary for this shading
shadingDictionary
)

Constructor using the given shading dictionary.

Method Summary

Modifier and TypeMethod and Description
public static PDShading

Returns:

the newly created shading resources object
create
(COSDictionary
the COS shading dictionary
shadingDictionary
)

Create the correct PD Model shading based on the COS base shading.

public float[]

Returns:

the output values
evalFunction
(float
the input value
inputValue
)

Convert the input value using the functions of the shading dictionary.

public float[]

Returns:

the output values
evalFunction
(float[]
the input values
input
)

Convert the input values using the functions of the shading dictionary.

public boolean

Returns:

the AntiAlias value
getAntiAlias
()

This will return the AntiAlias value.

public COSArray

Returns:

the background
getBackground
()

This will return the background.

public PDRectangle

Returns:

the BBox of the form
getBBox
()

An array of four numbers in the form coordinate system (see below), giving the coordinates of the left, bottom, right, and top edges, respectively, of the shading's bounding box.

public Rectangle2D

Returns:

Bounding rectangle or null, if not supported by this shading type.
getBounds
(AffineTransform
the affine transformation
xform
,
Matrix
the pattern matrix
matrix
)

Calculate a bounding rectangle around the areas of this shading context.

public PDColorSpace

Returns:

the color space for the shading
getColorSpace
()

This will get the color space or null if none exists.

public COSDictionary

Returns:

the dictionary for this shading.
getCOSObject
()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

This will get the underlying dictionary.

public PDFunction

Returns:

the function
getFunction
()

This will return the function used to convert the color values.

private PDFunction[]

Returns:

an array containing the function(s).
getFunctionsArray
()

Provide the function(s) of the shading dictionary as array.

public abstract int

Returns:

the shading typ
getShadingType
()

This will return the shading type.

public String

Returns:

the type of object that this is
getType
()

This will return the type.

public void
setAntiAlias(boolean
the new AntiAlias value
antiAlias
)

This will set the AntiAlias value.

public void
setBackground(COSArray
the new background
newBackground
)

This will set the background.

public void
setBBox(PDRectangle
the new BBox
newBBox
)

This will set the BBox (bounding box) for this Shading.

public void
setColorSpace(PDColorSpace
the color space
colorSpace
)

This will set the color space for the shading.

public void
setFunction(PDFunction
the new function
newFunction
)

This will set the function for the color conversion.

public void
setFunction(COSArray
the new COSArray containing all functions
newFunctions
)

This will set the functions COSArray for the color conversion.

public void
setShadingType(int
the new shading type
shadingType
)

This will set the shading type.

public abstract Paint

Returns:

an AWT Paint instance
toPaint
(Matrix
the pattern matrix concatenated with that of the parent content stream, this matrix which maps the pattern's internal coordinate system to user space
matrix
)

Returns an AWT paint which corresponds to this shading

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backgroundback to summary
private COSArray background
bBoxback to summary
private PDRectangle bBox
colorSpaceback to summary
private PDColorSpace colorSpace
dictionaryback to summary
private final COSDictionary dictionary
functionback to summary
private PDFunction function
functionArrayback to summary
private PDFunction[] functionArray
SHADING_TYPE1back to summary
public static final int SHADING_TYPE1

shading type 1 = function based shading.

SHADING_TYPE2back to summary
public static final int SHADING_TYPE2

shading type 2 = axial shading.

SHADING_TYPE3back to summary
public static final int SHADING_TYPE3

shading type 3 = radial shading.

SHADING_TYPE4back to summary
public static final int SHADING_TYPE4

shading type 4 = Free-Form Gouraud-Shaded Triangle Meshes.

SHADING_TYPE5back to summary
public static final int SHADING_TYPE5

shading type 5 = Lattice-Form Gouraud-Shaded Triangle Meshes.

SHADING_TYPE6back to summary
public static final int SHADING_TYPE6

shading type 6 = Coons Patch Meshes.

SHADING_TYPE7back to summary
public static final int SHADING_TYPE7

shading type 7 = Tensor-Product Patch Meshes.

Constructor Detail

PDShadingback to summary
public PDShading()

Default constructor.

PDShadingback to summary
public PDShading(COSDictionary shadingDictionary)

Constructor using the given shading dictionary.

Parameters
shadingDictionary:COSDictionary

the dictionary for this shading

Method Detail

createback to summary
public static PDShading create(COSDictionary shadingDictionary) throws IOException

Create the correct PD Model shading based on the COS base shading.

Parameters
shadingDictionary:COSDictionary

the COS shading dictionary

Returns:PDShading

the newly created shading resources object

Exceptions
IOException:
if we are unable to create the PDShading object
evalFunctionback to summary
public float[] evalFunction(float inputValue) throws IOException

Convert the input value using the functions of the shading dictionary.

Parameters
inputValue:float

the input value

Returns:float[]

the output values

Exceptions
IOException:
thrown if something went wrong
evalFunctionback to summary
public float[] evalFunction(float[] input) throws IOException

Convert the input values using the functions of the shading dictionary.

Parameters
input:float[]

the input values

Returns:float[]

the output values

Exceptions
IOException:
thrown if something went wrong
getAntiAliasback to summary
public boolean getAntiAlias()

This will return the AntiAlias value.

Returns:boolean

the AntiAlias value

getBackgroundback to summary
public COSArray getBackground()

This will return the background.

Returns:COSArray

the background

getBBoxback to summary
public PDRectangle getBBox()

An array of four numbers in the form coordinate system (see below), giving the coordinates of the left, bottom, right, and top edges, respectively, of the shading's bounding box.

Returns:PDRectangle

the BBox of the form

getBoundsback to summary
public Rectangle2D getBounds(AffineTransform xform, Matrix matrix) throws IOException

Calculate a bounding rectangle around the areas of this shading context.

Parameters
xform:AffineTransform

the affine transformation

matrix:Matrix

the pattern matrix

Returns:Rectangle2D

Bounding rectangle or null, if not supported by this shading type.

Exceptions
IOException:
if the bounds could not be created
getColorSpaceback to summary
public PDColorSpace getColorSpace() throws IOException

This will get the color space or null if none exists.

Returns:PDColorSpace

the color space for the shading

Exceptions
IOException:
if there is an error getting the color space
getCOSObjectback to summary
public COSDictionary getCOSObject()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

This will get the underlying dictionary.

Returns:COSDictionary

the dictionary for this shading.

Annotations
@Override
getFunctionback to summary
public PDFunction getFunction() throws IOException

This will return the function used to convert the color values.

Returns:PDFunction

the function

Exceptions
IOException:
if we were not able to create the function.
getFunctionsArrayback to summary
private PDFunction[] getFunctionsArray() throws IOException

Provide the function(s) of the shading dictionary as array.

Returns:PDFunction[]

an array containing the function(s).

Exceptions
IOException:
if we were unable to create a function.
getShadingTypeback to summary
public abstract int getShadingType()

This will return the shading type.

Returns:int

the shading typ

getTypeback to summary
public String getType()

This will return the type.

Returns:String

the type of object that this is

setAntiAliasback to summary
public void setAntiAlias(boolean antiAlias)

This will set the AntiAlias value.

Parameters
antiAlias:boolean

the new AntiAlias value

setBackgroundback to summary
public void setBackground(COSArray newBackground)

This will set the background.

Parameters
newBackground:COSArray

the new background

setBBoxback to summary
public void setBBox(PDRectangle newBBox)

This will set the BBox (bounding box) for this Shading.

Parameters
newBBox:PDRectangle

the new BBox

setColorSpaceback to summary
public void setColorSpace(PDColorSpace colorSpace)

This will set the color space for the shading.

Parameters
colorSpace:PDColorSpace

the color space

setFunctionback to summary
public void setFunction(PDFunction newFunction)

This will set the function for the color conversion.

Parameters
newFunction:PDFunction

the new function

setFunctionback to summary
public void setFunction(COSArray newFunctions)

This will set the functions COSArray for the color conversion.

Parameters
newFunctions:COSArray

the new COSArray containing all functions

setShadingTypeback to summary
public void setShadingType(int shadingType)

This will set the shading type.

Parameters
shadingType:int

the new shading type

toPaintback to summary
public abstract Paint toPaint(Matrix matrix)

Returns an AWT paint which corresponds to this shading

Parameters
matrix:Matrix

the pattern matrix concatenated with that of the parent content stream, this matrix which maps the pattern's internal coordinate system to user space

Returns:Paint

an AWT Paint instance