public abstract class PDFFunction
extends java.lang.Object
PDF Functions are defined in the reference as Section 3.9.
A PDF function maps some set of m inputs into some set of n outputs. There are 4 types of functions:
The function interface contains a single method, calculate which takes an array of m floats an interprets them into an array of n floats.
PDFFunctions do not have accessible constructors. Instead, use the static getFunction() method to read a functions from a PDF Object.
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_0
Sampled function
|
static int |
TYPE_2
Exponential interpolation function
|
static int |
TYPE_3
Stitching function.
|
static int |
TYPE_4
PostScript calculator function.
|
Modifier | Constructor and Description |
---|---|
protected |
PDFFunction(int type)
Creates a new instance of PDFFunction
|
Modifier and Type | Method and Description |
---|---|
float[] |
calculate(float[] inputs)
Map from m input values to n output values.
|
float[] |
calculate(float[] inputs,
int inputOffset,
float[] outputs,
int outputOffset)
Map from m input values to n output values.
|
protected abstract void |
doFunction(float[] inputs,
int inputOffset,
float[] outputs,
int outputOffset)
Subclasses must implement this method to perform the actual function
on the given set of data.
|
protected float |
getDomain(int i)
Get a component of the domain of this function
|
static PDFFunction |
getFunction(PDFObject obj)
Get a PDFFunction from a PDFObject
|
int |
getNumInputs()
Get the number of inputs, m, required by this function
|
int |
getNumOutputs()
Get the number of outputs, n, returned by this function
|
protected float |
getRange(int i)
Get a component of the range of this function
|
int |
getType()
Get the type of this function
|
protected abstract void |
parse(PDFObject obj)
Read the function information from a PDF Object
|
protected void |
setDomain(float[] domain)
Set the domain of this function
|
protected void |
setRange(float[] range)
Set the range of this function
|
public static final int TYPE_0
public static final int TYPE_2
public static final int TYPE_3
public static final int TYPE_4
protected PDFFunction(int type)
public static PDFFunction getFunction(PDFObject obj) throws java.io.IOException
java.io.IOException
public int getType()
public int getNumInputs()
public int getNumOutputs()
protected float getDomain(int i)
i
- the index into the domain array, which has size 2 * m.
the ith entry in the array has index 2i,
2i + 1protected void setDomain(float[] domain)
protected float getRange(int i)
i
- the index into the range array, which has size 2 * n.
the ith entry in the array has index 2i,
2i + 1protected void setRange(float[] range)
public float[] calculate(float[] inputs)
inputs
- an array of >= m input valuespublic float[] calculate(float[] inputs, int inputOffset, float[] outputs, int outputOffset)
inputs
- an array of >= m input valuesinputOffset
- the offset into the input array to read fromoutputs
- an array of size >= n which will be filled
with the output valuesoutputOffset
- the offset into the output array to write toprotected abstract void doFunction(float[] inputs, int inputOffset, float[] outputs, int outputOffset)
inputs
- guaranteed to be at least as big as
getNumInputs()
and all values within rangeinputOffset
- the offset into the inputs array to read fromoutputs
- guaranteed to be at least as big as
getNumOutputs()
, but not yet clipped to domainoutputOffset
- the offset into the output array to write toprotected abstract void parse(PDFObject obj) throws java.io.IOException
java.io.IOException