Class PDShading
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.graphics.shading.PDShading
-
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDShadingType1,PDShadingType2,PDShadingType4,PDShadingType5
public abstract class PDShading extends Object implements COSObjectable
A Shading Resource.
-
-
Field Summary
Fields Modifier and Type Field Description static intSHADING_TYPE1shading type 1 = function based shading.static intSHADING_TYPE2shading type 2 = axial shading.static intSHADING_TYPE3shading type 3 = radial shading.static intSHADING_TYPE4shading type 4 = Free-Form Gouraud-Shaded Triangle Meshes.static intSHADING_TYPE5shading type 5 = Lattice-Form Gouraud-Shaded Triangle Meshes.static intSHADING_TYPE6shading type 6 = Coons Patch Meshes.static intSHADING_TYPE7shading type 7 = Tensor-Product Patch Meshes.
-
Constructor Summary
Constructors Constructor Description PDShading()Default constructor.PDShading(COSDictionary shadingDictionary)Constructor using the given shading dictionary.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static PDShadingcreate(COSDictionary shadingDictionary)Create the correct PD Model shading based on the COS base shading.float[]evalFunction(float inputValue)Convert the input value using the functions of the shading dictionary.float[]evalFunction(float[] input)Convert the input values using the functions of the shading dictionary.booleangetAntiAlias()This will return the AntiAlias value.COSArraygetBackground()This will return the background.PDRectanglegetBBox()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.RectFgetBounds(AffineTransform xform, Matrix matrix)Calculate a bounding rectangle around the areas of this shading context.PDColorSpacegetColorSpace()This will get the color space or null if none exists.COSDictionarygetCOSObject()This will get the underlying dictionary.PDFunctiongetFunction()This will return the function used to convert the color values.abstract intgetShadingType()This will return the shading type.StringgetType()This will return the type.voidsetAntiAlias(boolean antiAlias)This will set the AntiAlias value.voidsetBackground(COSArray newBackground)This will set the background.voidsetBBox(PDRectangle newBBox)This will set the BBox (bounding box) for this Shading.voidsetColorSpace(PDColorSpace colorSpace)This will set the color space for the shading.voidsetFunction(COSArray newFunctions)This will set the functions COSArray for the color conversion.voidsetFunction(PDFunction newFunction)This will set the function for the color conversion.voidsetShadingType(int shadingType)This will set the shading type.
-
-
-
Field Detail
-
SHADING_TYPE1
public static final int SHADING_TYPE1
shading type 1 = function based shading.- See Also:
- Constant Field Values
-
SHADING_TYPE2
public static final int SHADING_TYPE2
shading type 2 = axial shading.- See Also:
- Constant Field Values
-
SHADING_TYPE3
public static final int SHADING_TYPE3
shading type 3 = radial shading.- See Also:
- Constant Field Values
-
SHADING_TYPE4
public static final int SHADING_TYPE4
shading type 4 = Free-Form Gouraud-Shaded Triangle Meshes.- See Also:
- Constant Field Values
-
SHADING_TYPE5
public static final int SHADING_TYPE5
shading type 5 = Lattice-Form Gouraud-Shaded Triangle Meshes.- See Also:
- Constant Field Values
-
SHADING_TYPE6
public static final int SHADING_TYPE6
shading type 6 = Coons Patch Meshes.- See Also:
- Constant Field Values
-
SHADING_TYPE7
public static final int SHADING_TYPE7
shading type 7 = Tensor-Product Patch Meshes.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PDShading
public PDShading()
Default constructor.
-
PDShading
public PDShading(COSDictionary shadingDictionary)
Constructor using the given shading dictionary.- Parameters:
shadingDictionary- the dictionary for this shading
-
-
Method Detail
-
getCOSObject
public COSDictionary getCOSObject()
This will get the underlying dictionary.- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- the dictionary for this shading.
-
getType
public String getType()
This will return the type.- Returns:
- the type of object that this is
-
setShadingType
public void setShadingType(int shadingType)
This will set the shading type.- Parameters:
shadingType- the new shading type
-
getShadingType
public abstract int getShadingType()
This will return the shading type.- Returns:
- the shading typ
-
setBackground
public void setBackground(COSArray newBackground)
This will set the background.- Parameters:
newBackground- the new background
-
getBackground
public COSArray getBackground()
This will return the background.- Returns:
- the background
-
getBBox
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:
- the BBox of the form
-
setBBox
public void setBBox(PDRectangle newBBox)
This will set the BBox (bounding box) for this Shading.- Parameters:
newBBox- the new BBox
-
getBounds
public RectF getBounds(AffineTransform xform, Matrix matrix) throws IOException
Calculate a bounding rectangle around the areas of this shading context.- Parameters:
xform-matrix-- Returns:
- Bounding rectangle or null, if not supported by this shading type.
- Throws:
IOException
-
setAntiAlias
public void setAntiAlias(boolean antiAlias)
This will set the AntiAlias value.- Parameters:
antiAlias- the new AntiAlias value
-
getAntiAlias
public boolean getAntiAlias()
This will return the AntiAlias value.- Returns:
- the AntiAlias value
-
getColorSpace
public PDColorSpace getColorSpace() throws IOException
This will get the color space or null if none exists.- Returns:
- the color space for the shading
- Throws:
IOException- if there is an error getting the color space
-
setColorSpace
public void setColorSpace(PDColorSpace colorSpace)
This will set the color space for the shading.- Parameters:
colorSpace- the color space
-
create
public static PDShading create(COSDictionary shadingDictionary) throws IOException
Create the correct PD Model shading based on the COS base shading.- Parameters:
shadingDictionary- the COS shading dictionary- Returns:
- the newly created shading resources object
- Throws:
IOException- if we are unable to create the PDShading object
-
setFunction
public void setFunction(PDFunction newFunction)
This will set the function for the color conversion.- Parameters:
newFunction- the new function
-
setFunction
public void setFunction(COSArray newFunctions)
This will set the functions COSArray for the color conversion.- Parameters:
newFunctions- the new COSArray containing all functions
-
getFunction
public PDFunction getFunction() throws IOException
This will return the function used to convert the color values.- Returns:
- the function
- Throws:
IOException- if we were not able to create the function.
-
evalFunction
public float[] evalFunction(float inputValue) throws IOExceptionConvert the input value using the functions of the shading dictionary.- Parameters:
inputValue- the input value- Returns:
- the output values
- Throws:
IOException- thrown if something went wrong
-
evalFunction
public float[] evalFunction(float[] input) throws IOExceptionConvert the input values using the functions of the shading dictionary.- Parameters:
input- the input values- Returns:
- the output values
- Throws:
IOException- thrown if something went wrong
-
-