fop 1.1

## org.apache.fop.pdf
Class PDFFunction

    java.lang.Object
      org.apache.fop.pdf.PDFObject
          org.apache.fop.pdf.PDFFunction

All Implemented Interfaces:
  PDFWritable

    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
`protected int` `bitsPerSample` Required for Type 0: Number of Bits used to represent each sample value.
`protected java.util.List` `bounds` Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply.
`protected java.util.List` `cOne` Required For Type 2: An Array of n Doubles defining the function result when x=1.
`protected java.util.List` `cZero` Required For Type 2: An Array of n Doubles defining the function result when x=0.
`protected java.util.List` `decode` Optional for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range.
`protected java.util.List` `domain` Required: 2 * m Array of Double numbers which are possible inputs to the function
`protected java.util.List` `encode` Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain.
`protected java.util.List` `filter` Required (possibly) For Type 0: A vector of Strings for the various filters to be used to decode the stream.
`protected java.lang.StringBuffer` `functionDataStream` Required For Type 4: Postscript Calculator function composed of arithmetic, boolean, and stack operators + boolean constants
`protected java.util.List` `functions` Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function.
`protected int` `functionType` Required: The Type of function (0,2,3,4) default is 0.
`protected double` `interpolationExponentN` Required for Type 2: The interpolation exponent.
`protected int` `order` Optional for Type 0: order of interpolation between samples.
`protected java.util.List` `range` Required: 2 * n Array of Double numbers which are possible outputs to the function
`protected java.util.List` `size` Required: Array containing the Integer size of the Domain and Range, respectively.

Fields inherited from class org.apache.fop.pdf.PDFObject
`log`

Constructor Summary
`PDFFunction(int theFunctionType, java.util.List theDomain, java.util.List theRange, java.util.List theSize, int theBitsPerSample, int theOrder, java.util.List theEncode, java.util.List theDecode, java.lang.StringBuffer theFunctionDataStream, java.util.List theFilter)` create an complete Function object of Type 0, A Sampled function.
`PDFFunction(int theFunctionType, java.util.List theDomain, java.util.List theRange, java.util.List theCZero, java.util.List theCOne, double theInterpolationExponentN)` create an complete Function object of Type 2, an Exponential Interpolation function.
`PDFFunction(int theFunctionType, java.util.List theDomain, java.util.List theRange, java.util.List theFunctions, java.util.List theBounds, java.util.List theEncode)` create an complete Function object of Type 3, a Stitching function.
`PDFFunction(int theFunctionType, java.util.List theDomain, java.util.List theRange, java.lang.StringBuffer theFunctionDataStream)` create an complete Function object of Type 4, a postscript calculator function.

Method Summary
`protected boolean` `contentEquals(PDFObject obj)` Check if the other PDFObject has the same content as the current object.
`byte[]` `toPDF()` represent as PDF.

Methods inherited from class org.apache.fop.pdf.PDFObject
`encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, output, outputInline, referencePDF, setDocument, setObjectNumber, setParent, toPDFString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### functionType

    protected int functionType

  Required: The Type of function (0,2,3,4) default is 0.

### domain

    protected java.util.List domain

  Required: 2 * m Array of Double numbers which are possible inputs to the function

### range

    protected java.util.List range

  Required: 2 * n Array of Double numbers which are possible outputs to the function

### size

    protected java.util.List size

  Required: Array containing the Integer size of the Domain and Range, respectively. Note: This is really more like two seperate integers, sizeDomain, and sizeRange, but since they're expressed as an array in PDF, my implementation reflects that.

### bitsPerSample

    protected int bitsPerSample

  Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32

### order

    protected int order

  Optional for Type 0: order of interpolation between samples. Limited to linear (1) or cubic (3). Default is 1

### encode

    protected java.util.List encode

  Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain. Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function. Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions.

### decode

    protected java.util.List decode

  Optional for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range. Defaults to Range.

### functionDataStream

    protected java.lang.StringBuffer functionDataStream

  Required For Type 4: Postscript Calculator function composed of arithmetic, boolean, and stack operators + boolean constants

### filter

    protected java.util.List filter

  Required (possibly) For Type 0: A vector of Strings for the various filters to be used to decode the stream. These are how the string is compressed. Flate, LZW, etc.

### cZero

    protected java.util.List cZero

  Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0].

### cOne

    protected java.util.List cOne

  Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1].

### interpolationExponentN

    protected double interpolationExponentN

  Required for Type 2: The interpolation exponent. Each value x will return n results. Must be greater than 0.

### functions

    protected java.util.List functions

  Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function.

### bounds

    protected java.util.List bounds

  Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain. k is the number of functions. If you pass null, it will output (1/k) in an array of k-1 elements. This makes each function responsible for an equal amount of the stitching function. It makes the gradient even.

Constructor Detail

### PDFFunction

    public PDFFunction(int theFunctionType,
                       java.util.List theDomain,
                       java.util.List theRange,
                       java.util.List theSize,
                       int theBitsPerSample,
                       int theOrder,
                       java.util.List theEncode,
                       java.util.List theDecode,
                       java.lang.StringBuffer theFunctionDataStream,
                       java.util.List theFilter)

  create an 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 used 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 vector 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, even if we may never use it in FOP. It is added for completeness sake.
    `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(int theFunctionType,
                       java.util.List theDomain,
                       java.util.List theRange,
                       java.util.List theCZero,
                       java.util.List theCOne,
                       double theInterpolationExponentN)

  create an 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:
    `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 vector 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 vector 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(int theFunctionType,
                       java.util.List theDomain,
                       java.util.List theRange,
                       java.util.List theFunctions,
                       java.util.List theBounds,
                       java.util.List 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:
    `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 vector 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(int theFunctionType,
                       java.util.List theDomain,
                       java.util.List theRange,
                       java.lang.StringBuffer 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.
    `theFunctionType` - The type of function which should be 4, as this is a Postscript calculator function

Method Detail

### toPDF

    public byte[] 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.

  Overrides:
    `toPDF` in class `PDFObject`
  Returns:
    the PDF string.

### contentEquals

    protected boolean contentEquals(PDFObject obj)

  Check if the other PDFObject has the same content as the current object.

  Note: This function has a contract which is less binding than `Object.equals(Object)`. Whereas equals would require all values to be identical, this method is not required to check everything. In the case of PDFObjects, this means that the overriding function does not have to check for `PDFObject.getObjectID()`.

  Overrides:
    `contentEquals` in class `PDFObject`
  Parameters:
    `obj` - object to compare to.
  Returns:
    true if the other object has the same content.

fop 1.1

Copyright 1999-2012 The Apache Software Foundation. All Rights Reserved.