Class PDFunction
java.lang.Object
org.apache.pdfbox.pdmodel.common.function.PDFunction
- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDFunctionType0
,PDFunctionType2
,PDFunctionType3
,PDFunctionType4
,PDFunctionTypeIdentity
This class represents a function in a PDF document.
- Author:
- Ben Litchfield
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected float[]
clipToRange
(float[] inputValues) Clip the given input values to the ranges.protected float
clipToRange
(float x, float rangeMin, float rangeMax) Clip the given input value to the given range.static PDFunction
Create the correct PD Model function based on the COS base function.abstract float[]
eval
(float[] input) Evaluates the function at the given input.Deprecated.Returns the stream.getDomainForInput
(int n) This will get the range for a certain input parameter.abstract int
Returns the function type.int
This will get the number of input parameters that have a domain specified.int
This will get the number of output parameters that have a range specified.protected PDStream
Returns the underlying PDStream.getRangeForOutput
(int n) This will get the range for a certain output parameters.protected COSArray
Returns all ranges for the output values as COSArray .protected float
interpolate
(float x, float xRangeMin, float xRangeMax, float yRangeMin, float yRangeMax) For a given value of x, interpolate calculates the y value on the line defined by the two points (xRangeMin , xRangeMax ) and (yRangeMin , yRangeMax ).void
setDomainValues
(COSArray domainValues) This will set the domain values.void
setRangeValues
(COSArray rangeValues) This will set the range values.toString()
-
Constructor Details
-
PDFunction
Constructor.- Parameters:
function
- The function stream.
-
-
Method Details
-
getFunctionType
public abstract int getFunctionType()Returns the function type. Possible values are: 0 - Sampled function 2 - Exponential interpolation function 3 - Stitching function 4 - PostScript calculator function- Returns:
- the function type.
-
getCOSObject
Returns the stream.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The stream for this object.
-
getPDStream
Returns the underlying PDStream.- Returns:
- The stream.
-
create
Create the correct PD Model function based on the COS base function.- Parameters:
function
- The COS function dictionary.- Returns:
- The PDModel Function object, never null.
- Throws:
IOException
- If we are unable to create the PDFunction object.
-
getNumberOfOutputParameters
public int getNumberOfOutputParameters()This will get the number of output parameters that have a range specified. A range for output parameters is optional so this may return zero for a function that does have output parameters, this will simply return the number that have the range specified.- Returns:
- The number of output parameters that have a range specified.
-
getRangeForOutput
This will get the range for a certain output parameters. This is will never return null. If it is not present then the range 0 to 0 will be returned.- Parameters:
n
- The output parameter number to get the range for.- Returns:
- The range for this component.
-
setRangeValues
This will set the range values.- Parameters:
rangeValues
- The new range values.
-
getNumberOfInputParameters
public int getNumberOfInputParameters()This will get the number of input parameters that have a domain specified.- Returns:
- The number of input parameters that have a domain specified.
-
getDomainForInput
This will get the range for a certain input parameter. This is will never return null. If it is not present then the range 0 to 0 will be returned.- Parameters:
n
- The parameter number to get the domain for.- Returns:
- The domain range for this component.
-
setDomainValues
This will set the domain values.- Parameters:
domainValues
- The new domain values.
-
eval
Deprecated.Replaced byeval(float[] input)
- Parameters:
input
- The array of input values for the function.- Returns:
- The of outputs the function returns based on those inputs.
- Throws:
IOException
- if something went wrong.
-
eval
Evaluates the function at the given input. ReturnValue = f(input)- Parameters:
input
- The array of input values for the function. In many cases will be an array of a single value, but not always.- Returns:
- The of outputs the function returns based on those inputs. In many cases will be an array of a single value, but not always.
- Throws:
IOException
- if something went wrong processing the function.
-
getRangeValues
Returns all ranges for the output values as COSArray . Required for type 0 and type 4 functions- Returns:
- the ranges array.
-
clipToRange
protected float[] clipToRange(float[] inputValues) Clip the given input values to the ranges.- Parameters:
inputValues
- the input values- Returns:
- the clipped values
-
clipToRange
protected float clipToRange(float x, float rangeMin, float rangeMax) Clip the given input value to the given range.- Parameters:
x
- the input valuerangeMin
- the min value of the rangerangeMax
- the max value of the range- Returns:
- the clipped value
-
interpolate
protected float interpolate(float x, float xRangeMin, float xRangeMax, float yRangeMin, float yRangeMax) For a given value of x, interpolate calculates the y value on the line defined by the two points (xRangeMin , xRangeMax ) and (yRangeMin , yRangeMax ).- Parameters:
x
- the to be interpolated value.xRangeMin
- the min value of the x rangexRangeMax
- the max value of the x rangeyRangeMin
- the min value of the y rangeyRangeMax
- the max value of the y range- Returns:
- the interpolated y value
-
toString
-
eval(float[] input)