com.sun.pdfview.function

Class FunctionType0

public class FunctionType0 extends PDFFunction

A sampled function maps input values to output values by interpolating along a line or cubic between two known values.
Field Summary
protected static intCUBIC_INTERPOLATION
protected static intLINEAR_INTERPOLATION
the valid interpolation methods
Constructor Summary
protected FunctionType0()
Creates a new instance of FunctionType0
Method Summary
protected voiddoFunction(float[] inputs, int inputOffset, float[] outputs, int outputOffset)
Map from m input values to n output values.
protected intgetBitsPerSample()
Get the number of bits per sample
protected floatgetDecode(int i)
Get the decoding for a particular input parameter
protected floatgetEncode(int i)
Get the encoding for a particular input parameter
protected intgetOrder()
Get the interpolation type
protected intgetSample(int[] values, int od)
Get a component for a sample given m indices and output dimension.
protected intgetSize(int dimension)
Get the size of a given input dimension
static floatinterpolate(float x, float xmin, float xmax, float ymin, float ymax)
Perform a linear interpolation.
protected voidparse(PDFObject obj)
Read the function information from a PDF Object
protected voidsetBitsPerSample(int bits)
Set the number of bits per sample
protected voidsetDecode(float[] decode)
Set the decode array
protected voidsetEncode(float[] encode)
Set the encode array
protected voidsetOrder(int order)
Set the interpolation type
protected voidsetSamples(int[][] samples)
Set the table of samples
protected voidsetSize(int[] size)
Set the size of all input dimensions

Field Detail

CUBIC_INTERPOLATION

protected static final int CUBIC_INTERPOLATION

LINEAR_INTERPOLATION

protected static final int LINEAR_INTERPOLATION
the valid interpolation methods

Constructor Detail

FunctionType0

protected FunctionType0()
Creates a new instance of FunctionType0

Method Detail

doFunction

protected void doFunction(float[] inputs, int inputOffset, float[] outputs, int outputOffset)
Map from m input values to n output values. The number of inputs m must be exactly one half the size of the domain. The number of outputs should match one half the size of the range.

Parameters: inputs an array of m input values outputs an array of size n which will be filled with the output values, or null to return a new array

getBitsPerSample

protected int getBitsPerSample()
Get the number of bits per sample

getDecode

protected float getDecode(int i)
Get the decoding for a particular input parameter

Parameters: i the index into the decoding array, which has size 2 * n. the ith entry in the array has index 2i, 2i + 1

Returns: the decoding value if the decoding array is set, or the default

getEncode

protected float getEncode(int i)
Get the encoding for a particular input parameter

Parameters: i the index into the encoding array, which has size 2 * m. the ith entry in the array has index 2i, 2i + 1

Returns: the encoding value if the encoding array is set, or the default

getOrder

protected int getOrder()
Get the interpolation type

getSample

protected int getSample(int[] values, int od)
Get a component for a sample given m indices and output dimension.

Parameters: values an array of m values determining which sample to select od the output dimension (0 - n) to get the sample in

Returns: the sample for the given values and index

getSize

protected int getSize(int dimension)
Get the size of a given input dimension

Parameters: dimension the input dimension to get the size of

Returns: the number of samples in the given dimension

interpolate

public static float interpolate(float x, float xmin, float xmax, float ymin, float ymax)
Perform a linear interpolation. Given a value x, and two points, (xmin, ymin), (xmax, ymax), where xmin <= x <= xmax, calculate a value y on the line from (xmin, ymin) to (xmax, ymax).

Parameters: x the x value of the input xmin the minimum x value ymin the minimum y value xmax the maximum x value ymax the maximum y value

Returns: the y value interpolated from the given x

parse

protected void parse(PDFObject obj)
Read the function information from a PDF Object

setBitsPerSample

protected void setBitsPerSample(int bits)
Set the number of bits per sample

setDecode

protected void setDecode(float[] decode)
Set the decode array

setEncode

protected void setEncode(float[] encode)
Set the encode array

setOrder

protected void setOrder(int order)
Set the interpolation type

setSamples

protected void setSamples(int[][] samples)
Set the table of samples

setSize

protected void setSize(int[] size)
Set the size of all input dimensions