org.foray.pdf.object
Class PDFFunction

java.lang.Object
  extended by org.foray.pdf.object.PDFObject
      extended by org.foray.pdf.object.PDFFunction

public class PDFFunction
extends PDFObject

class representing a PDF Function. PDF Functions represent parameterized mathematical formulas and sampled representations with arbitrary resolution. Functions are used in two areas: device-dependent rasterization information for halftoning and transfer functions, and color specification for smooth shading (a PDF 1.3 feature). All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.


Field Summary
static byte ORDER_CUBIC_SPLINE_INTERPOLATION
          Constant for Type 0 functions, indicating a "cubic spline interpolation" order.
static byte ORDER_LINEAR
          Constant for Type 0 functions, indicating a "linear" order.
static byte TYPE_EXP_INTERPOLATED
          Constant indicating a "FunctionType" of "Exponential interpolation function".
static byte TYPE_PS_CALCULATOR
          Constant indicating a "FunctionType" of "PostScript calculator function".
static byte TYPE_SAMPLED
          Constant indicating a "FunctionType" of "Sampled function".
static byte TYPE_STITCHING
          Constant indicating a "FunctionType" of "Stitching function".
 
Fields inherited from class org.foray.pdf.object.PDFObject
EOL, MSG_EOL, XREF_EOL
 
Constructor Summary
PDFFunction(PDFDocument doc, int theFunctionType, List<Double> theDomain, List<Double> theRange, List<Double> theSize, int theBitsPerSample, int theOrder, List<Double> theEncode, List<Double> theDecode, StringBuilder theFunctionDataStream, List<String> theFilter)
          Create a complete Function object of Type 0, a Sampled function.
PDFFunction(PDFDocument doc, int theFunctionType, List<Double> theDomain, List<Double> theRange, List<Double> theCZero, List<Double> theCOne, double theInterpolationExponentN)
          Create a complete Function object of Type 2, an Exponential Interpolation function.
PDFFunction(PDFDocument doc, int theFunctionType, List<Double> theDomain, List<Double> theRange, List<PDFFunction> theFunctions, List<Double> theBounds, List<Double> theEncode)
          create an complete Function object of Type 3, a Stitching function.
PDFFunction(PDFDocument doc, int theFunctionType, List<Double> theDomain, List<Double> theRange, StringBuilder theFunctionDataStream)
          create an complete Function object of Type 4, a postscript calculator function.
 
Method Summary
 String toPDF()
          represent as PDF.
 
Methods inherited from class org.foray.pdf.object.PDFObject
bufferToByteArray, byteArrayToStream, getCharsPerLine, getGeneration, getLogger, getNumber, getPDFDocument, output, pdfID, pdfReference, setNumber, stringToByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_SAMPLED

public static final byte TYPE_SAMPLED
Constant indicating a "FunctionType" of "Sampled function".

See Also:
"PDF Reference, 3rd Ed., Table 3.26.", Constant Field Values

TYPE_EXP_INTERPOLATED

public static final byte TYPE_EXP_INTERPOLATED
Constant indicating a "FunctionType" of "Exponential interpolation function".

See Also:
"PDF Reference, 3rd Ed., Table 3.26.", Constant Field Values

TYPE_STITCHING

public static final byte TYPE_STITCHING
Constant indicating a "FunctionType" of "Stitching function".

See Also:
"PDF Reference, 3rd Ed., Table 3.26.", Constant Field Values

TYPE_PS_CALCULATOR

public static final byte TYPE_PS_CALCULATOR
Constant indicating a "FunctionType" of "PostScript calculator function".

See Also:
"PDF Reference, 3rd Ed., Table 3.26.", Constant Field Values

ORDER_LINEAR

public static final byte ORDER_LINEAR
Constant for Type 0 functions, indicating a "linear" order.

See Also:
Constant Field Values

ORDER_CUBIC_SPLINE_INTERPOLATION

public static final byte ORDER_CUBIC_SPLINE_INTERPOLATION
Constant for Type 0 functions, indicating a "cubic spline interpolation" order.

See Also:
Constant Field Values
Constructor Detail

PDFFunction

public PDFFunction(PDFDocument doc,
                   int theFunctionType,
                   List<Double> theDomain,
                   List<Double> theRange,
                   List<Double> theSize,
                   int theBitsPerSample,
                   int theOrder,
                   List<Double> theEncode,
                   List<Double> theDecode,
                   StringBuilder theFunctionDataStream,
                   List<String> theFilter)
Create a complete Function object of Type 0, a Sampled function. Use null for an optional object parameter if you choose not to use it. For optional int parameters, pass the default.

