Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.common.function

public abstract Class PDFunction

extends Object
implements COSObjectable
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.common.COSObjectable
Known Direct Subclasses
org.apache.pdfbox.pdmodel.common.function.PDFunctionType0, org.apache.pdfbox.pdmodel.common.function.PDFunctionType2, org.apache.pdfbox.pdmodel.common.function.PDFunctionType3, org.apache.pdfbox.pdmodel.common.function.PDFunctionType4, org.apache.pdfbox.pdmodel.common.function.PDFunctionTypeIdentity
Imports
java.io.IOException, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSName, .COSObject, .COSStream, org.apache.pdfbox.pdmodel.common.COSObjectable, .PDRange, .PDStream

This class represents a function in a PDF document.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
private COSArray
private COSDictionary
private PDStream
private int
private int
private COSArray

Constructor Summary

AccessConstructor and Description
public
PDFunction(COSBase
The function stream.
function
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
protected float[]

Returns:

the clipped values
clipToRange
(float[]
the input values
inputValues
)

Clip the given input values to the ranges.

protected float

Returns:

the clipped value
clipToRange
(float
the input value
x
,
float
the min value of the range
rangeMin
,
float
the max value of the range
rangeMax
)

Clip the given input value to the given range.

public static PDFunction

Returns:

The PDModel Function object, never null.
create
(COSBase
The COS function dictionary.
function
)

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

public abstract float[]

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.
eval
(float[]
The array of input values for the function. In many cases will be an array of a single value, but not always.
input
)

Evaluates the function at the given input.

public final COSDictionary

Returns:

The stream for this object.
getCOSObject
()

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

Returns the stream.

public PDRange

Returns:

The domain range for this component.
getDomainForInput
(int
The parameter number to get the domain for.
n
)

This will get the range for a certain input parameter.

private COSArray

Returns:

the domains array.
getDomainValues
()

Returns all domains for the input values as COSArray.

public abstract int

Returns:

the function type.
getFunctionType
()

Returns the function type.

public int

Returns:

The number of input parameters that have a domain specified.
getNumberOfInputParameters
()

This will get the number of input parameters that have a domain specified.

public int

Returns:

The number of output parameters that have a range specified.
getNumberOfOutputParameters
()

This will get the number of output parameters that have a range specified.

protected PDStream

Returns:

The stream.
getPDStream
()

Returns the underlying PDStream.

public PDRange

Returns:

The range for this component.
getRangeForOutput
(int
The output parameter number to get the range for.
n
)

This will get the range for a certain output parameters.

protected COSArray

Returns:

the ranges array.
getRangeValues
()

Returns all ranges for the output values as COSArray .

protected float

Returns:

the interpolated y value
interpolate
(float
the to be interpolated value.
x
,
float
the min value of the x range
xRangeMin
,
float
the max value of the x range
xRangeMax
,
float
the min value of the y range
yRangeMin
,
float
the max value of the y range
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 ).

public void
setDomainValues(COSArray
The new domain values.
domainValues
)

This will set the domain values.

public void
setRangeValues(COSArray
The new range values.
rangeValues
)

This will set the range values.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

domainback to summary
private COSArray domain
functionDictionaryback to summary
private COSDictionary functionDictionary
functionStreamback to summary
private PDStream functionStream
numberOfInputValuesback to summary
private int numberOfInputValues
numberOfOutputValuesback to summary
private int numberOfOutputValues
rangeback to summary
private COSArray range

Constructor Detail

PDFunctionback to summary
public PDFunction(COSBase function)

Constructor.

Parameters
function:COSBase

The function stream.

Method Detail

clipToRangeback to summary
protected float[] clipToRange(float[] inputValues)

Clip the given input values to the ranges.

Parameters
inputValues:float[]

the input values

Returns:float[]

the clipped values

clipToRangeback to summary
protected float clipToRange(float x, float rangeMin, float rangeMax)

Clip the given input value to the given range.

Parameters
x:float

the input value

rangeMin:float

the min value of the range

rangeMax:float

the max value of the range

Returns:float

the clipped value

createback to summary
public static PDFunction create(COSBase function) throws IOException

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

Parameters
function:COSBase

The COS function dictionary.

Returns:PDFunction

The PDModel Function object, never null.

Exceptions
IOException:
If we are unable to create the PDFunction object.
evalback to summary
public abstract float[] eval(float[] input) throws IOException

Evaluates the function at the given input. ReturnValue = f(input)

Parameters
input:float[]

The array of input values for the function. In many cases will be an array of a single value, but not always.

Returns:float[]

The of outputs the function returns based on those inputs. In many cases will be an array of a single value, but not always.

Exceptions
IOException:
if something went wrong processing the function.
getCOSObjectback to summary
public final COSDictionary getCOSObject()

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

Returns the stream.

Returns:COSDictionary

The stream for this object.

Annotations
@Override
getDomainForInputback to summary
public PDRange getDomainForInput(int n)

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:int

The parameter number to get the domain for.

Returns:PDRange

The domain range for this component.

getDomainValuesback to summary
private COSArray getDomainValues()

Returns all domains for the input values as COSArray. Required for all function types.

Returns:COSArray

the domains array.

getFunctionTypeback to summary
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:int

the function type.

getNumberOfInputParametersback to summary
public int getNumberOfInputParameters()

This will get the number of input parameters that have a domain specified.

Returns:int

The number of input parameters that have a domain specified.

getNumberOfOutputParametersback to summary
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:int

The number of output parameters that have a range specified.

getPDStreamback to summary
protected PDStream getPDStream()

Returns the underlying PDStream.

Returns:PDStream

The stream.

getRangeForOutputback to summary
public PDRange getRangeForOutput(int n)

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:int

The output parameter number to get the range for.

Returns:PDRange

The range for this component.

getRangeValuesback to summary
protected COSArray getRangeValues()

Returns all ranges for the output values as COSArray . Required for type 0 and type 4 functions

Returns:COSArray

the ranges array.

interpolateback to summary
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:float

the to be interpolated value.

xRangeMin:float

the min value of the x range

xRangeMax:float

the max value of the x range

yRangeMin:float

the min value of the y range

yRangeMax:float

the max value of the y range

Returns:float

the interpolated y value

setDomainValuesback to summary
public void setDomainValues(COSArray domainValues)

This will set the domain values.

Parameters
domainValues:COSArray

The new domain values.

setRangeValuesback to summary
public void setRangeValues(COSArray rangeValues)

This will set the range values.

Parameters
rangeValues:COSArray

The new range values.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override