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

public Class PDFunctionType0

extends PDFunction
Class Inheritance
Imports
java.io.IOException, .InputStream, javax.imageio.stream.ImageInputStream, .MemoryCacheImageInputStream, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSBase, .COSInteger, .COSName, org.apache.pdfbox.pdmodel.common.PDRange

This class represents a type 0 function in a PDF document.
Authors
Ben Litchfield, Tilman Hausherr

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
PDFunctionType0.Rinterpol

Inner class do to an interpolation in the Nth dimension by comparing the content size of N-1 dimensional objects.

Field Summary

Modifier and TypeField and Description
private COSArray
decode

An array of 2 x n numbers specifying the linear mapping of sample values into the range appropriate for the function's output values.

private COSArray
encode

An array of 2 x m numbers specifying the linear mapping of input values into the domain of the function's sample table.

private static final Log
LOG

Log instance.

private int[][]
samples

The samples of the function.

private COSArray
size

An array of m positive integers specifying the number of samples in each input dimension of the sample table.

Constructor Summary

AccessConstructor and Description
public
PDFunctionType0(COSBase
The function.
function
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public float[]
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
)

Implements abstract org.apache.pdfbox.pdmodel.common.function.PDFunction.eval.

Evaluates the function at the given input.

public int

Returns:

Number of bits for each output value.
getBitsPerSample
()

Get the number of bits that the output value will take up.

public PDRange

Returns:

The decode parameter range or null if none is set.
getDecodeForParameter
(int
The function parameter number.
paramNum
)

Get the decode for the input parameter.

private COSArray

Returns:

the decode array.
getDecodeValues
()

Returns all decode values as COSArray.

public PDRange

Returns:

The encode parameter range or null if none is set.
getEncodeForParameter
(int
The function parameter number.
paramNum
)

Get the encode for the input parameter.

private COSArray

Returns:

the encode array.
getEncodeValues
()

Returns all encode values as COSArray.

public int
public int

Returns:

order of interpolation.
getOrder
()

Get the order of interpolation between samples.

public COSArray

Returns:

A List of java.lang.Integer objects.
getSize
()

The "Size" entry, which is the number of samples in each input dimension of the sample table.

public void
setBitsPerSample(int
The number of bits for each output value.
bps
)

Set the number of bits that the output value will take up.

public void
setDecodeValues(COSArray
The new decode values.
decodeValues
)

This will set the decode values.

public void
setEncodeValues(COSArray
The new encode values.
encodeValues
)

This will set the encode values.

Inherited from org.apache.pdfbox.pdmodel.common.function.PDFunction:
clipToRangeclipToRangecreategetCOSObjectgetDomainForInputgetNumberOfInputParametersgetNumberOfOutputParametersgetPDStreamgetRangeForOutputgetRangeValuesinterpolatesetDomainValuessetRangeValuestoString

Field Detail

decodeback to summary
private COSArray decode

An array of 2 x n numbers specifying the linear mapping of sample values into the range appropriate for the function's output values. Default value: same as the value of Range

encodeback to summary
private COSArray encode

An array of 2 x m numbers specifying the linear mapping of input values into the domain of the function's sample table. Default value: [ 0 (Size0 - 1) 0 (Size1 - 1) ...].

LOGback to summary
private static final Log LOG

Log instance.

samplesback to summary
private int[][] samples

The samples of the function.

sizeback to summary
private COSArray size

An array of m positive integers specifying the number of samples in each input dimension of the sample table.

Constructor Detail

PDFunctionType0back to summary
public PDFunctionType0(COSBase function)

Constructor.

Parameters
function:COSBase

The function.

Method Detail

evalback to summary
public float[] eval(float[] input) throws IOException

Implements abstract org.apache.pdfbox.pdmodel.common.function.PDFunction.eval.

Doc from org.apache.pdfbox.pdmodel.common.function.PDFunction.eval.

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.

Annotations
@Override
Exceptions
IOException:
if something went wrong processing the function.
getBitsPerSampleback to summary
public int getBitsPerSample()

Get the number of bits that the output value will take up. Valid values are 1,2,4,8,12,16,24,32.

Returns:int

Number of bits for each output value.

getDecodeForParameterback to summary
public PDRange getDecodeForParameter(int paramNum)

Get the decode for the input parameter.

Parameters
paramNum:int

The function parameter number.

Returns:PDRange

The decode parameter range or null if none is set.

getDecodeValuesback to summary
private COSArray getDecodeValues()

Returns all decode values as COSArray.

Returns:COSArray

the decode array.