Parameters:
theDomain - List objects of Double objects. This is the domain of the function. See page 264 of the PDF 1.3 Spec.
theRange - List objects of Double objects. This is the Range of the function. See page 264 of the PDF 1.3 Spec.
theSize - A List object of Integer objects. This is the number of samples in each input dimension. I can't imagine there being more or less than two input dimensions, so maybe this should be an array of length 2. See page 265 of the PDF 1.3 Spec.
theBitsPerSample - An int specifying the number of bits user to represent each sample value. Limited to 1,2,4,8,12,16,24 or 32. See page 265 of the 1.3 PDF Spec.
theOrder - The order of interpolation between samples. Default is 1 (one). Limited to 1 (one) or 3, which means linear or cubic-spline interpolation. This attribute is optional. See page 265 in the PDF 1.3 spec.
theEncode - List objects of Double objects. This is the linear mapping of input values intop the domain of the function's sample table. Default is hard to represent in ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. This attribute is optional. See page 265 in the PDF 1.3 spec.
theDecode - List objects of Double objects. This is a linear mapping of sample values into the range. The default is just the range. This attribute is optional. Read about it on page 265 of the PDF 1.3 spec.
theFunctionDataStream - The sample values that specify the function are provided in a stream. This is optional, but is almost always used. Page 265 of the PDF 1.3 spec has more.
theFilter - This is a List of String objects which are the various filters that have are to be applied to the stream to make sense of it. Order matters, so watch out. This is not documented in the Function section of the PDF 1.3 spec, it was deduced from samples that this is sometimes used.
doc - The parent PDF document.
theFunctionType - This is the type of function (0,2,3, or 4). It should be 0 as this is the constructor for sampled functions.

PDFFunction

public PDFFunction(PDFDocument doc,
                   int theFunctionType,
                   List<Double> theDomain,
                   List<Double> theRange,
                   List<Double> theCZero,
                   List<Double> theCOne,
                   double theInterpolationExponentN)
Create a complete Function object of Type 2, an Exponential Interpolation function. Use null for an optional object parameter if you choose not to use it. For optional int parameters, pass the default.

Parameters:
doc - The parent PDF document.
theDomain - List objects of Double objects. This is the domain of the function. See page 264 of the PDF 1.3 Spec.
theRange - List of Doubles that is the Range of the function. See page 264 of the PDF 1.3 Spec.
theCZero - This is a List of Double objects which defines the function result when x=0. This attribute is optional. It's described on page 268 of the PDF 1.3 spec.
theCOne - This is a List of Double objects which defines the function result when x=1. This attribute is optional. It's described on page 268 of the PDF 1.3 spec.
theInterpolationExponentN - This is the inerpolation exponent. This attribute is required. PDF Spec page 268
theFunctionType - The type of the function, which should be 2.

PDFFunction

public PDFFunction(PDFDocument doc,
                   int theFunctionType,
                   List<Double> theDomain,
                   List<Double> theRange,
                   List<PDFFunction> theFunctions,
                   List<Double> theBounds,
                   List<Double> theEncode)
create an complete Function object of Type 3, a Stitching function. Use null for an optional object parameter if you choose not to use it. For optional int parameters, pass the default.

Parameters:
doc - The parent PDF document.
theDomain - List objects of Double objects. This is the domain of the function. See page 264 of the PDF 1.3 Spec.
theRange - List objects of Double objects. This is the Range of the function. See page 264 of the PDF 1.3 Spec.
theFunctions - A List of the PDFFunction objects that the stitching function stitches. This attributed is required. It is described on page 269 of the PDF spec.
theBounds - This is a List of Doubles representing the numbers that, in conjunction with Domain define the intervals to which each function from the 'functions' object applies. It must be in order of increasing magnitude, and each must be within Domain. It basically sets how much of the gradient each function handles. This attributed is required. It's described on page 269 of the PDF 1.3 spec.
theEncode - List objects of Double objects. This is the linear mapping of input values intop the domain of the function's sample table. Default is hard to represent in ascii, but basically [0 (Size0 1) 0 (Size1 1)...]. This attribute is required. See page 270 in the PDF 1.3 spec.
theFunctionType - This is the function type. It should be 3, for a stitching function.

PDFFunction

public PDFFunction(PDFDocument doc,
                   int theFunctionType,
                   List<Double> theDomain,
                   List<Double> theRange,
                   StringBuilder theFunctionDataStream)
create an complete Function object of Type 4, a postscript calculator function. Use null for an optional object parameter if you choose not to use it. For optional int parameters, pass the default.

Parameters:
theDomain - List object of Double objects. This is the domain of the function. See page 264 of the PDF 1.3 Spec.
theRange - List object of Double objects. This is the Range of the function. See page 264 of the PDF 1.3 Spec.
theFunctionDataStream - This is a stream of arithmetic, boolean, and stack operators and boolean constants. I end up enclosing it in the '{' and '}' braces for you, so don't do it yourself. This attribute is required. It's described on page 269 of the PDF 1.3 spec.
doc - The parent PDF document.
theFunctionType - The type of function which should be 4, as this is a Postscript calculator function
Method Detail

toPDF

public String toPDF()
represent as PDF. Whatever the FunctionType is, the correct representation spits out. The sets of required and optional attributes are different for each type, but if a required attribute's object was constructed as null, then no error is raised. Instead, the malformed PDF that was requested by the construction is dutifully output. This policy should be reviewed.

Returns:
the PDF string.


Copyright © 2017. All rights reserved.