getEncodeForParameterback to summary
public PDRange getEncodeForParameter(int paramNum)

Get the encode for the input parameter.

Parameters
paramNum:int

The function parameter number.

Returns:PDRange

The encode parameter range or null if none is set.

getEncodeValuesback to summary
private COSArray getEncodeValues()

Returns all encode values as COSArray.

Returns:COSArray

the encode array.

getFunctionTypeback to summary
public int getFunctionType()

Implements abstract org.apache.pdfbox.pdmodel.common.function.PDFunction.getFunctionType.

Doc from org.apache.pdfbox.pdmodel.common.function.PDFunction.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.

Annotations
@Override
getOrderback to summary
public int getOrder()

Get the order of interpolation between samples. Valid values are 1 and 3, specifying linear and cubic spline interpolation, respectively. Default is 1. See p.170 in PDF spec 1.7.

Returns:int

order of interpolation.

getSizeback to summary
public COSArray getSize()

The "Size" entry, which is the number of samples in each input dimension of the sample table.

Returns:COSArray

A List of java.lang.Integer objects.

setBitsPerSampleback to summary
public void setBitsPerSample(int bps)

Set the number of bits that the output value will take up. Valid values are 1,2,4,8,12,16,24,32.

Parameters
bps:int

The number of bits for each output value.

setDecodeValuesback to summary
public void setDecodeValues(COSArray decodeValues)

This will set the decode values.

Parameters
decodeValues:COSArray

The new decode values.

setEncodeValuesback to summary
public void setEncodeValues(COSArray encodeValues)

This will set the encode values.

Parameters
encodeValues:COSArray

The new encode values.

org.apache.pdfbox.pdmodel.common.function back to summary

private Class PDFunctionType0.Rinterpol

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.pdfbox.pdmodel.common.function.PDFunctionType0.Rinterpol

Inner class do to an interpolation in the Nth dimension by comparing the content size of N-1 dimensional objects. This is done with the help of recursive calls. To understand the algorithm without recursion, here is a bilinear interpolation and here's a trilinear interpolation (external links).

Field Summary

Modifier and TypeField and Description
private final float[]
private final int[]
private final int[]
private final int
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
Rinterpol(float[]
the input coordinates
input
,
int[]
coordinate of the "ceil" point
inputPrev
,
int[]
coordinate of the "floor" point
inputNext
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private int

Returns:

index in flat array
calcSampleIndex
(int[]
with coordinates
vector
)

calculate array index (structure described in p.171 PDF spec 1.7) in multiple dimensions.

private int[][]

Returns:

an array with all samples.
getSamples
()

Get all sample values of this function.

private float[]

Returns:

interpolated result sample
rinterpol
(int[]
coord partially set coordinate (not set from step upwards); gets fully filled in the last call ("leaf"), where it is used to get the correct sample
coord
,
int
between 0 (first call) and dimension - 1
step
)

Do a linear interpolation if the two coordinates can be known, or call itself recursively twice.

pack-priv float[]

Returns:

interpolated result sample
rinterpolate
()

Calculate the interpolation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

inback to summary
private final float[] in
inNextback to summary
private final int[] inNext
inPrevback to summary
private final int[] inPrev
numberOfInputValuesback to summary
private final int numberOfInputValues
numberOfOutputValuesback to summary
private final int numberOfOutputValues

Constructor Detail

Rinterpolback to summary
pack-priv Rinterpol(float[] input, int[] inputPrev, int[] inputNext)

Constructor.

Parameters
input:float[]

the input coordinates

inputPrev:int[]

coordinate of the "ceil" point

inputNext:int[]

coordinate of the "floor" point

Method Detail

calcSampleIndexback to summary
private int calcSampleIndex(int[] vector)

calculate array index (structure described in p.171 PDF spec 1.7) in multiple dimensions.

Parameters
vector:int[]

with coordinates

Returns:int

index in flat array

getSamplesback to summary
private int[][] getSamples()

Get all sample values of this function.

Returns:int[][]

an array with all samples.

rinterpolback to summary
private float[] rinterpol(int[] coord, int step)

Do a linear interpolation if the two coordinates can be known, or call itself recursively twice.

Parameters
coord:int[]

coord partially set coordinate (not set from step upwards); gets fully filled in the last call ("leaf"), where it is used to get the correct sample

step:int

between 0 (first call) and dimension - 1

Returns:float[]

interpolated result sample

rinterpolateback to summary
pack-priv float[] rinterpolate()

Calculate the interpolation.

Returns:float[]

interpolated result sample